Algorithms

Last Updated : 15 Feb, 2023

Learn more about Algorithms in DSA Self Paced Course
Practice Problems on all Algorithms
Recent articles on Algorithms

What is an Algorithm?

The word Algorithm means ” A  set of rules to be followed in calculations or other problem-solving operations ” Or ” A procedure for solving a mathematical problem in a finite number of steps that frequently by recursive operations “. 

Therefore Algorithm refers to a sequence of finite steps to solve a particular problem.

Algorithms can be simple and complex depending on what you want to achieve.

What is Algorithm?

Types of Algorithms:

There are several types of algorithms available. Some important algorithms are:

1. Brute Force Algorithm: It is the simplest approach for a problem. A brute force algorithm is the first approach that comes to finding when we see a problem.

2. Recursive Algorithm: A recursive algorithm is based on recursion. In this case, a problem is broken into several sub-parts and called the same function again and again.

3. Backtracking Algorithm: The backtracking algorithm basically builds the solution by searching among all possible solutions. Using this algorithm, we keep on building the solution following criteria. Whenever a solution fails we trace back to the failure point and build on the next solution and continue this process till we find the solution or all possible solutions are looked after.

4. Searching Algorithm: Searching algorithms are the ones that are used for searching elements or groups of elements from a particular data structure. They can be of different types based on their approach or the data structure in which the element should be found.

5. Sorting Algorithm: Sorting is arranging a group of data in a particular manner according to the requirement. The algorithms which help in performing this function are called sorting algorithms. Generally sorting algorithms are used to sort groups of data in an increasing or decreasing manner.

6. Hashing Algorithm: Hashing algorithms work similarly to the searching algorithm. But they contain an index with a key ID. In hashing, a key is assigned to specific data.

7. Divide and Conquer Algorithm: This algorithm breaks a problem into sub-problems, solves a single sub-problem and merges the solutions together to get the final solution. It consists of the following three steps:

  • Divide
  • Solve
  • Combine

8. Greedy Algorithm: In this type of algorithm the solution is built part by part. The solution of the next part is built based on the immediate benefit of the next part. The one solution giving the most benefit will be chosen as the solution for the next part.

9. Dynamic Programming Algorithm: This algorithm uses the concept of using the already found solution to avoid repetitive calculation of the same part of the problem. It divides the problem into smaller overlapping subproblems and solves them.

10. Randomized Algorithm: In the randomized algorithm we use a random number so it gives immediate benefit. The random number helps in deciding the expected outcome.

Topics:

Analysis of Algorithms:

  1. Asymptotic Analysis
  2. Worst, Average and Best Cases
  3. Asymptotic Notations
  4. Lower and Upper Bound Theory
  5. Introduction to Amortized Analysis
  6. What does ‘Space Complexity’ mean?
  7. Polynomial Time Approximation Scheme
  8. Accounting Method | Amortized Analysis
  9. Potential Method in Amortized Analysis

Searching and Sorting:

  1. Introduction to Searching Algorithms
  2. Introduction to Sorting Algorithm
  3. Stable and Unstable Sorting Algorithms
  4. Lower bound for comparison based sorting algorithms
  5. Can Run Time Complexity of a comparison-based sorting algorithm be less than N logN?
  6. Which sorting algorithm makes minimum number of memory writes?

Greedy Algorithms:

  1. Introduction to Greedy Algorithms
  2. Activity Selection Problem
  3. Huffman Coding
  4. Job Sequencing Problem
  5. Quiz on Greedy Algorithms
  6. Minimum Number of Platforms Required for a Railway/Bus Station

Dynamic Programming:

  1. Introduction to Dynamic Programming
  2. Overlapping Subproblems Property
  3. Optimal Substructure Property
  4. Longest Increasing Subsequence
  5. Longest Common Subsequence
  6. Min Cost Path
  7. Coin Change
  8. Matrix Chain Multiplication
  9. 0-1 Knapsack Problem
  10. Longest Palindromic Subsequence
  11. Palindrome Partitioning

Pattern Searching:

  1. Introduction to Pattern Searching
  2. Naive Pattern Searching
  3. KMP Algorithm
  4. Rabin-Karp Algorithm
  5. Pattern Searching using a Trie of all Suffixes
  6. Aho-Corasick Algorithm for Pattern Searching
  7. Z algorithm (Linear time pattern searching Algorithm)

Backtracking:

  1. Introduction to Backtracking
  2. Print all permutations of a given string
  3. The Knight’s tour problem
  4. Rat in a Maze
  5. N Queen Problem
  6. Subset Sum
  7. m Coloring Problem
  8. Hamiltonian Cycle
  9. Sudoku

Divide and Conquer:

  1. Introduction to Divide and Conquer
  2. Merge Sort
  3. Write your own pow(x, n) to calculate x*n
  4. Count Inversions
  5. Closest Pair of Points
  6. Strassen’s Matrix Multiplication

Geometric Algorithm:

  1. Introduction to Geometric Algorithms
  2. Closest Pair of Points | O(nlogn) Implementation
  3. How to check if a given point lies inside or outside a polygon?
  4. How to check if two given line segments intersect?
  5. Given n line segments, find if any two segments intersect
  6. How to check if given four points form a square
  7. Convex Hull using Jarvis’ Algorithm or Wrapping

Mathematical Algorithms:

  1. Introduction to Mathematical Algorithms
  2. Write an Efficient Method to Check if a Number is Multiple of 3
  3. Write a program to add two numbers in base 14
  4. Program for Fibonacci numbers
  5. Average of a stream of numbers
  6. Multiply two integers without using multiplication, division and bitwise operators, and no loops
  7. Babylonian method for square root
  8. Sieve of Eratosthenes
  9. Pascal’s Triangle
  10. Given a number, find the next smallest palindrome
  11. Program to add two polynomials
  12. Multiply two polynomials
  13. Count trailing zeroes in factorial of a number

Bitwise Algorithms:

  1. Introduction to Bitwise Algorithms
  2. Little and Big Endian
  3. Detect opposite signs
  4. Swap bits
  5. Turn off the rightmost set bit
  6. Rotate bits
  7. Next higher number with same number of set bits
  8. Swap two nibbles in a byte

Graph Algorithms:

  1. Introduction to Graph Algorithms
  2. BFS, DFS
  3. Cycles in Graph
  4. Shortest paths
  5. MST
  6. Topological Sorting
  7. Connectivity
  8. Max Flow

Randomized Algorithms:

  1. Introduction to Randomized Algorithms
  2. Linearity of Expectation
  3. Expected Number of Trials until Success
  4. Randomized Algorithms | Set 0 (Mathematical Background)
  5. Randomized Algorithms | Set 1 (Introduction and Analysis)
  6. Randomized Algorithms | Set 2 (Classification and Applications)
  7. Randomized Algorithms | Set 3 (1/2 Approximate Median)
  8. Reservoir Sampling

Branch and Bound:

  1. Branch and Bound | Set 1 (Introduction with 0/1 Knapsack)
  2. Branch and Bound | Set 2 (Implementation of 0/1 Knapsack)
  3. Branch and Bound | Set 3 (8 puzzle Problem)
  4. Branch And Bound | Set 4 (Job Assignment Problem)
  5. Branch and Bound | Set 5 (N Queen Problem)
  6. Branch And Bound | Set 6 (Traveling Salesman Problem)

Quizzes:

Please see Data Structures and Advanced Data Structures for Graph, Binary Tree, BST and Linked List based algorithms.


My Personal Notes arrow_drop_up

Share your thoughts in the comments

Similar Reads

LMNs- Algorithms
LMNs- Algorithms Analyze an algorithm 1) Worst Case Analysis (Usually Done):In the worst case analysis, we calculate upper bound on running time of an algorithm by considering worst case  (a situation where algorithm takes maximum time) 2) Average Case Analysis (Sometimes done) :In average case analysis, we take all possible inputs and calculate co
8 min read
Bitwise Algorithms | Intermediate
Swap bits in a given number Little and Big Endian Mystery Smallest of three integers without comparison operators A Boolean Array Puzzle Compute the integer absolute value (abs) without branching Compute the minimum or maximum of two integers without branching Find the two non-repeating elements in an array of repeating elements Write an Efficient
7 min read
Bitwise Algorithms | Basic
Find the element that appears once Detect if two integers have opposite signs Add 1 to a given number Multiply a given Integer with 3.5 Turn off the rightmost set bit Find whether a given number is a power of 4 or not Compute modulus division by a power-of-2-number Rotate bits of a number Find the Number Occurring Odd Number of Times Check for Inte
5 min read
Mathematical Algorithms | Number Digits
Recent Articles on Number Digits ! Automorphic Number Self Descriptive Number Motzkin number Narcissistic number Schröder–Hipparchus number Number of n digit stepping numbers Deserium Number K’th Boom Number Pandigital Product Neon Number Harshad (Or Niven) Number Tidy Number (Digits in non-decreasing Order) Seeds (Or Seed Roots) of a number Number
7 min read
Mathematical Algorithms | Divisibility and Large Numbers
Recent Articles on Divisibility ! Recent Articles on Large Numbers ! Check if a large number is divisible by 3 or not Number of digits to be removed to make a number divisible by 3 Find whether a given integer is a power of 3 or not Check if a large number is divisible by 4 or not Count rotations divisible by 4 Number of substrings divisible by 4 i
4 min read
Mathematical Algorithms | Prime Factorization and Divisors
Divisors: Mathematically, divisor is defined as a number that divides another number completely or with a remainder. For example: Consider 6 / 3. Here 3 divides 6 completely. Also, consider 8 /3. Here 3 does not divide 8 completely. But in both cases, 3 is the divisor. Prime Factorization: Prime factorization is a very common topic of mathematics a
3 min read
Mathematical Algorithms | Prime numbers and Primality Tests
What is Prime Number? A prime number is a natural number greater than 1 that is divisible by only 1 and the number itself. In other words, the prime number can be defined as a positive integer greater than that has exactly two factors, 1 and the number itself. First 10 prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. Note: 1 is neither a prime
3 min read
Mathematical Algorithms | GCD & LCM
Greatest Common Divisor (GCD): The GCD of two numbers is defined as the largest integer that divides both integers without any remainder. It is also termed as the HCF (Highest Common Factor). GCD of an array is the integer that divides all the elements of the array without leaving any remainder. GCD of two numbers may be calculated using the follow
3 min read
Mathematical Algorithms | Sequence & Series
What is Sequence? A sequence is an arrangement of a set of numbers in a particular order defined by some rule. If a1, a2, a3 . . . is a sequence then 1, 2, 3 denotes the position of the elements in the sequence. A sequence can be finite or infinite. Some well-known sequences are: Arithmetic Sequence Geometric Seqeunce Harmonic Sequence Fibonacci Se
4 min read
Topic wise Quizes on Algorithms
Data Structures and Algorithms (DSA) MCQ Quiz Online Quiz on Data Structures | DSA MCQs Quiz on Algorithms | DSA MCQs Topic DSA Quiz Link SearchingTop MCQs on Searching Algorithm with AnswersTop MCQs on Binary Search Algorithm with AnswersSortingTop MCQs on QuickSort Algorithm with AnswersTop MCQs on SelectionSort Algorithm with AnswersTop MCQs on
2 min read