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: Panduranga chary — May 16, 2008
    not yet rated
      + -

    search diagonally.

    diag 1 = 1
    diag2 = 2,4
    ….

    for example
    given the number 7 we take the bounds of each diagonal and check wether the number will fall in that range else move farward.
    here diagonal selection is sequential but the number search is binary.

  2. Submitted By: rimi — May 25, 2008
    +1 votes
      + -

    //int uperrow,uppercol;
    // number to b searched is n;
    //asumed no are sorted in ascending order
    1)apply binary search on 1st row of initial arrey,that ll return the index of smallest no >= n ,in that row i.e. upper bound of coloumns and is denoted as uppercol;
    2)apply binary search on 1st col of initial arrey,that ll return the index of smallest no>=n, in that col i.e. upper bound of rows and is denoted as upperrow;
    3)now ur matrix size is upperrow*uppercol;forget no beyond this range;
    4)apply step 1) and 2) again but remember that matrix is shortened,so apply search remembering the upperbounds of rows n colunms;

  3. Submitted By: None of them will work — June 1, 2008
    +3 votes
      + -

    None of the above will work. The best solution possible is is an O(m+n) solution.
    Start with the left bottom element.
    If it is smaller than key, move to the left.
    If it is larger than the key, move upwards.
    Continue till you find the key or reach a boundary.
    Regards,
    J1gs4w

  4. Submitted By: Samrat — June 2, 2008
    not yet rated
      + -

    Rimi > understood your logic but want to change a bit.

    let firstrow,lastrow,firstcol,lastcol be the variable..

    if (a[midrow][midcol] target)
    {
    lastrow=midrow
    lastcol=modcol
    }

  5. Submitted By: Otron — June 5, 2008
    not yet rated
      + -

    Assuming the array has N rows and M columns, searching for the value V:

    Perform binary search on the first row, and find the index i s.t. array[0,i-1]

  6. Submitted By: Code Decoder — June 26, 2008
    +1 votes
      + -

    I suggest following method to use….

    First Search the no. in first row and store the index of the element which is just smaller than the no. to search. Similarly find the same in the first column. Now you have two indices this will divide the entire matrix into four parts out of which only one part will lie in our problem domain.

    Apply the same logic for this part of matrix.

    This way you can find the element in least time.

  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.