• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
EDUCBA

EDUCBA

MENUMENU
  • Resources
        • Java Tutorials

          • Cheat Sheet Java
          • Cheat Sheet Python
          • C# vs Js
        • Java Tutorials
        • Python Tutorials

          • Angular 5 vs Angular 4
          • Careers in Python
          • Kali Linux vs Ubuntu
        • Python Tutorials
        • Top Differences

          • Cheat Sheet JavaScript
          • Python Interview Questions
          • Cloud Computing or Virtualization
        • Top Differences
        • Others

          • Resources (A-Z)
          • Top Interview Question
          • Programming Languages
          • Web Development Tools
          • HTML CSS Tutorial
          • Technology Basics
          • Technology Careers
          • View All
  • Free Courses
  • All Courses
        • Certification Courses

          Software Development Course 2
        • All in One Bundle

          All-in-One-Software-Development-Bundle
        • Become a Python Developer

          Python-Certification-Training
        • Others

          • Java Course
          • Become a Selenium Automation Tester
          • Become an IoT Developer
          • Ruby on Rails Course
          • Angular JS Certification Training
          • View All
  • 600+ Courses All in One Bundle
  • Login

Types of Algorithms

Home » Software Development » Blog » Software Development Basics » Types of Algorithms

Types-of-Algorithms

Introduction to Algorithms

An Algorithm is a sequence of steps that describe how a problem can be solved. Every computer program that ends with a result is basically based on an Algorithm. Algorithms, however, are not just confined for use in computer programs, these can also be used to solve mathematical problems and on many matters of day-to-day life. Based on how they function, we can divide Algorithms into multiple types. Let’s take a look at some of the important ones.

Types of Algorithm

There are many types of Algorithms but the fundamental types of Algorithms are:

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

types of algorithm

1) Recursive Algorithm

This is one of the most interesting Algorithms as it calls itself with a smaller value as inputs which it gets after solving for the current inputs. In more simpler words, It’s an Algorithm that calls itself repeatedly until the problem is solved.

Problems such as the Tower of Hanoi or DFS of a Graph can be easily solved by using these Algorithms.

For example, here is a code that finds a factorial using a recursion Algorithm:

Fact(y)

If y is 0

return 1

return (y*Fact(y-1))  /* this is where the recursion happens*/

2) Divide and Conquer Algorithm

This is another effective way of solving many problems. In Divide and Conquer algorithms, divide the algorithm into two parts, the first parts divides the problem on hand into smaller subproblems of the same type. Then on the second part, these smaller problems are solved and then added together (combined) to produce the final solution of the problem.

Popular Course in this category
Cyber Week Sale
All in One Software Development Bundle (600+ Courses, 50+ projects) 600+ Online Courses | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (3,144 ratings)
Course Price

View Course

Related Courses
Software Testing Training (11 Courses)Selenium Training Certification (9 Courses, 4+ Projects)Appium Training (2 Courses)JMeter Certification Training (3 Courses)

Merge sorting and quick sorting can be done with divide and conquer algorithms. Here is the pseudocode of the merge sort algorithm to give you an example:

MergeSorting(ar[], l,  r)

If r > l

  1. Find the mid-point to divide the given array into two halves:

middle m = (l+r)/2

  1. Call mergeSorting for the first half:

Call mergeSorting(ar, l, m)

  1. Call mergeSorting for the second half:

Call mergeSorting(ar, m+1, r)

  1. Merge the halves sorted in step 2 and 3:

Call merge(ar, l, m, r)

3) Dynamic Programming Algorithm

These algorithms work by remembering the results of the past run and using them to find new results. In other words, dynamic programming algorithm solves complex problems by breaking it into multiple simple subproblems and then it solves each of them once and then stores them for future use.

Fibonacci sequence is a good example for Dynamic Programming algorithms, you can see it working in the pseudo code:

Fibonacci(N) = 0                                                (for n=0)

= 0                                                                          (for n=1)

= Fibonacci(N-1)+Finacchi(N-2)                      (for n>1)

4) Greedy Algorithm

These algorithms are used for solving optimization problems. In this algorithm, we find a locally optimum solution (without any regard for any consequence in future) and hope to find the optimal solution at the global level.

The method does not guarantee that we will be able to find an optimal solution.

The algorithm has 5 components:

  • The first one is a candidate set from which we try to find a solution.
  • A selection function which helps choose the best possible candidate.
  • A feasibility function which helps in deciding if the candidate can be used to find a solution.
  • An objective function which assigns value to a possible solution or to a partial solution
  • Solution function that tells when we have found a solution to the problem.

