Quick sort technique. Element to search k.

Sort(A, s,e, Key)
{
       pivot=A[s];
       z= partition(A,s,e,pivot); //this will split the array in to two parts in which one part contains elemnents lesser than the pivot and
                                     other greater than pivot.
       If ( pivot > key) Sort(A,s,z,key);
      else if (pivot == key) return pivot;
      else {
                    if(z==e) return pivot;
                     swap(A[z],A[e]);
                     Sort(A,z,e,Key);
}
 
On 5/19/06, Terry <[EMAIL PROTECTED] > wrote:

Hi,

If i have an array like {1,4, 10, 15 , 20 , 30 }  of size n , now if i
want to search for number

25 , i should get 20 , if i search for number 11 i hould get 10 , if i
search for 4 i should get 4, if i search for a number and it doesn't
exist i should get the lower number between which it lies. All numbers
are bound to lie between 1 and n.

Can you tell me a easy way to do it.


Regards
Nik


[EMAIL PROTECTED]
-------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to