0% found this document useful (0 votes)
12 views10 pages

Question

The document covers various fundamental concepts in algorithms, including definitions, properties, and applications of algorithms, asymptotic notations, sorting algorithms, divide and conquer techniques, dynamic programming, greedy algorithms, graph algorithms, NP-completeness, and miscellaneous definitions. It includes specific problems and algorithms such as the closest pair problem, insertion sort, merge sort, and the Bellman-Ford algorithm, along with their complexities and methodologies. Additionally, it addresses advanced topics like parallel algorithms and backtracking, providing a comprehensive overview of algorithmic principles and techniques.

Uploaded by

u2104085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views10 pages

Question

The document covers various fundamental concepts in algorithms, including definitions, properties, and applications of algorithms, asymptotic notations, sorting algorithms, divide and conquer techniques, dynamic programming, greedy algorithms, graph algorithms, NP-completeness, and miscellaneous definitions. It includes specific problems and algorithms such as the closest pair problem, insertion sort, merge sort, and the Bellman-Ford algorithm, along with their complexities and methodologies. Additionally, it addresses advanced topics like parallel algorithms and backtracking, providing a comprehensive overview of algorithmic principles and techniques.

Uploaded by

u2104085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

1.

Introduction to Algorithms
1. What do you mean by algorithms? State some application areas of
algorithms.

2. What is the closet pair problem? Write an algorithm to solve the problem
using the divide and conquer paradigm.

3. Distinguish between divide & conquer and dynamic programming tech-


niques.

4. Distinguish between sequential algorithm and parallel algorithm. Use ap-


propriate example.

2. Asymptotic Notations
1. Define algorithm. Write down the properties of good algorithms. Why is
choosing an appropriate data structure for an algorithm important?

2. Define Big O, Omega (Ω), and Theta (Θ) asymptotic notations.

3. Define o (little-oh), Ω (BIG Omega), and Θ (BIG theta) notations. Why


do we need them?

4. Check whether the following are correct or not:


• n² = O(n³) where c is a constant

• 2n² + 5n = O(n²)

• 2n² log = O(n²)

• 2n² + 5n² = Ω(n²)

• n² × log n = O(n²)

5. Check whether the following are correct or not:


• n² / log n = O(n²)

• n³ + 10n² = O(n²)

• 33n² + 4n³ = Ω(n³)

• n × 2� = O(3�)

• n² × log n = O(n × 2�)

1
6. Prove that any comparison sort algorithm requires Ω(n log n) comparisons
in the worst case.

7. Define time–space tradeoff.

8. Let T(n) = ½n³ + 3n. Which of the following statements are true?
(i) T(n)=O(n), (ii) T(n)=Θ(n³), (iii) T(n)=O(n³), (iv) T(n)=Ω(n³).

9. What do you mean by space complexity of an algorithm?

3. Sorting Algorithms
1. Write a short note on the Brute force technique.

2. The pseudocode for the INSERTION-SORT algorithm is given. Find out


the time complexity (line-by-line analysis). Show best case, worst case,
and average case.

3. Write the pseudocode for the Insertion sort algorithm with examples.
State best, worst, and average time complexities.

4. Write down the parallel version of the merge sort algorithm.

5. Write an algorithm to delete an element x from a binary search tree t.


What is the time complexity of this algorithm?

6. Write down the pseudocode of bucket sort and prove that the time
complexity is linear.

7. Show the average-case time complexity for quick sort using the recursion
tree method.

8. Calculate the average and best-case complexities of quick sort using the
recursion method.

9. What is topological sorting? Write down the intuition to find the


topological sorting of a directed acyclic graph (DAG) using DFS.

10. Explain various graph representation techniques with their advantages


and disadvantages.

11. DACS (Directed Acyclic Circuits/Graphs) inherently have a topological


sort order. Justify this with an example.

2
12. A sorting method is said to be stable if identical elements remain in the
same order as in the original set. Is merge sort a stable sorting method?

4. Divide and Conquer


1. What do you mean by the optimal substructure property in the divide
and conquer approach?

2. Write down the pseudocode for the merge sort algorithm using divide
and conquer. Calculate its time complexity using the substitution method.

3. Explain the Master Theorem to find complexity of a recurrence. Then,


for each, apply it:
• T(n) = 3T(n/3) + n²

• T(n) = 4T(n/2) + n

• T(n) = 16T(n/4) + n²

• T(n) = 2T(n/2) + n log n

4. Write the merits and demerits of the substitution method and the Master
Theorem.

5. Solve the following recurrence relation using the recursion-tree method.

6. Write the pseudocode for the binary search algorithm and establish its
recurrence relation.

7. Let S be a sequence (not necessarily sorted) of n keys. A key k in S is an


approximate median if at least n/4 of the keys are � k and at least n/4 of
the keys are � k. Devise an O(n) time algorithm to find the approximate
median of S.

5. Dynamic Programming
1. What properties suggest that a problem can be solved using Dynamic
Programming?

2. Define the Subset Sum problem (SSS). Write the recursive formula.
Construct a DP table and track elements for a given input set and target

3
sum.

3. Can we solve any recursive problem using the DP technique? If not,


explain the conditions a problem must fulfill to be solvable via DP.

4. Find the longest common subsequence from the given two sequences of
characters.

6. Greedy Algorithms
1. You are given a list of activities with start and finish times. Apply
a greedy approach to select the maximum number of non-overlapping
activities.

2. A thief enters a shop with a backpack capacity of 6 kg. Four products (with
weight and profit) are given. The thief uses a greedy approach based on
profit-per-kg to maximize profit.

3. If each product is indivisible (e.g., electronics), can a greedy approach


still be used? Apply an appropriate algorithm to calculate maximum
profit.

4. Prove the greedy-choice property for the Fractional Knapsack problem.

5. There are N children in a line, each with a “rating.” You must give candies
such that:
• Each child gets at least one candy.

• A child with a higher rating gets more candies than neighbors.

4
• What is the minimum number of candies needed?

6. Apply the rod-cutting algorithm to compute the maximum obtainable


value for rods of lengths 2, 4, and 6, given a price table.

7. Suppose a greedy algorithm is applied for the above candy or rod-cutting


scenario. Two input-output sets are provided for convenience.

8. Given several jobs with deadlines and profits:

1. Write the optimal schedule that yields maximum profit.

2. Are all jobs completed in the optimal schedule?

3. What is the maximum earned profit?

9. Define the following terms with respect to optimization problems:


• Feasible solution

• Optimal solution

• Greedy choice property

7. Graph Algorithms
1. What is a spanning tree of a graph? Write Kruskal’s algorithm to find
a minimum spanning tree (MST) of a weighted graph. Analyze time
complexity with appropriate data structures.

2. Find an MST of the graph in Figure 5(c) using Prim’s algorithm.

5
3. Suppose you need to store a sparse graph in memory. Which data
structure is best? Explain with pros and cons.

4. What is the difference between BFS and DFS? Write the pseudocode for
DFS and trace it completely.

5. Explain the intuition behind the Bellman–Ford algorithm. How do you


detect a negative cycle?

6. Write the pseudocode of Dijkstra’s algorithm for the single-source shortest


path (SSSP). Prove its correctness and analyze time complexity. What if
a Binary Heap is used instead of a binary heap?

7. Apply the Ford–Fulkerson method to compute the maximum flow in


Figure 8(a).

6
8. Run either Kruskal’s or Prim’s MST algorithm on the graph in Fig. 7(b).
If needed, start from vertex A. Write down the pseudo code and label
edges 1,2,3… as they are chosen.

9. Write the algorithm for finding an m-coloring of a graph. Draw the


state-space tree for m=3 and n=3.

10. Differentiate between Dijkstra’s and Bellman–Ford SSSP algorithms.


Explain their runtime complexities.

11. Find the shortest path from node S in the graph of Fig. 6(c) using
Bellman–Ford. Derive the result up to i=3 edges.

7
12. How many ways are there to represent a graph? Describe them with
pros and cons. Why are stack and queue appropriate for DFS and BFS,
respectively? Why is BFS time O(V + E)?

13. How is topological sort performed? How can it be implemented via DFS?
Show that its running time is O(m + n), where m is the number of edges
and n is the number of vertices.

14. Illustrate the differences between Prim’s and Kruskal’s MST approaches
with an example.

8. NP-Completeness
1. Briefly discuss the relationship among P, NP, NP-complete, and NP-hard
problems.

2. What are parallel algorithms? Why did the concept of parallel algorithms
evolve? Write the parallel version of merge sort.

3. Make an analogy among NP-hard, NP-complete, and NP classes of


problems.

4. Prove that P = NP. Explain and prove Cook’s Theorem.

5. Prove that P = NP? Explain and prove Cook’s Theorem. (Duplicate or


variant)

6. Can we solve any recursive problems using DP? If not, explain the con-
ditions for using DP. (Appears here again, but also under Dynamic Pro-

8
gramming.)

9. Miscellaneous Definitions
1. Define the following with necessary details:
• Poset

• Lattice

• Bipartite graph

• Sandwiching theorem

• Multigraph

• Complete graph

2. Define the following terms:


• Degree of a graph

• Complete graph

• Bipartite graph

• Euler path

• Hamiltonian cycle

3. What is a bloom filter and its supported operations? Give a heuristic


analysis to show the false positive probability can be kept minimal.

4. What is amortized cost? Show three different ways of computing


amortized cost. What is a negative cycle in a digraph?

5. Write short notes on:


• Load factor

• Uniform hashing

• Double hashing

6. What are the invariants of a Red-Black tree? Prove that every red-black
tree with n nodes has height � 2 log(n+1).

9
10. Unclassified / Backtracking / Other
1. Find all possible solutions for the 4×4 chessboard and the 4-queens
problem. (Backtracking)

2. Identify the statement “Ternary search is much better than linear and
binary search.”

3. What is a backtracking algorithm? Write down the general backtracking


algorithm with possible optimizations.

4. Define the following:


• diagraph

• digraph (possible typo/variant of “directed graph”)

• Bipartite Graph

• Walk in a graph

10

You might also like