Data Structure & Algorithm Quiz by azka.xdlabin QuizApril 5, 2025 Data Structure & Algorithm Qiuz 1 / 100In a Binary Search Tree (BST), the left subtree has: Only greater elements Only smaller elements Only leaf nodes Random elements 2 / 100How many passes are required to sort an array of n elements using Bubble Sort (worst case)? n n-1 n/2 log n 3 / 100What happens when you dequeue from an empty queue? Returns 0 Overflow Underflow NULL 4 / 100Which traversal method is best for copying a tree? Pre-order In-order Post-order Level-order 5 / 100What does a node in a singly linked list contain? Data only Data and pointer to next node Only pointer Data and pointer to previous node 6 / 100Which of these is not a limitation of Radix Sort? Works only with integers Needs extra space Stable sort Inefficient for large digit ranges 7 / 100What is a leaf node? Node with one child Node with no children Root node Middle node 8 / 100What is the total number of comparisons in Selection Sort for an array of 4 elements? 4 5 10 6 9 / 100In Merge Sort, what happens during the merge step? Splitting arrays Swapping arrays Combining sorted subarrays Reversing arrays 10 / 100Which operation is used to insert an element into the stack? enqueue dequeue push pop 11 / 100Which of these is true about Quick Sort? Requires extra space Is a stable algorithm Can be implemented in-place Slower than Bubble Sort 12 / 100Which of the following is not an application of stack? Function call management Expression evaluation Undo operation Binary search 13 / 100How many comparisons are needed in the worst case to insert the last element in an array of size n using Insertion Sort? 1 n-1 n log n 14 / 100Which operation is more efficient in a linked list than in an array? Accessing an element Insertion/deletion at beginning Accessing middle element Searching an element 15 / 100What is the time complexity of push and pop operations? O(n) O(log n) O(1) O(n²) 16 / 100Which of the following is a type of queue? Circular queue Priority queue Deque All of the above 17 / 100What happens in each step of binary search? Search entire array again Divide the array into halves Double the search space Reverse the array 18 / 100What is an AVL Tree? A type of heap A self-balancing binary search tree A graph A queue 19 / 100What does the last node in a singly linked list point to? Itself First node NULL Garbage value 20 / 100Which of the following rotations is used to fix Right-Right (RR) imbalance? Left Rotation Right Rotation Right-Left Rotation None 21 / 100Array elements are stored in ? Heap Stack/Heap depending on declaration ROM CPU cache 22 / 100What is returned if the element is not found? -1 0 1 null 23 / 100What happens if you forget to update the mid index inside the loop? Nothing Faster search Infinite loop Segmentation fault 24 / 100What will happen if you access arr[1000] when size is arr[10]? Segmentation fault / Undefined behavior Prints 0 Compile error Returns NULL 25 / 100What will be the array after the first pass of Selection Sort on [5, 2, 8, 4]? [2, 5, 8, 4] [5, 2, 4, 8] [4, 2, 5, 8] [5, 2, 8, 4] 26 / 100Which data structure is used to implement recursion? Queue Stack Heap Tree 27 / 100What is the time complexity of Radix Sort? O(n²) O(n log n) O(d * (n + k)) O(log n) 28 / 100Linear search is also known as: Binary search Sequential search Direct search Fast search 29 / 100What is the index of the first element in an array? 1 0 -1 n 30 / 100Is Selection Sort a stable algorithm? Yes No Depends Only for Integers 31 / 100Which of the following can lead to worst-case behavior in Quick Sort? Choosing a good pivot Randomizing the array Already sorted array Equal elements 32 / 100Quick Sort follows which programming paradigm? Greedy Divide and Conquer Dynamic Programming Backtracking 33 / 100What is the best-case time complexity of binary search? O(n) O(1) O(log n) O(n/2) 34 / 100What is the average-case time complexity of Quick Sort? O(n²) O(n log n) O(log n) O(n) 35 / 100In a binary tree, each node can have at most: 1 child 2 children 3 children Unlimited children 36 / 100What is the time complexity of searching in a balanced binary search tree? O(n) O(log n) O(1) O(n²) 37 / 100What is the time complexity of Counting Sort? O(n log n) O(n²) O(n + k) O(log n) 38 / 100How can we find the size of an array in C? size(arr) len(arr) sizeof(arr)/sizeof(arr[0]) length(arr) 39 / 100Queue follows which principle? LIFO FILO FIFO None 40 / 100What is the time complexity of binary search in the worst case? O(n) O(n log n) O(log n) O(1) 41 / 100Radix Sort is based on which principle? Divide and Conquer Divide and Conquer Counting and Place Value Recursion 42 / 100In how many swaps does Bubble Sort sort [3, 2, 1]? 2 3 1 4 43 / 100Merge Sort requires: No extra space In-place recursi Additional memory O(1) auxiliary space 44 / 100What is the default value of an uninitialized int array ? 0 Depends on compiler Garbage NULL 45 / 100Which of the following is true about Counting Sort? It is always faster than Quick Sort It uses divide and conquer It uses additional space It works well for very large ranges 46 / 100Which data structure is used to implement queue efficiently? Array Linked list Both Tree 47 / 100When does Merge Sort perform better than Quick Sort? When array is already sorted For large arrays with many duplicate values For linked lists For small arrays 48 / 100What is the rear of a queue? First element Middle element Last element NULL 49 / 100Bubble Sort works by repeatedly ? Dividing array into halves Swapping adjacent elements if they are in wrong order Selecting smallest element Using stacks 50 / 100Radix Sort is most effective when: Data has large digits and values Data is small and sorted All input numbers have similar lengths Elements are floating points 51 / 100Bubble Sort is a type of ? Divide and conquer algorithm Recursive algorithm Comparison-based sorting algorithm Counting algorithm 52 / 100Which of the following is true about Selection Sort? It is stable It performs fewer swaps than Bubble Sort It uses recursion It is faster than Merge Sort 53 / 100What is the time complexity to insert a node at the beginning of a singly linked list? O(1) O(n) O(log n) O(n log n) 54 / 100Which header file is required for using sizeof() operator? stdlib.h math.h No header required stdio.h 55 / 100Merge Sort is best suited for: Small arrays Large datasets Already sorted arrays Linked lists only 56 / 100Which sorting algorithm is typically used as a subroutine in Radix Sort? Quick Sort Merge Sort Counting Sort Bubble Sort 57 / 100Is Insertion Sort a stable sorting algorithm? Yes No Depends on data Not Depend on data 58 / 100In the worst case, Quick Sort's time complexity is: O(n) O(log n) O(n log n) O(n²) 59 / 100Merge Sort follows which algorithmic strategy? Greedy Dynamic Programming Divide and Conquer Backtracking 60 / 100Which type of linked list allows traversal in both directions? Singly linked list Doubly linked list Circular linked list Multi-directional list 61 / 100Which part of the array is considered sorted during Selection Sort? Left side Right side Middle None 62 / 100Which sorting technique inserts each element into its correct position? Selection Sort Merge Sort Insertion Sort Heap Sort 63 / 100Binary search works only on: Unsorted arrays Sorted arrays Linked lists Any data 64 / 100What will be the final sorted array after applying Bubble Sort on [6, 2, 8, 4]? [2, 4, 6, 8] [4, 6, 8, 2] [1, 4, 6, 8] [0, 4, 6, 8] 65 / 100Linear search can be applied to: Arrays only Lists only Any linear data structure Trees only 66 / 100Which rotation is used to fix Left-Right (LR) imbalance? Left Rotation Right Rotation Left-Right Rotation Right-Left Rotation 67 / 100What is the time complexity of Selection Sort in the worst case? O(n log n) O(n²) O(n) O(1) 68 / 100What is the correct way to declare an array of 10 integers in C? int arr[10]; int arr(10); int arr{10}; array arr[10]; 69 / 100What is the allowed balance factor for any node in AVL tree? Only 0 Between -1 and 1 Greater than 1 Any value 70 / 100In-order traversal of BST gives elements in: Descending order Random order Ascending order Zigzag order 71 / 100What is the time complexity of Insertion Sort in the worst case? O(n log n) O(n²) O(log n) O(n) 72 / 100Bubble Sort is an in-place algorithm. What does that mean? It uses no extra space It modifies original array It creates a new array It requires extra memory 73 / 100Counting Sort is best suited for: Floating-point numbers Large integers Small-range integers Linked lists 74 / 100What is the best-case time complexity of Bubble Sort (optimized)? O(n²) O(n log n) O(n) O(1) 75 / 100What happens when all elements in the array are equal? Worst-case O(n²) Best-case O(n log n) Error occurs Sorting fails 76 / 100What is the topmost node of a tree called? Leaf Root Parent Head 77 / 100What is the time complexity of Bubble Sort in the worst case? O(n) O(log n) O(log n) O(n²) 78 / 100In which direction does Insertion Sort scan the sorted portion? Left to Right Right to Left Random Both 79 / 100What is the best pivot in Quick Sort? First element Middle element Median of the array Last element 80 / 100Which is true about arrays in C? Can grow dynamically Stored in non-contiguous memory Fixed size and contiguous Can store mixed data types 81 / 100What is a tree in data structures? A linear data structure A non-linear data structure A sequential structure None of the above 82 / 100In binary search, how do you calculate the mid index? (low + high) / 2 (low + high) // 2 low * high / 2 (low - high) / 2 83 / 100Which operation inserts an element into the queue? pop push enqueue dequeue 84 / 100What happens if the input range is significantly larger than the number of elements? Space is wasted It works faster It uses recursion Sorting fails 85 / 100How many passes are required to fully sort an array of size n using Selection Sort? n n-1 n/2 log n 86 / 100Which operation is used to remove the top element of the stack? insert push pop delete 87 / 100Which is safer to calculate mid index to avoid overflow? mid = (low + high)/2 mid = low + (high - low)/2 mid =low -(high + low)/2 mid = (low - high)/2 88 / 100What is the worst-case time complexity of linear search? O(log n) O(1) O(n) O(n log n) 89 / 100What will be the best-case time complexity of linear search? O(n) O(n log n) O(1) O(log n) 90 / 100If a stack is empty and we call pop(), what happens? Returns 0 Underflow error Overflow Returns NULL 91 / 100Insertion Sort is best suited for: Large datasets Randomly ordered data Almost sorted data None of these 92 / 100Selection Sort repeatedly : Swaps adjacent elements Merges sorted halves Selects the minimum element and places it in correct position Uses divide and conquer 93 / 100Which of the following linked lists doesn’t contain NULL as a next pointer in any node? Singly linked list Doubly linked list Circular linked list None of the above 94 / 100Linear search works on which data type(s)? Only int int and float char and string All of the above 95 / 100Which of the following is true about linear search? Array must be sorted Works only on integers It is faster than binary search It works on both sorted and unsorted arrays 96 / 100What is the time complexity of Merge Sort in all cases (best, average, worst)? O(n log n) O(n²) O(log n) O(n) 97 / 100Which of these conditions is used to stop the binary search loop? low == high key == mid low <= high key != mid 98 / 100What will be the array after the first pass of Bubble Sort on [5, 3, 4, 1]? [3, 4, 1, 5] [1, 3, 4, 5] [5, 3, 4, 1] [3, 5, 1, 4] 99 / 100Which of the following makes Bubble Sort more efficient in best case? Using a flag to stop if no swaps Using recursion Comparing non-adjacent elements Sorting halves separately 100 / 100Which operation removes an element from the queue? pop dequeue insert remove Your score isThe average score is 6% 0% Restart quiz