Alg Design Techniques
Alg Design Techniques
Backtracking Algorithm
4. Divide and Conquer
A divide and conquer algorithm breaks down the complexity of
its problem so it can solve smaller and easier sub-problems. It
involves three major steps:
Divide – Divide the problem into multiple sub-problems of
the same nature
Solve – Solve each resulting sub-problem
Combine – Combine the solutions to the sub-problems to
get the solution to the starting problem
A divide and conquer algorithm handles each sub-problem
separately. Such algorithms give the most optimal solution for
problems like efficiently sorting a collection of elements.
Example
Thanks to their simple approach, it isn't hard to understand
divide and conquer algorithms. There are many divide and
conquer algorithm examples in the real world. For example,
take the common problem of looking for a lost item in a huge
space. It is easier to divide the space into smaller sections and
search in each separately.
Recursive Algorithm
7. Searching
A searching algorithm retrieves information about an element's
existence in a collection. Here are different types of searching
algorithms based on their approach:
Linear Search: Checks each element in the collection
Binary Search: Searches the first or latter half of a sorted
collection depending on the element's value
Hashing: Searches using the hash value obtained through
a hashing algorithm
Example
There are different search algorithms, each searching for the
element in a certain data structure. For example, some popular
searching algorithms for graphs are:
Breadth-first Search
Depth-first Search
A* search
Similarly, hash-based searching uses unique values called hash
values generated by a hashing algorithm. Linear and binary
search are the common options for searching an element in a
collection.