Computer Knowledge
Data Structures and Algorithms
1,518 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
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).
-
TRUE
-
FALSE
-
Undefined
-
None of these
B
Correct answer
Explanation
The question is garbled, but PRCD(x, y) typically returns false if x does not have precedence over y. Given the context of operator precedence, the output is FALSE.
-
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.
C
Correct answer
Explanation
In a binary heap, the minimum number of nodes for a given depth d occurs when all levels up to d-1 are completely filled and the last level has only a single node. The formula for the minimum nodes for depth d is 2^d.
-
Equal to height of the tree
-
Constant
-
Number of nodes in the heap
-
None of these
A
Correct answer
Explanation
In a binary heap, decreasing a key may require 'bubbling up' the node to maintain the heap property. This process takes time proportional to the height of the tree, which is O(log n).
-
Infix to postfix conversion
-
Infix to prefix conversion
-
Postfix evaluation
-
None of these
C
Correct answer
Explanation
Multipop is often used in the analysis of stack operations or specific algorithms like postfix evaluation where multiple operands need to be popped to perform an operation.