PA of Algorithms Q38

0. What does the following algorithm approximate?

  • Option : C
  • Explanation :
    Given program fragment in Pseudo language is
    x = m ;
    y = 1 ;
    while (x – y > e)
    x = (x + y) /2 ;
    y = m/x ;
    }
    Print (x)
    This program will find out the square root of m, suppose that m = 2
    X-YXY
    1st looping23/2=1.52/1.5=1.33
    2nd looping.16(1.5+1.3)/2 = 1.4152.0/1.415 = 1.413
    3rd looping0.021.4141.414
    4th looping0  

    as x – y = 0 exit from loop hence print 1.414 which is root of 2.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *