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: Mr. Google — October 17, 2006
    +11 votes
      + -

    Well, you work out that 5123 x 3 = 15369. Write it down and then appropriately add zero’s and add.

    These types of problems typically are known as caching problems. Save your results so you don’t have to do it again!

    It’s not always so dramatic, but how many times do you want to recalculate things? The classic example of the Fibonacci sequence is an example:

    f( n ) = f( n - 1 ) + f( n - 2 )

    It’s trivial to translate this recursively. So we do. Unforunately, if you want to know, say, the 100-th Fibonacci number, and your computer does, say, a trillion calculations a second, it will still take, about 11 years to get your answer. So save and reuse your results! If you did do that, even if you only do 100 operation a second, it’ll take less than a minute!

    Yes, someone’s going to point out you only need the last two numbers, so you can use a for loop. You’re perfectly correct, and that’s “Dynamic Programming” (DP). Sometimes memoization is faster, sometimes dp is faster. Experience will tell you which one is which.

    I’m handwaving right now, but this isn’t simply “saving down results”, of course. DP/Memo is when you know that certain results will be re-used in the future, exploiting the fact that well, you don’t need to redoing the same thing over and over again..

  2. Submitted By: fishball — November 17, 2006
    +11 votes
      + -

    Assuming I am using C.
    5122 = 4098 + 1024 + 1
    = 2^12 + 2^10 + 2^0

    In this case:
    1. Shift 3333 to the left 10 bits => A
    2. Shift A to the left 2 bits => B
    3. answer = A + B + 3333

  3. Submitted By: P — April 11, 2007
    +2 votes
      + -

    Answer 3 is not correct
    4098+1024+1 = 5123

  4. Submitted By: Sharath — July 11, 2007
    +3 votes
      + -

    Answer #3 is almost near to solution.
    It should have been
    5122=4096+1024+2
    =2^12+2^10+2^1
    1. Shift 3333 to the left 1 bits = A
    2. Shift A to the left 9 bits = B
    3. Shift B to the left 2 bits = c
    4. Answer = A+B+C

  5. Submitted By: kiran — August 21, 2007
    +0 votes
      + -

    answer 5 is not correct
    3333*2^12 = 13651968
    3333*2^10 = 3412992
    3333*2^1 = 6666
    total 17071626

    BUt actual result of multiplication is 17074959
    There is 3333 difference between the answer and above result.

  6. Submitted By: Deepak Garg — September 3, 2007
    +0 votes
      + -

    It should have been
    5123=4096+1024+2+1
    =2^12+2^10+2^1+2^0
    1. A = shift 3333 left 12 bit
    2. B = shilf A Right 3 bit
    3 C = shift A Right 7 bits
    4 D = shift A Right 1 bit
    4. Answer = A+B+C+D

  7. Submitted By: Vlad Apostolov — September 19, 2007
    +3 votes
      + -

    5123 x 3333 =
    ((5123 x ((3 x 3333) + 1)) – 5123) / 3 =
    ((5123 x10000) – 5123) / 3 =
    (51230000 – 5123) / 3 =
    51224877 / 3 =
    17074959

  8. Submitted By: hello there — January 22, 2008
    -2 votes
      + -

    void doMultiply(int a, int b, int *result)
    {
    *result = 0;
    while (b–) {
    *result += a;

    retrun;
    }

  9. 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.