Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 6 MCQs Searching techniques

CSE329 — Prelude To Competitive Coding 60 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 60 answered 0 right 0 wrong , 60 left

  1. Question 1 of 60 Iterative and recursive binary search Easy

    What is the time complexity of binary search on a sorted array of elements?

  2. Question 2 of 60 Iterative and recursive binary search Easy

    Binary search requires the input array to be:

  3. Question 3 of 60 Iterative and recursive binary search Easy

    In binary search, how is the middle index typically computed to avoid integer overflow for indices and ?

  4. Question 4 of 60 Jump search Easy

    For an array of size , what is the optimal block (jump) size used in jump search?

  5. Question 5 of 60 Jump search Easy

    Like binary search, jump search requires the array to be:

  6. Question 6 of 60 Sublist search Easy

    What does sublist search (list matching) determine?

  7. Question 7 of 60 Find the missing number Easy

    For an array containing distinct numbers from to , which formula gives the missing number using the sum approach?

  8. Question 8 of 60 Find the missing number Easy

    Which bitwise operation is commonly used to find a single missing number without risk of overflow?

  9. Question 9 of 60 Search an element in a sorted and rotated array Easy

    What is the time complexity of searching an element in a sorted and rotated array using modified binary search?

  10. Question 10 of 60 Search an element in a sorted and rotated array Easy

    In a sorted and rotated array, at each step of modified binary search we first check:

  11. Question 11 of 60 Recursive function to perform substring search Easy

    What does a substring search function return when the pattern is found in the text?

  12. Question 12 of 60 Recursive function to perform substring search Easy

    In a naive recursive substring search, what happens at each recursive call?

  13. Question 13 of 60 Find the K most frequent words from a string Easy

    Which data structure is most suitable for counting how many times each word appears in a string?

  14. Question 14 of 60 Find the K most frequent words from a string Easy

    When two words have the same frequency, they are often ordered by:

  15. Question 15 of 60 Find a pair with a given difference Easy

    For finding a pair with a given difference in a sorted array, which technique gives an efficient solution?

  16. Question 16 of 60 Find a pair with a given difference Easy

    To find a pair with difference , if we fix an element , which value do we search for?

  17. Question 17 of 60 Find a peak element Easy

    A peak element in an array is one that is:

  18. Question 18 of 60 Find a peak element Easy

    What is the time complexity of finding a peak element using binary search?

  19. Question 19 of 60 Length of longest subarray having sum in given range l r Easy

    Which technique is commonly combined with prefix sums to efficiently handle subarray sum range problems?

  20. Question 20 of 60 Print all subarrays with sum in a given range Easy

    The naive brute-force method to print all subarrays with sum in a range has what time complexity?

  21. Question 21 of 60 Iterative and recursive binary search Medium

    In an iterative binary search, the mid index is computed as mid = low + (high - low) / 2 instead of mid = (low + high) / 2. What is the primary reason for this choice?

  22. Question 22 of 60 Iterative and recursive binary search Medium

    A recursive binary search is called on a sorted array of elements. In the worst case, how many recursive calls (including the initial call) are made before termination?

  23. Question 23 of 60 Jump search Medium

    For a sorted array of elements, what block (jump) size minimizes the worst-case number of comparisons in jump search?

  24. Question 24 of 60 Jump search Medium

    Jump search is being applied to an array of 100 sorted elements using the optimal block size. Approximately how many total comparisons does it need in the worst case?

  25. Question 25 of 60 Sublist search Medium

    Sublist search checks whether a linked list of nodes appears as a contiguous sublist within a larger linked list of nodes. What is its worst-case time complexity using the naive approach?

  26. Question 26 of 60 Find the missing number Medium

    An array contains distinct numbers taken from the range to . Using the sum formula, which expression correctly gives the missing number?

  27. Question 27 of 60 Find the missing number Medium

    Which technique finds the single missing number in a range to without risking overflow from summation and works in time?

  28. Question 28 of 60 Search an element in a sorted and rotated array Medium

    In a sorted and rotated array with no duplicates, after computing mid, how do you decide which half to search in modified binary search?

  29. Question 29 of 60 Search an element in a sorted and rotated array Medium

    Consider the rotated array [6, 7, 8, 1, 2, 3, 4, 5]. When searching for 3, the first mid (index 3, value 1) is examined. Which half is identified as sorted?

  30. Question 30 of 60 Recursive function to perform substring search Medium

    A recursive substring search checks if pattern P occurs in text T starting at each index. What is the base case that returns success?

  31. Question 31 of 60 Find the K most frequent words from a string Medium

    To find the most frequent words in a string, a min-heap of size is maintained over word frequencies. What is the overall time complexity if there are distinct words?

  32. Question 32 of 60 Find the K most frequent words from a string Medium

    When two words have the same frequency in the "K most frequent words" problem, the standard tie-breaking rule ranks them by which criterion?

  33. Question 33 of 60 Find a pair with a given difference Medium

    Given a sorted array, the two-pointer method finds a pair with difference . When arr[j] - arr[i] > d, what action is taken?

  34. Question 34 of 60 Find a pair with a given difference Medium

    For an unsorted array, which approach finds a pair with a given difference in average time using extra space?

  35. Question 35 of 60 Find a peak element Medium

    A peak element is one that is not smaller than its neighbors. Using binary search, if arr[mid] < arr[mid+1], where is a peak guaranteed to exist?

  36. Question 36 of 60 Find a peak element Medium

    What is the time complexity of finding a peak element in an unsorted array using the binary search approach?

  37. Question 37 of 60 Length of longest subarray having sum in given range l r Medium

    To find the longest subarray whose sum lies in , prefix sums are used. For a fixed right index with prefix sum , the subarray sum condition becomes which inequality on an earlier prefix ?

  38. Question 38 of 60 Print all subarrays with sum in a given range Medium

    For an array of all positive integers, why does the sliding-window technique work to enumerate subarrays with sum in a range?

  39. Question 39 of 60 Minimum time required to produce m items Medium

    Machines produce items at fixed rates. To find the minimum time to make items, binary search is applied on the answer (time ). What is checked for a candidate time ?

  40. Question 40 of 60 Minimum time required to produce m items Medium

    If the slowest machine takes max_rate minutes per item and there are machines producing items, what is a valid upper bound for the binary search on time?

  41. Question 41 of 60 Iterative and recursive binary search Hard

    In a binary search implementation, using mid = (low + high) / 2 can cause a bug for very large arrays. Why does mid = low + (high - low) / 2 fix this?

  42. Question 42 of 60 Iterative and recursive binary search Hard

    A recursive binary search is written with base case if (low > high) return -1. If instead a programmer writes if (low >= high) return -1, what is the consequence?

  43. Question 43 of 60 Jump search Hard

    For a sorted array of size , jump search uses a block size of . What block size minimizes the worst-case number of comparisons, and what is that optimal complexity?

  44. Question 44 of 60 Jump search Hard

    Why is jump search generally preferred over binary search on systems where jumping backward is far costlier than jumping forward (e.g., certain tape/streaming media)?

  45. Question 45 of 60 Sublist search Hard

    Sublist search checks whether a linked list S appears as a contiguous sublist of list L. What is the worst-case time complexity of the straightforward approach for lengths and ?

  46. Question 46 of 60 Sublist search Hard

    During sublist search, a partial match fails after matching nodes of the pattern. In the naive algorithm, from which node of the main list does the next matching attempt begin?

  47. Question 47 of 60 Find the missing number Hard

    An array contains distinct numbers from the range with exactly one missing. Using XOR to find the missing number, what is XORed together?

  48. Question 48 of 60 Find the missing number Hard

    For finding one missing number in , the sum formula uses . Compared to the XOR method, what is the main practical drawback of the sum approach?

  49. Question 49 of 60 Search an element in a sorted and rotated array Hard

    In a sorted rotated array with no duplicates, at each step of the modified binary search you compute mid. How do you decide which half is normally sorted?

  50. Question 50 of 60 Search an element in a sorted and rotated array Hard

    When a sorted rotated array contains duplicates, why can the worst-case time complexity of the search degrade to ?

  51. Question 51 of 60 Recursive function to perform substring search Hard

    A recursive substring search matches pattern P inside text T. The base cases are: pattern exhausted (return true) and text exhausted with pattern remaining (return false). What recursive relation correctly continues a match?

  52. Question 52 of 60 Recursive function to perform substring search Hard

    For a recursive naive substring search over text of length and pattern of length , what is the worst-case time complexity, and which inputs trigger it?

  53. Question 53 of 60 Find the K most frequent words from a string Hard

    To find the most frequent words (ties broken by lexicographic order) from a string with distinct words, using a min-heap of size , what is the time complexity?

  54. Question 54 of 60 Find the K most frequent words from a string Hard

    When using a min-heap to keep the top- frequent words, the comparator must order words so the least desirable candidate sits at the root for eviction. For equal frequencies, how should the comparator rank words?

  55. Question 55 of 60 Find a pair with a given difference Hard

    Given a sorted array, to find a pair with difference using two pointers i and j, how are the pointers advanced?

  56. Question 56 of 60 Find a pair with a given difference Hard

    For an unsorted array, a hash-set method finds a pair with difference by checking, for each element , whether or was seen. What subtle case must be handled when ?

  57. Question 57 of 60 Find a peak element Hard

    In an array where arr[i] != arr[i+1] for all i, a peak is an element not smaller than its neighbors. Binary search finds a peak in . Which decision rule is correct at index mid?

  58. Question 58 of 60 Find a peak element Hard

    Why does the peak-finding binary search always guarantee a peak exists in the chosen half, even without global sorting?

  59. Question 59 of 60 Length of longest subarray having sum in given range l r Hard

    For an array with negative numbers, why does the simple sliding-window (two-pointer) technique fail to find the longest subarray with sum in range ?

  60. Question 60 of 60 Minimum time required to produce m items Hard

    Given machines where machine produces one item every minutes, binary search on time finds the minimum to make items. What monotonic predicate is searched?

That's unit 6

Answer a few questions and your score shows up here.