Huffman Coding and Dijkstra’s algorithm are two prime examples where Greedy algorithm is used.

In Huffman coding, The algorithm goes through a message and depending on the frequency of the characters in that message, for each character, it assigns a variable length encoding. To do Huffman coding, we first need to build a Huffman tree from the input characters and then traverse through the tree to assign codes to the characters.

5) Brute Force Algorithm

This is one of the simplest algorithms in the concept. A brute force algorithm blindly iterates all possible solutions to search one or more than one solution that may solve a function. Think of brute force as using all possible combinations of numbers to open a safe.

Here is an example of Sequential Search done by using brute force:

Algorithm S_Search (A[0..n], X)

A[n] ← X

i ← 0

While A [i] ≠ X do

i ← i + 1

if  i < n return i

else  return -1

6) Backtracking Algorithm

Backtracking is a technique to find a solution to a problem in an incremental approach. It solves problems recursively and tries to get to a solution to a problem by solving one piece of the problem at a time. If one of the solutions fail, we remove it and backtrack to find another solution.

In other words, a backtracking algorithm solves a subproblem and if it fails to solve the problem, it undoes the last step and starts again to find the solution to the problem.

N Queens problem is one good example to see Backtracking algorithm in action. The N Queen Problem states that there are N pieces of Queens in a chess board and we have to arrange them so that no queen can attack any other queen in the board once organized.

Now let’s take a look at SolveNQ algorithm and Check Valid functions to solve the problem:

CheckValid(Chessboard, row, column)

Start

If there is a Queen at on the left of the current column then return false

If the queen is at upper-left diagonal, then return false

If the queen is at lower-left diagonal, then return false

Return true

End

SolveNQ(Board, Column)

Start

If all columns are full then return true

For each row present in the chess board

Do

If, CheckValid( board, x, column), then

Set the queen at cell (x, column) on the board

If SolveNQ(board, column+1) = True, then return true.

Else, remove the queen from the cell ( x, column) from board

Done

Return false

End

Conclusion – Types of Algorithms

Algorithms are behind most of the impressive things computers can do and these are at the core of most computing tasks. Being better with algorithms will not only help you in being a successful programmer, but you will become more efficient as well.

Recommended Articles

This has been a guide to Types of Algorithms. Here we discuss the Top 6 Important Types of Algorithms with their functions. You can also go through our other suggested articles to learn more –

  1. Introduction To Algorithm
  2. Algorithm in Programming
  3. Algorithm Interview Questions
  4. Factorial in Python | Techniques
  5. Quick Sorting Algorithms in Java
  6. Top 6 Sorting Algorithm in JavaScript

All in One Software Development Course Bundle

600+ Online Courses

