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
@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
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
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
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
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
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
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
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
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"
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
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
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
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
14 matches
Mail list logo