Algorithms and The Different Types of Algorithms

feature-top

The programming world is very fascinating and interesting, many programmers understand that having their skills sharp and up to date, is very important to solve very complex algorithm questions and problems with code.

In order to be able to solve these complex questions, a good software engineer must be familiar with the different types of algorithms, and algorithm techniques, which exist, to solve complex algorithm problems.

In today's article, we are going to be talking a bit about algorithms, how they work, the different types that exist. A computer is able to solve problems, by using algorithms, which are well-defined procedures, used by software engineers to solve complex algorithmic problems.

Some of the algorithms available today are, Simple recursive algorithms • Backtracking algorithms • Divide-and-conquer algorithms • Dynamic programming algorithms • Greedy algorithms • Branch-and-bound algorithms.

The recursive algorithm, calls itself but with simpler or smaller input values, which are used to obtain the results of the operations. When a function calls itself, directly or indirectly, it is known as recursion, the recursive function is the corresponding function.

The base case is provided with a solution in recursion, and for the bigger problems, a solution is provided in terms of smaller problems, by dividing that big problem into smaller problems. The base case is the case for when the answer is known and can be expressed, without the need to use recursion. In a recursive algorithm, a problem is represented in terms of one or more smaller problems, then the base case is used to stop the recursion.

A stack overflow problem may occur, if the base case, has not been reached or well defined. A recursive algorithm may be direct or indirect, which means that when a function bread() call function bread() then this is known as direct recursion.

However, if function bread() call a function bread_new() and then that function call function bread() then this is known as indirect recursion.

The following code is from GeeksforGeeks.com


// PHP program to demonstrate 

// working of recursion   

// function to demonstrate 

// working of recursion

function printBread($milk)

{

    if ($milk > 1) // base case

        return;

    else

    {

        echo("$test ");

       // statement 2

       printBread($milk + 1); 

          

        echo("$test ");

        return;

    }

}

// Driver Code

$milk = 3;

printFun($test);   

// This code is contributed by

// Smitha Dinesh Semwal.

?>

Another type of algorithm is known as Backtracking algorithms, which searches every possible combination in order to solve a computational problem. A solution is built incrementally in a backtracking algorithmic technique, which solves problems recursively.

The solutions which fail to satisfy the constraints of the problem are removed from being identified as a possible viable solution to the problem.

The types of backtracking problems are known as Decision problems, which is where a feasible solution is searched. Another type is an optimization problem, where the best solution is searched, and enumeration problem, which finds all the feasible solutions.

Backtracking algorithm is simple and elegant, however, it is not the best performing algorithm out there for use. In backtracking algorithm we attempt to solve the problem by trying something, if that doesn't work, then backtrack what we did and try something else, if that doesn't work either backtrack what we did then try solving something else until the solution is reached. The problem is backtracking is divided into subproblems, and each of those subproblems is solved until a solution is reached.  

feature-top
feature-top
Hernando Cadet

Hi every one, I obtained a bachelor's degree in Bioinformatics back in 2006, from Claflin University, after I received my bachelor's degree, I gained full time employment as a software engineer at a Video Relay Service company, maintaining databases and developing software for a new developed device called the VPAD.

I worked at that company for two years, then I became a web developer, and worked for a magazine for three years. After that job, I worked as a Drupal web developer, as a subcontractor for the NIH, for a year and then left the job to go back to school.

Hernando Cadet Hi every one, I obtained a bachelor's degree in Bioinformatics back in 2006, from Claflin University, after I received my bachelor's degree, I gained full time employment as a software engineer at a Video Relay Service company, maintaining databases and developing software for a new developed device called the VPAD.

I worked at that company for two years, then I became a web developer, and worked for a magazine for three years. After that job, I worked as a Drupal web developer, as a subcontractor for the NIH, for a year and then left the job to go back to school.