I am trying to Huffman Encode and String. To do this I First store the frequency of each character in an array that looks something like this:A["Ascii value of the character"]= frequency of the character
Example: "Ascii";
A[65]=1; //A
A[115]=1 // s
A[99]=1;// c
A[105]=2;//i
I am trying to make a Priority Queue based on this array.
I have set up a CharacterObject class that has two attributes: the actual Character, and the frequency.
I have created the following PriorityQueue:
PriorityQueue<CharObject> pq= new PriorityQueue<CharObject>(pqsize);
// pqsize is the number of distinct characters in the string
// i want to Huffman Encode.
My question is how do I tell the The PriorityQueue that I want to Prioritize by the frequency attribute of the CharacterObject class I made so that it doesnt throw an error when i try to add the the PQ. Side note I want to implement a Min-PQ.