Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help inserting a tree into a heap...

Status
Not open for further replies.

randy4126

Programmer
Jun 2, 2001
62
US
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
smiletiniest.gif


You can Email me at: RCooper@cinci.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top