LoginSignup
2
0

More than 5 years have passed since last update.

Algorithms

Last updated at Posted at 2018-07-18

What is an algorithm

An algorithm is simply as set of steps or actions to accomplish a specified task

    Main tools used to analyse and build an algorithm:
  1. understanding difference between Binary search and Linear search (Binary Search: a way to efficiently search an array of items by halving the search space each time).
  2. Asymptotic notation: how to use asymptotic analysis to describe the efficiency of an algorithm, and how to use asymptotic notation (Big O, Big-Theta, and Big-Omega) to more precisely describe the efficiency.

How to make your code more efficient and faster to execute

In Algorithms there is a way to know approximately how long a code could take so how it is really efficient as a code by using asymptotic notation (Big O, Big-Theta, and Big-Omega)

For that purpose there are many different Algorithms to resolve the same problem, the only problem is to how to choose the best algorithm that can be used to resolve it

    let is take example of sorting arrays by order, these are the most common used algorithms:
  • Selection Sort : not an efficient way
  • Insertion Sort : not a very efficient way
  • (Recursive Algorithms): Merge Sort : a very efficient way relying on the power of recursion
  • (Recursive Algorithms): Merge Sort : a strong efficient way

By using recursion the Average-case running time decrease considerably from Θ(n^2) (for Selection and Insertion Sort) to Θ(nlgn)

As you can remark that using recursion make the algorithms more efficient and faster as it relies on very smart concept (Divide and Conquer) which is :

  1. Divide : divide the main problem to smaller subproblems
  2. Conquer : use the recursive logic by finding the base cases
  3. Combine : as final step combining the solution of all subproblems and merge it for the solution of the original problem

Knowing these details can impact considerably to enhance your way to resolve problems and code more efficient algorithms to resolve the problems that you may encounter in future

main source used for this article : KHAN Academy-Algorithms.

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0