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