Computer Knowledge
Data Structures and Algorithms
1,256 Questions
Data Structures and Algorithms form the core of computer science, focusing on arrays, linked lists, trees, and sorting mechanisms. These concepts are essential for solving complex computational problems efficiently. Test takers preparing for technical and administrative IT exams will find these questions highly relevant.
Array OperationsLinked List ApplicationsSorting AlgorithmsTree Data StructuresMultilevel IndexingAlgorithm Time Complexity
Data Structures and Algorithms Questions
-
A B C D
-
B A C D
-
B A D C
-
A B D C
B
Correct answer
Explanation
A node in a doubly linked list contains three fields: the data field, a pointer to the next node, and a pointer to the previous node.
C
Correct answer
Explanation
In a doubly linked list of 10 nodes, each node has two pointers. However, the first node's 'previous' pointer and the last node's 'next' pointer are null. Thus, there are 9 'next' pointers and 9 'previous' pointers, totaling 18 active links.
C
Correct answer
Explanation
In an array of 10 elements, if the 4th element is deleted, the elements from index 5 to 10 must be shifted one position to the left to fill the gap. This affects 6 elements (5th, 6th, 7th, 8th, 9th, and 10th).
-
Both are LIFO lists.
-
Both are FIFO lists.
-
Both are linear data structures.
-
Insertion in both the data structures take place at the same end.
C
Correct answer
Explanation
Stacks and queues are both linear data structures, meaning their elements are arranged in a sequential order. They differ in their access patterns (LIFO vs FIFO) and insertion/deletion points.
A
Correct answer
Explanation
A node in a doubly linked list typically contains three fields: the data field, a pointer to the previous node, and a pointer to the next node.
A
Correct answer
Explanation
In a doubly linked list, each node has two pointers (next and prev). For 10 nodes, there are 10 * 2 = 20 pointers.
-
O(nlog n)
-
O(n2)
-
O(n2log n)
-
O(n)
A
Correct answer
Explanation
Quick sort has an average time complexity of O(n log n).
-
Front = 0
-
Rear = -1
-
Rear = Front
-
Rear - Front + 1 = 0
D
Correct answer
Explanation
In a linear queue implemented with an array, the condition Rear - Front + 1 = 0 (or simply Rear < Front) indicates that the queue is empty, meaning an underflow occurs if a dequeue operation is attempted.
-
available list is empty
-
available list is full
-
available list is half full
-
none of these
A
Correct answer
Explanation
In linked list management, the 'available list' stores free nodes. If the available list is empty, there are no free nodes to allocate, resulting in an overflow condition when a new node is requested.
-
Front = MAXQUEUE
-
Rear = MAXQUEUE -1
-
Rear = Front
-
Rear - Front + 1 = 0
B
Correct answer
Explanation
In a linear queue implemented with an array of size MAXQUEUE, the rear pointer increments with each insertion. Overflow occurs when the rear pointer reaches the last index, which is MAXQUEUE - 1.
-
Insertion in array is costlier whereas linked list is cheaper.
-
Deletion in array is costlier whereas linked list is cheaper.
-
Traversal in array is costlier whereas linked list is cheaper.
-
Linked list requires more memory than array.
C
Correct answer
Explanation
Traversal in an array is O(n) and in a linked list is also O(n). Therefore, stating that traversal in an array is costlier than in a linked list is incorrect.
-
Infix to postfix conversion
-
Infix to prefix conversion
-
Postfix evaluation
-
Prefix evaluation
B
Correct answer
Explanation
To convert an infix expression to a prefix expression, the standard algorithm involves reversing the infix string, converting it to postfix, and then reversing the result.