Ad Code

Ticker

6/recent/ticker-posts

What is an algorithm in computer science

  


 Algorithm refers to the logic of program, and step-by-step description of how to arrive at the solution of a given problem.Algorithm is not a  computer code.Algorithm are just instruction which gives which give clear data to you idea to write the computer code.

   If we are going to make a program, firstly we have want to write the algorithm and flowchart then only we get correct idea about program.To become a programmer the base is to know about algorithm and flowchart.


Qualities of a good algorithm

  • Inputs and output should be defined precisely
  • Each steps in algorithm should be clear and Unambigous.
  • Algorithm should be most effective among many different 
  • different ways to solve a problem.
  • An algorithm shouldn't have computer code. Instead, the algorithm should be written in such a way that, it can be used in similar programming language.

 Let's look a simple algorithm to find the sum of x and y

           step 1: start   
           step 2: input x,y
           step 3 :let s=x+y
           step 4: print s
           step 5: stop

Lets look another problem

To find the radius of a circle whose radius is given
      
            step 1: start
            step 2: read r
            step 3:let A =3.14*r^2
            step 4: print A 
            step 5: stop   


Find the area of triangle


            step 1: start
            step 2: read b,h
            step 3:let A =1/2*b*h
            step 4: print A 
            step 5: stop      
     

check the given number is odd or even


          step 1: start
          step 2: read x
          step 3:if x mod 2=0,then print''Number is even''else go to step 4.
          step 4: print'' Number is odd '' 
          step 5: stop   


Find the largest among two number



          step 1: start.
          step 2: read x,y.
          step 3:if x>y then print x,''is the largest'' else go to step 4.
          step 4: print y,'' is the largest ''.  
          step 5: stop .
Reactions

Post a Comment

0 Comments

Ad Code