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
-
Stack
-
Queue
-
Heap
-
Link list
C
Correct answer
Explanation
For run time memory location, heap is used. As we don't know the size of memory required to allocate. So, heap is used to allocate memory.
-
Link list
-
Graph
-
Tree
-
Stack
B
Correct answer
Explanation
The data structure which is used to manipulate data is called self referential structure. Graph is a self referential structure. So answer is correct as in Graph structure, we cannot refer all the vertices in some order.
A
Correct answer
Explanation
In link list, when value is assigned, its link part is updated. As after step 2, P is pointing to C, after third step, B is pointing to D, after 4th step, D's link is updated with C and in 5th step, P is pointing to C, so C will be printed.
In linklist when value is assigned, Its link part is updated.
As After step 2 P is pointing to C.After third step B is pointing to DAfter 4th step D's link is updated with CAnd 5th step P is pointing to C So C is printed.
B
Correct answer
Explanation
Three dimensional array consists of 2D array. First 2 is indicating there are two matrices. So A(0)(0)(1 ) is indicating to 2. A(1)(1)(1) can be written as (((*a +1)+ 1)+1 ), so A(0)(0)(1 ) is referring to second memory location, which is 2. So option as 2 is correct.
-
C B F E D A
-
C B E F A D
-
B C F E D A
-
C B E F D A
D
Correct answer
Explanation
- In POST order traversal, first traverse left, then right and then print node. 2. If the sequence to traversal is given then it is easy to predict the tree. In preorder, the node which is traversed first is the root of the tree. So, here A is the root. Now take each node from preorder list and now from list in order the node which is right side of A is right and the node which is on left will come in left. Now traverse one by one each element from the list and make a tree and then find post order traversal from first step. On traversing the tree, we get following sequence for post order: C B E F D A. So the option C B E F D A is correct.
-
Ascending order
-
Random order
-
Descending order
-
None of the above
A
Correct answer
Explanation
It will be printed in ascending order as a root node has all the smaller elements in its left side and all the larger elements in its right side. Likewise it is arranged for each node, always left child is smaller and right child is larger. So, it will arrange all elements in ascending order. So it is correct option.
-
strictly binary tree
-
binary tree
-
AVL tree
-
none of the above
A
Correct answer
Explanation
If a binary tree contains either zero or two child, then it is called as strict binary tree.
-
O(n2)
-
O(nlogn)
-
O(logn)
-
O(n)
A
Correct answer
Explanation
Selection sort makes n-1 passes, each time scanning remaining unsorted elements to find the minimum. This always requires roughly n²/2 comparisons, giving O(n²) in all cases.
-
O(n2)
-
O(nlogn)
-
O(logn)
-
O(n)
A
Correct answer
Explanation
Insertion sort's average case involves shifting roughly half the sorted portion on average per insertion, leading to O(n²) comparisons and shifts overall.
-
O(n2)
-
O(nlogn)
-
O(logn)
-
O(n)
A
Correct answer
Explanation
Insertion sort's worst case occurs with reverse-sorted input, where each new element must shift through all existing sorted elements, requiring O(n²) comparisons and shifts.
-
O(n2)
-
O(nlogn)
-
O(logn)
-
O(n)
A
Correct answer
Explanation
Bubble sort's worst case occurs with reverse-sorted input, requiring maximum passes (n-1) and maximum comparisons/swaps per pass, resulting in O(n²) total operations.
-
O(n2)
-
O(nlogn)
-
O(logn)
-
O(n)
B
Correct answer
Explanation
Quick sort's average case achieves O(n log n) when pivots consistently create roughly balanced partitions, dividing the problem size logarithmically.
-
O
-
O(n)
-
O(logn)
-
None of these
B
Correct answer
Explanation
Merge sort requires O(n) auxiliary space for the temporary arrays used during the merge phase of each recursive call, regardless of time complexity.
-
O(n2)
-
O(nlogn)
-
O(logn)
-
O(n)
B
Correct answer
Explanation
Merge sort always divides input in half and recursively merges, requiring n comparisons per level across log n levels, giving O(n log n) in all cases.
-
0
-
O(n)
-
O(logn)
-
None of these
B
Correct answer
Explanation
Quick sort's worst-case space complexity is O(n) for recursive implementations when poor pivots create maximum recursion depth, causing stack frames proportional to input size. (Note: optimized implementations using tail recursion or iteration can achieve O(log n)).