Lecture -3 Study Notes
Lecture -3 Study Notes
Introduction to Algorithms
An algorithm is a step-by-step procedure or formula for solving a problem. It consists of well-defined instructions that
take an input, process it, and produce an output.
Characteristics of an Algorithm:
1. Divide and Conquer: Breaking a problem into subproblems (e.g., Merge Sort, Quick Sort).
2. Dynamic Programming: Solving overlapping subproblems using memoization (e.g., Fibonacci, Knapsack
problem).
3. Greedy Algorithms: Making locally optimal choices (e.g., Kruskal’s Algorithm, Dijkstra’s Algorithm).
4. Backtracking: Searching for a solution by exploring possibilities recursively (e.g., N-Queens problem, Sudoku
Solver).
5. Brute Force: Trying all possible solutions (e.g., String Matching, Traveling Salesman Problem).
Efficiency of an Algorithm
The efficiency of an algorithm is measured by the resources it requires for execution, primarily time complexity and
space complexity.
1. Time Complexity
Time complexity measures the number of operations an algorithm performs as a function of input size n.
Asymptotic Notations:
Space complexity refers to the amount of memory required by an algorithm, including input storage and auxiliary storage.
1. Time vs. Space Trade-off: Reducing time complexity may increase space usage and vice versa.
2. Exact vs. Approximate Solutions: Some problems are too complex to solve exactly, requiring approximate
algorithms (e.g., heuristic search in AI).