Implement a complete binary tree using an array
Posted on 2004-08-28
Ok. I am willing to post a second 500 pointer to anyone who can assist me here. I am a C++ dummy, so be kind. I am trying to convert an algorithm from VB6 to C++, but I don't know where to start. C++ is WAY out of my league.
Anyway...I have a program in VB that does the assigned task (an old homework problem from my VB classes, but is right along the same lines as what I'm trying to accomplish in C++).
The program performs a binary tree sort using an array. The treesize is only 10, and the values will change from time to time, but for the moment let's assume the nodes are initialized as follows:
treesize=10; //as mentioned above
I need to have a program that'll utilize the int parent, int leftchild, and int rightchild to organize these ten values. This is so vastly different from VB6 that I don't even know where to start.
I am trying to teach myself C++ and I'm using my VB code as a guideline to write C++ code. Can anyone get me the source code that can perform this function? Our C++ instructor for the college I work at recently had a heart attack, and is in the hospital and out of commission for a while. They threw me into this position to "sub" for him being that I am the only other instructor with any background in programming....unfortunately, just the wrong kind (SQL and VB6). Further...I am a networking guru. I have tried adamantly to AVOID programming. LOL. Now, here I am...knee deep in it.
I've scoured the net and found a lot of code on arrays and BSTs, but can't really find one that will show me how to create a binary tree sort using an array. I've got to sub for this guy for up to the next six weeks (unless the college can find a temp substitute sooner), so I am hoping someone here can help me out from time to time when I need it.
Thanks in advance!