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