array elements: 1 2 9 8 7 5 2 3 1 1 4 2 6 2 3 sort: 1 1 1 2 2 2 2 3 3 4 5 6 7 8 9 compare the element with the next , if its same then increment the count. repeat until v find all the occurrences of tat element & then insert tat element into arr[count] (if arr[count] is null else traverse the list to insert @ the right postion)
create another array say arr arr[0] some sentinal/ garbage arr[1] pointer_list1 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 arr[2] pointer_list2 -> 3 arr[3] pointer_list3 -> 1 arr[4] pointer_list4 -> 2 . . . . On Sun, Oct 3, 2010 at 11:37 AM, mac adobe <macatad...@gmail.com> wrote: > how will this give me array_1 which lists all numbers comming 1 time , > array_2 which lists all numbers comming 2 time etc ? > > > > On Sun, Oct 3, 2010 at 11:31 AM, kusuma sanjeev <kushina...@gmail.com>wrote: > >> One possible solution would be to create an array of pointers to the >> list.. array index indicates how many times the element occurs and the list >> gives the elements. >> >> >> On Sun, Oct 3, 2010 at 11:22 AM, sharad kumar <aryansmit3...@gmail.com>wrote: >> >>> it will take same amount of memory na....key value is element and vaule >>> is the amount of times element occurs..... >>> >>> >>> On Sun, Oct 3, 2010 at 11:11 AM, mac adobe <macatad...@gmail.com> wrote: >>> >>>> i think hash map takes lots of memory ... please correct me if i am >>>> wrong here .. >>>> >>>> anyways its a soluton but i would like to have a different solution .. >>>> :) >>>> >>>> --mac >>>> >>>> >>>> On Sun, Oct 3, 2010 at 10:55 AM, sharad kumar >>>> <aryansmit3...@gmail.com>wrote: >>>> >>>>> cant u use a hash map buddy??? >>>>> >>>>> On Sun, Oct 3, 2010 at 10:35 AM, mac adobe <macatad...@gmail.com>wrote: >>>>> >>>>>> You are given a very long array of integers . Some number in this >>>>>> integer array come 1 time , some 2 times some 3 times . create 3 >>>>>> different >>>>>> arrays . >>>>>> Array 1 will have numbers with numbers comming only1 time , Array 2 >>>>>> will have numbers with numbers comming 2 times, Array 3 will have >>>>>> numbers >>>>>> with numbers repearting 3 times , >>>>>> >>>>>> >>>>>> Can you extend the solution to create array_x with elements repeating >>>>>> x times ? >>>>>> >>>>>> thanks >>>>>> --mac >>>>>> >>>>>> -- >>>>>> 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. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> yezhu malai vaasa venkataramana Govinda Govinda >>>>> >>>>> -- >>>>> 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. >>>> >>> >>> >>> >>> -- >>> yezhu malai vaasa venkataramana Govinda Govinda >>> >>> -- >>> 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. >>> >> >> >> >> -- >> Rgds, >> Kusuma S >> >> -- >> 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. >> > > > > -- > thanks > --mac > > -- > 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. > -- Rgds, Kusuma S -- 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.