I need help Im trying to implement the huffman algorithm.
And i am running into a problem that I need to insert a tree into the heap and i think becuse i told it only a node it cuts off my branches.
this is what im doing...
struct TreeNode
{
int Weight;
char Letter;
TreeNode *RightChild;
TreeNode *LeftChild;
};
/* Implementation of HEAP ADT */
class Heap
{
public:
Heap(): v( 1 ), Size( 0 ){}; //don't use first one
void insert(TreeNode *x);
TreeNode* findMin( ) const;
void deleteMin( );
bool isEmpty() const;
int Size; // Number of elements in heap
private:
vector<TreeNode *> v ; // The heap vector
void perculateDown (int loc);
void perculateUp (int loc);
};
Randy
You can Email me at: RCooper@cinci.rr.com
And i am running into a problem that I need to insert a tree into the heap and i think becuse i told it only a node it cuts off my branches.
this is what im doing...
struct TreeNode
{
int Weight;
char Letter;
TreeNode *RightChild;
TreeNode *LeftChild;
};
/* Implementation of HEAP ADT */
class Heap
{
public:
Heap(): v( 1 ), Size( 0 ){}; //don't use first one
void insert(TreeNode *x);
TreeNode* findMin( ) const;
void deleteMin( );
bool isEmpty() const;
int Size; // Number of elements in heap
private:
vector<TreeNode *> v ; // The heap vector
void perculateDown (int loc);
void perculateUp (int loc);
};
Randy
You can Email me at: RCooper@cinci.rr.com