Friday, May 8, 2020

Introduction to Algorithm

------------------------------------------------------------------------------------------------------------------

Problem & Solution?

In our Computer Science & Engineering, a problem may be treated as a set of values(say P) which are available to you at certain time t, but it is not the desired value set that you need.

Let, the desired value set be S. If S can be obtained from P somehow, then P may be called a Problem and S is the solution to the problem P. 

The way to calculate the desired set S from the given set P may be called Method. A Method can be represented by means of Flowchart or Pseudo Code.

Example:
Let, we have an integer X, and we want to find the set F which will contain all the factors of X.
Certainly, for X=100, F will be {1, 2, 4, 5, 10, 20, 25, 50, 100}.

Let, the method of calculating F is named as Factor_Calculator. So, the method should take X as Input and should generate the set F as Output.

Thus, the method Factor_Calculator must be represented as,
Factor_Calculator(X, F) with proper specification of X and F, so that, someone can understand the relationship between the Input & the Output.

Obviously, to calculate/ generate the set F from the given set X we need at least one or more operations. When there will be more than one operations, certainly there must be a sequence in the operations to get F properly, as we have seen earlier in the arithmetic using BODMAS rule

Definition of Algorithm:

A definite set of finite number of steps/ statements(logical or mathematical ) in a particular sequence to accomplish a predefined and particular task, such that, every steps should be computed within a finite amount of time, may be called an algorithm. 

Properties of an Algorithm:

An algorithm should have the following properties
  1. Input: An algorithm should have zero/ more explicit inputs.
  2. Output: An algorithm must have at least one/more output.
  3. Definiteness: Each step/ statement of an algorithm must be precisely defined without any confusion.
  4. Finiteness: Each step/statement of an algorithm must be computed in finite amount of time.
  5. Effectiveness: An algorithm must be effective, i.e. it should be computed using pencil & paper by a human being, may be taking too long time but not infinite.
  6. Correctness: An algorithm must produce correct result within its specified domain.
Note that, when a method does not satisfies the definiteness property it may be called Procedure.

Steps for Solving a Problem in View of Computer Science & Engineering:

The followings are the basic steps to solve a problem-
  1. Problem Statement: Generally, a set of statements is given by the client. May be a question in the laboratory or examination hall in our education system.
  2. Analysis of Requirements: Finding number of values required for the specific computation as input. Nature of each input values. Finding number of outputs and also nature of the output values .
  3. Problem Specifications: Define each of the input and output values specifically in terms of their nature. Also, state proper assumptions if required to ensure validity of the values. Consider a problem statement "perform X+Y". Assumptions may be taken as, (1) Z is the output, (2) X, Y, Z are the integer quantity. Assumption 2 is useful to validate the data value X & Y.
  4. Design of Algorithm: Finding one efficient solution. This is our main target in this documentation.
  5. Data Structure: Specification of the suitable Data Structure for the set of values required to implement the algorithm (Input, Output & temporary values) depending on the behavior of the values.
  6. Program Code: Selection of the Programming Language & Coding to ensure the automation of the algorithm.
  7. Testing: Testing of the program code w.r.t the specification of the Input/Output in the Algorithm designed.
Note That, Documentation of every steps stated above is very important w.r.t the future uses or modification or up gradation of the system(software/ a simple program).

There are so many things with the algorithm, those will be discussed in the later sections under this topic(Algorithms & its Analysis). You may note the following topics for future references-
  1. A problem can be solved using iterative or recursive algorithm.
  2. Complexity of an algorithm is one important part of analysis of an algorithm. This property shows the efficiency of an algorithm.
  3. There are so many classifications of Problems, like
    1. Decision problem
    2. Satisfiability problem
    3. Optimization problem
    4.  etc
  4. There are many types of algorithms like,
    1. Divide and Conquer algorithm
    2. Greedy Algorithm 
    3. Backtracking
    4. Branch & Bound
    5. Approximate algorithm
    6. Heuristic algorithms
    7. Genetic algorithms
    8. Dynamic Programming
    9. Ant colony Optimization
    10. Mimetic Algorithm
    11.  Simulated annealing
    12.  etc.

12 comments:

  1. After reading the above post, I must say that the text justifies the title of this post.
    This post actually cover the followings:
    1. Definition of Problem & it's Solution is explained with the help of mathematical concept.
    2. Definition of Algorithm(in simple terms) along with it's Properties.
    3. How to solve a problem?

    -Dwaipayan Bhoumick
    B.Sc, CMSA, Sem-IV

    ReplyDelete
  2. In this page, the definition of Algorithm and the properties of an Algorithm attracted my sight terribly.

    I read and I understand it - CMSA, SEM-2, Anojit Ghosh.

    ReplyDelete
    Replies
    1. Sir, how is it possible that an Algorithm may have zero input?

      Delete
    2. No, not "zero input" rather "zero explicit input"....
      Both statement are not same....

      Delete
  3. I get enough clearance from the Article. And I understood. If I will read this Article for next time and find some confusion, can I use 'Contact From' ? - Atish Sarkar, CMSA, SEM-II.

    ReplyDelete
  4. From these notes i learned the types of Algorithm that i did not know before.
    -SUNY DAS(CMSA,Sem-II)

    ReplyDelete
  5. Thank you Sir for emphasizing such a topic which is not paid much attention by everyone and that too with these definitions which make this topic much easier to understand.
    I read it & I understood it - Roshan Kumar Sharma, CMSA, sem-II

    ReplyDelete
  6. It is very helpful to understand about algorithm & it's analysis.
    - Arundhuti Dey,Spc,CMSA,Sem-2

    ReplyDelete
  7. All the topics are described precisely. I understood most of them at one go.
    First of all, the steps to solve a problem which are mentioned here are really going to be helpful.

    Secondly, classifications of the problems (described here) will help to understand them with ease.


    -Udayaditya Sasmal
    B.Tech, 6th Semester, GNIT

    ReplyDelete
  8. I have read the new topic of this article..
    I'm interested to know more about the followings..
    There are many types of algorithms like,
    Divide and Conquer algorithm
    Greedy Algorithm
    Backtracking
    Branch & Bound
    Approximate algorithm
    Heuristic algorithms
    Genetic algorithms
    Dynamic Programming
    Ant colony Optimization
    Mimetic Algorithm
    Simulated annealing
    etc.

    ReplyDelete
    Replies
    1. Yes....
      Wait for some time....
      Those are the part of your Semester- IV....
      Coming Soon....

      Delete