An algorithm is a procedure used for solving a problem or performing a computation.
Algorithms act as an exact list of instructions that conduct specified actions step by step in either hardware- or software-based routines.
Searching
There are various algorithms available.
One of the basic and most used algorithm is the searching algorithm.
Searching algorithms are used to find a specific element in an array, string, linked list, or some other data structures.
The most common searching algorithms include:
Linear search,
which checks for the element iteratively from one end to the other.
Binary search,
which breaks the data structure into two equal parts and try to decide in which half we need to find for the element.
Ternary search,
where the array is divided into three parts, and based on the values at partitioning positions we decide the segment where we need to find the required element.
Sorting
Sorting algorithm is used to rearrange a given array or list elements according to a comparison operator on the elements.
The comparison operator is used to decide the new order of element in the respective data structure.
There are many different types of sorting algorithms like
bubble sort,
selection sort,
insertion sort,
quick sort, and
merge sort.
Divide and Conquer
As the name suggests, it breaks the problem into parts, then solves each part and after that again merges the solved subtasks to get the actual problem solved.
This is the primary technique mentioned in the two sorting algorithms, quick sort and merge sort.
A typical divide and conquer algorithm solves a problem using the following three steps:
Divide,
which break the given problem into subproblems of same type,
Conquer,
which recursively solve these subproblems, and