INTRODUCTION TO ALGORITHMS

Definition

An algorithm is a sequence(step-by-step) of unambiguous instructions to solve a problem for obtaining a required output for any legitimate input in a finite amount of time.

Algorithmics is more than a branch of computer science, it is the core of computer science and in all fairness can be said to be relevant to most of science, business, and technology.

Reason for studying algorithms is their usefulness in developing analytical skills. After all, algorithms can be seen as special kinds of solutions to problems. It is like the mixture of mathematics and programming.

Simple Example

Algorithm to find the sum of two numbers.

  1. Start
  2. Read num1, num2
  3. sum = num1+num2
  4. Display sum
  5. Stop

Important points about Algorithms

  • The non-ambiguity requirement for each step of an algorithm cannot be compromised.
  • The range of inputs for which an algorithm works has to be specified carefully.
  • There maybe more than one algorithm for solving the same problem.
  • The same algorithm can be implemented in several ways.
  • Algorithms for the same problem can be based on different ideas and can solve the problem with dramatically different speeds.

Characteristics

  1. Inputs: 0 or more no. of inputs
  2. Outputs: 1 or more no. of outputs
  3. Unambiguity: Clear & Simple instructions.
  4. Finiteness: Limited no. of instructions/steps to solve the problem
  5. Effectiveness: Each instruction has an impact on overall process.

Notion of an Algorithm

Notion of an Algorithm
  • First we look into the problem.
  • We write an algorithm for the problem and feed it into the computer.
  • We then provide inputs to check the correctness of the algorithm.
  • Finally we get the output/s based on how the algorithm was written.

Design and Analysis of Algorithms

Design and Analysis of Algorithms
  1. The first thing you need to do before designing an algorithm is to understand completely the problem given. Read the problem’s description carefully and do a few small examples by hand, think about special cases.
  2. Once you completely understand a problem, you need to ascertain the capabilities of the computational device the algorithm is intended for. The next principal decision is to choose between solving the problem exactly or solving it approximately.
  3. An algorithm design technique is a general approach to solving problems algorithmically that is applicable to a variety of problems from different areas of computing. Design a simple algorithm that could approximately solve the problem.
  4. Prove the correctness by providing inputs of your own and try to get the required output. That is, you have to prove that the algorithm yields a required result for every legitimate input in a finite amount of time.
  5. We usually want our algorithms to possess several qualities and be more efficient. In fact, there are two kinds of algorithm efficiency: time efficiency (indicating how fast the algorithm runs) and space efficiency (indicating how much extra memory it uses).
  6. Finally, code the algorithm with your preferred programming language.

That's it from this blog post. If you liked it then do share this blog with your friends or people who wanna get into programming world. Thank You!

Copyright © NStF Blogs 2021