CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    Join Date
    Nov 2003
    Posts
    1,405

    Re: O(log n) algorithm

    Quote Originally Posted by ideru
    i agree with _uj

    first try to create the BST then do a search right and left ..
    Well, I didn't suggest a BST to be built In my reply #15 I suggested an O(log N) solution based on two slightly modified standard binary searches.

  2. #17
    Join Date
    May 2005
    Location
    Ellesmera
    Posts
    427

    Re: O(log n) algorithm

    Quote Originally Posted by _uj
    Well, I didn't suggest a BST to be built In my reply #15 I suggested an O(log N) solution based on two slightly modified standard binary searches.
    oh okay my bad, you did not suggest a BST ..

    but its good the OP can now have some options on how to solve the problem ..
    *** Con Tu Adios, Te Llevas, Mi Corazon***

    Traveling Encoder...

  3. #18
    Join Date
    May 2005
    Location
    Ellesmera
    Posts
    427

    Re: O(log n) algorithm

    Quote Originally Posted by ProgramThis
    There is absolutely no need for a BST here. As seeguna has shown you can perform O(log(n)) searches on arrays given the conditions of the problem easily. Complicating the issue with trees is not the solution.
    If you look closely, the sample code that seeguna posted is actually a binary search code
    *** Con Tu Adios, Te Llevas, Mi Corazon***

    Traveling Encoder...

  4. #19
    Join Date
    Feb 2008
    Posts
    966

    Re: O(log n) algorithm

    Quote Originally Posted by ideru
    If you look closely, the sample code that seeguna posted is actually a binary search code
    Yes, and you wouldn't have posted this comment if you knew the difference between a binary search and a binary search tree.

    I was suggesting that there is no need to use a BST when you can perform a binary search on the array. YOU suggested placing the array into a BST and then using that. I was reasoning that there was no need to create the tree because a binary search can already be done on an array.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured