AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: xianfeng — October 6, 2006
    +12 votes
      + -

    void circle(int x,int y, int rad)
    {
    //check boundary first
    for (int xi = x-rad, int yi = y-rad;
    xi<=x+rad,yi<y+rad; xi++,yi++)
    if((xi-x)*(xi-x)+(yi-y)*(yi-y) = rad *rad + Error)
    set_point;
    }

  2. Submitted By: nmotgi — October 6, 2006
    -2 votes
      + -

    In order circle using only integers this might be the solution.

    {(x,y) represent center and k the radius.}
    loop thru till u complete drawing the circles
    x = x + y/k;
    y = y + x/k
    end loop.

    – Nitin Motgi (nmotgi@cs.ucf.edu)

  3. Submitted By: srm — October 6, 2006
    +2 votes
      + -

    In order to avoid floating point calculations, we can do two things:

    1) instead of fixing one co-ordinate and looking for anothe via the equation, search the whole co-ordinate space from x +- r and y +- r. Plot the point that is close.

    But this is a costly N*N algo.
    2) To go for an efficient workhorse, go for Bresenham’s circle drawing algo, found in any of the good graphics textbooks.

  4. Submitted By: Vladimir — November 29, 2006
    +7 votes
      + -

    Lets forget about the circle’s center point (Xc,Yc) for a minute. To minimize calculations you should consider the next notes:

    1) It is enough to calculate all the points just in one quarter of a circle. For each calculated point you can build three additional points by a simple sign manipulation (and than shifting according given Xc and Yc)

    2) Now we need to calculate all (X,Y) points which belong to the circle’s quarter sector. There are [Rad+1] of such points. X[0]=0, X[1]=1 … X[Rad] = Rad. And here is the most important optimization: Y(X[n]) INF, that is a pretty optimal O(N) algorithm

  5. Submitted By: arpit — May 22, 2007
    not yet rated
      + -

    vladmir, u can optimise ur soln even more by considering symmetry about x and y axes. so effectively, u can calculate points in one half of a quadrant and use that to compute 7 more points and then shifting the points according to the center of the circle

  6. Submitted By: ravi — July 15, 2007
    -2 votes
      + -

    listen
    you better go byconversion in radians i.e angle
    rcos@,rsin@ now vary @0 to 360

  7. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.