Re: [algogeeks] Frequency Sort Algo

2011-12-29 Thread praveen raj
steps: 1) use hash mapping to keep track of frequency of each and every element. 2)Then iterate hash table and store in 2D array with 1st column(element value) and 2nd column(frequency of element value). 3)sort the row according to second column(i.e frequency). 4)Then Print the eleme

Re: [algogeeks] Frequency Sort Algo

2011-12-27 Thread atul anand
@Ashish : not exactly ... you can use counting sort 1st part where you find the frequency of each elements. now u have to select frequency in decreasing order to give the required output. On Tue, Dec 27, 2011 at 7:49 PM, Ashish Goel wrote: > isn't the solution is counting sort? > Best Regards

Re: [algogeeks] Frequency Sort Algo

2011-12-27 Thread Ashish Goel
isn't the solution is counting sort? Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sat, Dec 24, 2011 at 11:48 PM, atul anand wrote: > first sort the given array , you will get > > 1,1,1,1,2,2,2,3,3,3,3,3,4,4,5 > > now count frequency of each nu

Re: [algogeeks] Frequency Sort Algo

2011-12-24 Thread atul anand
first sort the given array , you will get 1,1,1,1,2,2,2,3,3,3,3,3,4,4,5 now count frequency of each number and insert it into min heap. each node contain 2 variable. 1) frequency 2) number now do extract min operation. and expand , for eg:- for node 5 frequency = 0 number =5; write 5 to the giv

Re: [algogeeks] Frequency Sort Algo

2011-12-24 Thread surender sanke
MinHeap with frequency of data is constructed, then sorting it. But don't see with same frequency it maintains the order of the first appeared element Regards Surender On Sat, Dec 24, 2011 at 10:57 PM, Ankur Garg wrote: > how can one do frequency sort . > > Suppose we have an integer array like

[algogeeks] Frequency Sort Algo

2011-12-24 Thread Ankur Garg
how can one do frequency sort . Suppose we have an integer array like 1,2,3,1,2,3,1,1,2,3,4,4,3,5,3 Then 1 is appearing 4 times 2 - 3 3- 5 4-2 5-1 Then if we sort by frequency we shud have this as result 5,4,4,2,2,2,1,1,1,1,3,3,3,3,3 How to do it -- Y

Re: [algogeeks] Frequency of number

2011-09-27 Thread Yogesh Yadav
Take an array a[1000]input first 1000 values from the stream in it.. Here we are representing a unit time with help of space because 1000 elements in a stream will always come in constant time So just count the occurrence of a given number in that array... then divide the count with 1000 t

Re: [algogeeks] Frequency of number

2011-09-27 Thread teja bala
If we are to find frequency of only one number let us say 35 in infinite coming numbers , do xor operation with coming numbers If the result is 0 increment the value of temp variable by 1 if not scan next input until all numbers are over. On Tue, Sep 27, 2011 at 10:22 PM, Ankuj Gup

[algogeeks] Frequency of number

2011-09-27 Thread Ankuj Gupta
Infinite numbers are coming in a stream . how will you find the frequency of a given number ? -- 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, se

[algogeeks] FREQUENCY COUNT FOR TIME

2011-09-04 Thread SHIVAM AGRAWAL
Calculate frequency count for time for the following. #include #include using namespace std; int main() { ifstream filein; filein.open("datafile.dat",ios::in); int a[100]; int j,k=0,h; filein >> j; while (filein){ a[k]=j; k++; filein >> j; } filein.close(); system("pause"

Re: [algogeeks] frequency

2010-05-14 Thread kaushik sur
Hi Friend Using HashMap in Java *** /* * input a character array from the user and output in the following way. example string is amazon.. then output should be a2m1z1o1n1 */ package questionaire; import java.util.Collection; import java.util.HashMap; impo

Re: [algogeeks] frequency

2010-05-14 Thread divya jain
use binary tree and insert in it every character u come across. if the character is already present then increment its count. use this approach if u r nt sure that characters will be only 26 or no. if u r sure there r 26 char then u cn use hash.. plz correct me if i m wrong. thanks On 14 May 2010

Re: [algogeeks] frequency

2010-05-13 Thread sharad kumar
cant u use a hash map of O(K) where K is distinct elements in string.. On Thu, May 13, 2010 at 8:13 PM, jalaj jaiswal wrote: > input a character array from the user and output in the following way. > example string is amazon.. then output should be a2m1z1o1n1 > > i did it taking a 26 siz

[algogeeks] frequency

2010-05-13 Thread jalaj jaiswal
input a character array from the user and output in the following way. example string is amazon.. then output should be a2m1z1o1n1 i did it taking a 26 size array... some better solution ?? -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message becau