Independent Preparation Bank for Pakistani Computing Graduates • 100% Free • No Signup
NSCTPrep.
Data Structures & AlgorithmsTopic #3 of 540 MCQs Available

Searching Algorithms

Comprehensive question bank, step-by-step rationales, and dedicated timed quiz for Searching Algorithms.

Launch Quiz Mode ↗

Searching Algorithms Question Bank

Showing 40 questions of 40 with verified answers

6Multiple Choice

(Comparison) Why is Merge Sort preferred for sorting Linked Lists over Quick Sort?

7Multiple Choice

(Conceptual) Which sorting algorithm is Adaptive (meaning it becomes O(N) for nearly-sorted data)?

8Multiple Choice

(Debugging) A developer chooses Selection Sort because it has a low number of swaps. What is the major drawback of this algorithm?

9Multiple Choice

(Calculation) How many comparisons does Insertion Sort perform in the **Best Case** (already sorted array of size N)?

10Multiple Choice

(Conceptual) Which sorting algorithm utilizes a **Max-Heap** data structure to maintain the unsorted part of the array?

11Multiple Choice

(Comparison) Which of the following O(N \log N) algorithms is **not in-place** (requires O(N) extra space)?

12Multiple Choice

(Scenario-Based) You need an algorithm with a guaranteed O(N \log N) worst- case time complexity and O(1) extra space. Which is the best choice?

13Multiple Choice

(Code-Tracing) In Quick Sort, what is the role of the Partition step?

14Multiple Choice

(Conceptual) Radix Sort sorts numbers by processing individual digits. Which sorting algorithm is typically used as the "stable" subroutine for Radix Sort?

15Multiple Choice

(Scenario-Based) An array has only 3 distinct values (e.g., 0, 1, 2) repeated many times. Which algorithm (Dutch National Flag problem) is most efficient?

16Multiple Choice

(Calculation) What is the time complexity of Heapify (converting an array into a heap)?

17Multiple Choice

(Conceptual) Which sorting algorithm is commonly used as the default sort in many languages (e.g., Python's sort(), Java's Arrays.sort() for objects)?

18Multiple Choice

(Debugging) You implemented Quick Sort, and it works, but it takes a long time for large, already-sorted arrays. How can you fix this?

19Multiple Choice

(Conceptual) Which sorting algorithm is Online (can sort data as it is received from a stream)?

20Multiple Choice

(Comparison) What is the Recurrence Relation for Merge Sort?

1Multiple Choice

(Conceptual) What is the main goal of a Hash Function in a Hash Table?

2Multiple Choice

(Calculation) You have a Hash Table of size 10. Using the hash function h(k) = k mod 10, what is the index for key 1257?

3Multiple Choice

(Conceptual) Which collision resolution technique uses a Linked List at each bucket to handle multiple keys?

4Multiple Choice

(Debugging) A developer notices that a HashMap search is becoming very slow (O(N)). What is the most likely cause?

5Multiple Choice

(Conceptual) In Open Addressing, what is Linear Probing?

6Multiple Choice

(Scenario-Based) A system needs to handle a Load Factor of 2.0. Which collision resolution strategy is the only one that can handle this?

7Multiple Choice

(Conceptual) What is Primary Clustering in Hash Tables?

8Multiple Choice

(Comparison) What is the main advantage of Double Hashing over Linear Probing?

9Multiple Choice

(Conceptual) Why is it recommended to use a **Prime Number** for the size of a Hash Table?

10Multiple Choice

(Scenario-Based) You are using Open Addressing. You delete an element at index 5. Why shouldn't you just set table[5] = NULL?

11Multiple Choice

(Calculation) If a Hash Table has 100 slots and contains 70 items, what is its Load Factor?

12Multiple Choice

(Conceptual) What is Rehashing?

13Multiple Choice

(Comparison) Compare the Space Complexity of Chaining vs. Open Addressing.

14Multiple Choice

(Conceptual) In Quadratic Probing, if the initial hash is h, the sequence of probes is:

15Multiple Choice

(Scenario-Based) Which of the following is a "Cryptographic" hash function requirement, but NOT necessarily required for a standard Hash Table?

1Multiple Choice

(Conceptual) What is the primary characteristic that differentiates a Binary Search Tree (BST) from a regular Binary Tree?

2Multiple Choice

(Calculation) What is the maximum number of nodes in a Perfect Binary Tree with a height of 4? (Assume root is at height 0).

3Multiple Choice

(Code-Tracing) Given a BST, which traversal method will visit the nodes in ascending sorted order?

4Multiple Choice

(Scenario-Based) You are inserting the following numbers into an empty BST in this order: 10, 5, 15, 7, 12. What is the Right Child of the node with value 10?

5Multiple Choice

(Conceptual) What is the Balance Factor of a node in an AVL Tree?

6Multiple Choice

(Code-Tracing) If the Pre-order traversal of a tree is ABC and the In-order is BAC, what is the Root of the tree?

7Multiple Choice

(Debugging) A BST becomes "Skewed" (like a linked list) when elements are inserted in sorted order. What is the Search Time Complexity in this worst-case skewed BST?

8Multiple Choice

(Scenario-Based) You need to delete a node that has two children from a BST. What is the standard procedure?

9Multiple Choice

(Comparison) What is the primary advantage of an AVL Tree over a standard BST?

29Multiple Choice

In a balanced Red-Black tree with n nodes, what is the maximum possible height?