Unit 5: Transform-and-Conquer and Advanced Algorithmic Techniques - Subjective Questions

CSE408 — Design And Analysis Of Algorithms • Practice Questions with Detailed Answers

20 questions

1

Define a balanced search tree. Why is balancing necessary in a binary search tree?

2

Explain the balance condition of an AVL tree and describe the four rotations used to restore balance after insertion.

3

Compare AVL trees and red-black trees with respect to balancing rules, operation costs, and practical applications.

4

Describe how insertion and deletion are performed in a balanced search tree. Derive their worst-case time complexities.

5

Explain the working of counting sort with a suitable example. State its time and space complexities.

6

Why is counting sort considered a stable non-comparison sort? Explain the role of cumulative counts and reverse traversal.

7

Describe least-significant-digit radix sort and trace it for the keys .

8

Distinguish between most-significant-digit radix sort and least-significant-digit radix sort. Why must the digit sort in LSD radix sort be stable?

9

Explain the steps of bucket sort and derive its expected running time under a uniform-distribution assumption.

10

Compare counting sort, radix sort, and bucket sort in terms of assumptions, stability, complexity, and suitable input.

11

Define a monotonic stack. Explain how it can be used to find the next greater element for every element of an array.

12

Describe how a monotonic stack solves the largest rectangle in a histogram problem. Justify the running time.

13

Explain the role of monotonic stacks in finding previous smaller and next smaller elements. How are these boundaries useful in range problems?

14

Define a monotonic queue and explain how it differs from an ordinary queue and a monotonic stack.

15

Develop the monotonic-queue algorithm for finding the maximum of every sliding window of size . Trace it for with .

16

Explain how a monotonic queue can optimize dynamic programming recurrences involving a sliding-window minimum.

17

Explain the two-pointers technique and describe its main variants with suitable use cases.

18

Design a two-pointers algorithm to determine whether a sorted array contains two elements whose sum equals a target . Prove its correctness and analyze its complexity.

19

Describe how sliding-window two pointers find the minimum-length subarray with sum at least when all array elements are positive.

20

Compare the two-pointers technique, monotonic stack, and monotonic queue. Explain how the invariant maintained by each technique determines its applications.