you have to find the kth element of your list. which will take O(n) and remaining element you can get in the other traversal eg: 3,5,4,35,599,34 you have to find the 3 min element from the lsit so finding 3rd element we will get 5 on next thing is traverse the list and take all the element less than 5, eg:3,5,4 is this clear your doubt ...? or i have gone on the other way...
On Sun, Mar 28, 2010 at 8:41 PM, abhijith reddy <abhijith200...@gmail.com>wrote: > Can any one tell how to do this when there are 'm' queries like "query i j > k" find the kth largest element in between indices i->j in an array. > When m is large even an O(n) algorithm would be slow. > I thinking that each query could be answered in O(sqrt(n)) time > So any suggestions ? > > Thanks > > > On Sun, Mar 28, 2010 at 7:57 PM, blackDiamond <patidarc...@gmail.com>wrote: > >> there are better solution of O(n) are posted in the thread.......[?]. >> using order statices .... >> >> >> On Sun, Mar 28, 2010 at 6:49 PM, Mukesh Kumar thakur < >> mukeshraj8...@gmail.com> wrote: >> >>> Create a temp array temp[0..k-1] of size k. >>> 2) Traverse the array arr[k..n-1]. While traversing, keep updating the >>> smallest element of temp[] >>> 3) Return the smallest of temp[] >>> Time Complexity: O((n-k)*k). >>> >>> >>> try it ..............for this problem[?] >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algoge...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> ~~~~BL/\CK_D!AMOND~~~~~~~~ >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algoge...@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- ~~~~BL/\CK_D!AMOND~~~~~~~~ -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
<<338.gif>>
<<361.gif>>