3000+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Reader Interactions
Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar
Technology Blog Tutorials
  • Software Development Basics
    • Interoperability Testing
    • Code Coverage
    • Test Plan Template
    • Domain Testing
    • Sanity Testing
    • React Tools
    • What is Switch?
    • Adhoc Testing
    • Equivalence Partitioning
    • Recovery Testing
    • Software Development
    • Black Box Testing Techniques
    • What is XPath?
    • Listeners in TestNG
    • Array vs ArrayList
    • Git Checkout
    • Haskell Alternatives
    • What is Polymorphism?
    • TestNG Annotations
    • Unix File System
    • Shell Script Parameters
    • Software Quality Assurance
    • What is SDET?
    • UML Deployment Diagram
    • Fuzz Testing
    • What is Defect?
    • Automation Testing
    • Static Testing Techniques
    • Install GRUB
    • Spike Testing
    • Exception Handling in VB.NET
    • Unix File Permissions
    • Mutation Testing
    • What is a Bug in Software Testing?
    • Mantis Bug Tracker
    • Compatibility Testing
    • Components of Selenium
    • Overriding in OOPs
    • Iterator in C++
    • Free Web Hosting Sites
    • Interface Testing
    • Dynamic Testing
    • Non Functional Testing
    • Regression Testing Tools
    • Scalability Testing
    • Volume Testing
    • Negative Testing
    • Performance Testing Life Cycle
    • What is XPath in Selenium?
    • What is Test Automation Frameworks?
    • Bootstrap Typography
    • What is Laravel?
    • Hive Built-in Functions
    • Stability Testing
    • Levels of Software Testing
    • Software Testing Life Cycle
    • Types of Domain
    • VB.NET Controls
    • Types of Websites
    • What is Cucumber?
    • Best C Compilers
    • Manual Testing
    • UML Component Diagram
    • What is Stress Testing?
    • What is Debugging?
    • Test Harness
    • Diffie Hellman Key Exchange Algorithm
    • What is Functional Testing?
    • Constructor in C++
    • TFTP
    • What is Web Hosting?
    • Types of Software Testing
    • Benchmark Testing
    • UML Diagram Softwares
    • UML Object Diagram
    • Test Coverage
    • Gantt Chart Software
    • What is FTP?
    • Static Testing
    • Python Frameworks
    • What is Usability Testing?
    • HTTP Cookies
    • RMI Architecture
    • Selenium Architecture
    • Defect Tracking Tools
    • Performance Testing Tools
    • Monolithic Kernel vs MicroKernel
    • Cryptosystems
    • IPv6 Header Format
    • What is Cross Site Scripting?
    • User Datagram Protocol
    • SOA Testing
    • Test Case Design Techniques
    • What is SVN?
    • What is Debian?
    • Bootstrap Components
    • Bootstrap Layout
    • Windows Commands
    • Kotlin Functions
    • DBMS Keys
    • Selenium Grid
    • Selenium Tools
    • List of few Errors In Website
    • Introduction To GIT
    • Internet of Things (IoT) Applications
    • Is Cassandra NoSQL
    • What is OLTP?
    • Introduction To Algorithm
    • What is Juypter Notebook
    • Git Alternatives
    • Introduction To Android
    • GitHub Alternatives
    • Introduction to Windows
    • What is an Algorithm
    • What is Maven
    • What Is Apache
    • What Is SDLC
    • Sharepoint Alternatives
    • Selenium Alternatives
    • What is Selenium
    • What is Shell Scripting
    • What is Mainframe
    • What is Software Development
    • What is Git
    • What is Computer Science
    • Uses Of Powershell
    • What is SSRS
    • What is Application Server
    • What is RMAN Oracle
    • What is Virtual Host
    • What is Desktop Software
    • System Design Interview Questions
    • What Is System Design
    • What Is Design Pattern
    • What is MVC Design Pattern
    • System Analysis And Design
    • Application Software & Types
    • Learn the Art of Mechatronics
    • Myths & Misconceptions Software
    • Solve Problems With Technology
    • Avoid Pitfalls of Shadow
    • Learn to Code For Beginners
    • Software as a Service (Saas)
    • Freelance Web Designer
    • CISA Certification Exam
    • Programming Concepts
    • Defect Life Cycle in Software Testing
    • What is Visual Studio Code
    • Gray Box Testing
    • What is GPS
    • What is WIX
    • Bootstrap 4 Cheat sheet
    • Increase Productivity With New Technology
    • Uses of Salesforce
    • Uses of Selenium
    • Uses Of C#
    • IntelliJ Cheat Sheet
    • What is Spiral Model
    • Monolithic Kernel
    • Uses Of WordPress
    • What is a Greedy Algorithm
    • What is OSPF
    • Is MySQL Programming Language
    • Is Blockchain the Future
    • What is JMS
    • WordPress Work
    • What is Web Application
    • HTML Image Tags
    • Boolean operators in Java
    • What is WebSocket
    • Introduction To PHP
    • Advantages Of Array
    • Python 3 cheat sheet
    • How JavaScript Works
    • Is Blockchain Safe
    • What is PLC
    • What is Threading
    • How Blockchain Works
    • SoapUI Alternatives
    • What is Microcontroller
    • Advantages of PHP
    • PHP Alternatives
    • Ubuntu Alternatives
    • WordPress Alternatives
    • Linux Alternatives
    • What is SOAP
    • Introduction To Computer Network
    • Windows Operators
    • Android Alternatives
    • What is PowerShell
    • What is Elasticsearch
    • Algorithm in Programming
    • JIRA Alternatives
    • Wix Alternatives
    • PowerShell Operators
    • What is Laravel Framework
    • SOA Alternatives
    • Is Ansible free
    • Laravel Commands
    • What is Blockchain Technology
    • What is Bootstrap
    • What is Unix
    • What is Ansible
    • What is Software Testing
    • Windows Alternatives
    • What is Jira Software
    • What is UI Designer
    • What is VBScript
    • What is SoapUI
    • Uses of Ubuntu
    • What is MVC
    • What is ASP.NET
    • What is Multithreading
    • What is ASP.Net Web Services
    • What is TFS
    • What is DBMS
    • What is Embedded Systems
    • Inheritance in VB.Net
    • What is VMware?
    • What is Open-Source License
    • What is Bot
    • What is Open Source
    • What is ETL Testing
    • What is GraphQL
    • cPanel vs Plesk
    • System Software Tools
    • Information Technology Benefits
    • Black Box Testing
    • What is ETL
    • What is IDE
    • Uses of Coding
    • Uses Of Raspberry Pi
    • What is Hypervisor
    • Website Services
    • What is Common Gateway Interface
    • White Box Testing
    • Web Testing Application
    • OS Alternatives
    • Iterative Model
    • What is Unix Shell
    • Automation Testing Tools
    • Integration Testing
    • System Testing
    • Unit Testing
    • Test Automation Framework
    • Alpha and Beta Testing
    • Decision Table Testing
    • Regression Testing
    • Types of Algorithms
    • What is Appium
    • Prototype Model
    • What is CLI
    • Waterfall Model
    • RAD Model
    • Ray Tracing Algorithm
    • OpenGL in Android
    • Types of UML Diagrams
    • Class Diagram
    • What is Assembly Language
    • ASP.NET Page Life Cycle
    • HTTP Caching
    • What is Selenium Web Driver
    • Selenium Framework
    • Selenium Testing
    • Selenium Automation Testing
    • What is Buffer Overflow
    • What is Joomla
    • What is Virtualization
    • What is WCF
    • What is OOP
    • What is SOA
    • What is JDBC
    • What is Clickbait
    • What is GUI
    • What is FreeBSD
    • Software Testing Principles
    • System Integration Testing
    • What is CMD
    • What is VB.Net
    • What is CodeIgniter
    • UML Use Case Diagram
    • What is WordPress
    • UML Activity Diagram
    • What is Coding
    • UNIX ARCHITECTURE
    • Random Forest Algorithm
    • UML Sequence Diagram
    • DOS vs Windows
    • What is SVG
    • What is QTP
    • VB.NET Operators
    • What is MuleSoft
    • What is Exploratory Testing
    • What is Ransomware
    • Sublime Text Alternatives
    • What is Static Routing
    • Kotlin vs Swift
    • GUI vs CLI
    • What is CentOS
    • What is Template Class in C++
    • What is Apex
    • StringBuffer vs StringBuilder
    • DES vs AES
    • Encryption vs Decryption
    • Dynamic Routing
    • Cyclomatic Complexity
    • Encryption Algorithm
    • Install Kali Linux
    • Alpha Testing vs Beta Testing
    • What is DHCP
    • Basic HTML Tags
    • Advantages of C
    • ASP.Net Validation Controls
    • What is CSRF
    • Network Mapper
    • Loops in C++
    • Loops in C
    • EJB vs Spring
    • Switch Statement in C
    • CentOS Commands
    • Digital Signature Softwares
  • Database Management (71+)
  • Ethical Hacking Tutorial (33+)
  • HTML CSS Tutorial (47+)
  • Installation of Software (54+)
  • Top Interview question (188+)
  • Java Tutorials (196+)
  • JavaScript (71+)
  • Linux tutorial (32+)
  • Network Security (85+)
  • Programming Languages (232+)
  • Python Tutorials (89+)
  • Software Development Careers (38+)
  • SQL Tutorial (33+)
  • String Functions (12+)
  • Technology Commands (38+)
  • Top Differences (368+)
  • Web Development Tools (33+)
  • Mobile App (60+)
Technology Blog Courses
  • Software Testing Training
  • Selenium Training Certification
  • Appium Training
  • JMeter Certification Training
Footer
About Us
  • Who is EDUCBA?
  • Sign Up
  •  
Free Courses
  • Free Course Programming
  • Free course Python
  • Free Course Java
  • Free Course Javascript
  • Free Course on SQL
  • Free Course on Web Design
  • Free HTML Course
  • Free Android App Development Course
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • Ruby on Rails Course
  • ASP.NET Course
  • VB.NET Course
  • Bootstrap Training Course
  • Become a Linux System Administrator
  • PHP Course
  • Joomla Training
  • HTML Course
Resources
  • Resources (A To Z)
  • Java Tutorials
  • Python Tutorials
  • Top Differences
  • Top Interview Question
  • Programming Languages
  • Web Development Tools
  • HTML CSS Tutorial
  • Technology Basics
  • Technology Careers
  • Ethical Hacking Tutorial
  • SQL Tutorials
  • Digital Marketing
Apps
  • iPhone & iPad
  • Android
Support
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions

© 2019 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Let’s Get Started
Please provide your Email ID
Email ID is incorrect