Unit 6: Searching techniques - Subjective Questions

CSE329 — Prelude To Competitive Coding • Practice Questions with Detailed Answers

20 questions

1

Explain the iterative binary search algorithm. Write its pseudocode and derive its time complexity.

2

Distinguish between iterative and recursive binary search. Provide the recursive implementation and discuss its space complexity.

3

Describe the Jump Search algorithm. Derive the optimal jump (block) size and its time complexity.

4

Explain the Sublist Search (search a linked list in another linked list) technique with an algorithm and its time complexity.

5

Describe at least three methods to find the missing number in an array containing distinct numbers from the range to . Compare their efficiency.

6

Explain how to search an element in a sorted and rotated array in time. Provide the algorithm with an example.

7

Write a recursive function to perform substring search (check if a pattern occurs in a text). Explain its working and time complexity.

8

Explain the approach to find the K most frequent words from a string. Discuss the data structures used and analyze the complexity.

9

Describe how to find a pair with a given difference in an array. Compare the brute-force, sorting, and hashing approaches.

10

Define a peak element and explain the algorithm to find a peak element in an array.

11

Explain the approach to find the length of the longest subarray having sum in a given range . Discuss the complexity.

12

Describe how to print all subarrays with sum in a given range . Provide an algorithm and its complexity.

13

Explain the problem of finding the minimum time required to produce items given machines with different production rates. Show how binary search on the answer is applied.

14

Compare Linear Search, Binary Search, and Jump Search on the basis of prerequisites, time complexity, and use cases.

15

Given the rotated sorted array [7, 8, 9, 1, 2, 3, 4, 5, 6], find the pivot (minimum) element using binary search. Explain each step.

16

Derive the recurrence relation for recursive binary search and solve it using the Master Theorem.

17

Explain how binary search can find the first and last occurrence of a target element in a sorted array with duplicates.

18

A factory has machines with production times [1, 2, 3] and needs to produce items. Compute the minimum time required using the binary search on answer approach, showing each iteration.

19

Explain the concept of "binary search on the answer" as a problem-solving pattern in competitive coding. When is it applicable? Give two example problems.

20

Distinguish between the sliding window and prefix sum techniques for subarray sum problems. When should each be used?