View Full Version : ok...guys...i m totally new here..plzz help me out..!!!


electrical
04-28-02, 12:39 PM
this is my first programmin assignment...and i have no clue wat to do.....can someone helpp........it will be very help ful....thanxx in advance...


Objective: implementing binary trees.
Goal: To implememnt the binary search tree ADT as an object template in C++, to use this ADT as the basis of a sorting program.

The binazry search (bstree) abstract data type is specified as follows.

Abstract Dada Type bstree{
Instances: binary search tgrees, each node has an element; all elements are distinct; elements in the left sub tree of any node are smaller than the element in the node, elements in the right sub tree are larger.
Operations: :
create ( ) : Create an empty binary search tree
Destroy ( ) : Erase a binary search tree.
Find ( ) : Return true if the binary search tree contains the element k;
false other wise.
Printsost ( ) : Output all elements in the binary search tree in ascending
order.
delete (k) : Delete the lements k from the binary search tree.
Insert (k) : Insert the element k into the binary search tree.
}

You are to implement this ADT in the C++ programming language. Perform each of the above operations on the tree structure and save in your output file. Run your tree with Inserting, printing, finding, creating, deleting etc.

Sorting. You are to now compare the performance of the Insertion Sort Algorithm with the following:

Given a file of elements that are to be sorted, we can insert these elements successively into a binary search tree, and then call printsort ( ) to print all the elements in the tree in sorted order.

You are required to collect timing information on the performance of both your sorting programs - the one using Insert Sort, and the current one - in sorting certain datasets that will be made through an input file.

Adam
04-28-02, 02:45 PM
I have very little idea about C++, I'm starting on C. But welcome to here anyway.

electrical
04-28-02, 03:48 PM
12 views....and NO...replyyy...!!!!

i thought i would get some help....
:(

Adam
04-28-02, 03:58 PM
"If you build it, they will come."

Have patience. Someone will turn up sooner or later who kows this stuff.

malisha
04-28-02, 06:01 PM
I have done a binray tree before in C and Java so your lucked out cuz i didnt get to do one in C++, but what kind of help is it that you need ?

Do u need to know what a binary tree is , how to code in c++ or what cuz its not really clear as to what type of help you want. The other thing is because you have to store objects in there instead of just integers you have to write a comparator class because comparing a person object to another person object cant be done unless the user gives the comparision predicate.

As a starting point though look up binary trees in google.
www.google.com and see how they work. Also if you dont already know who to code in C++ then look up some tutes on that there are a shait load on the net.

And finally it looks like a pretty steep ask for a FIRST programming assigment, there are alot of concepts to learn like recursion which at the start is a bit of a byatch to understand.

Anyway good luck and go hard, programming is fun :)

itchy
04-29-02, 07:48 AM
I'm not exactly sure about if I have understood your assignment but I think it might look something like this:

(This editor won't allow certain character combinations so I put in some spaces where there shouldn't be any.)

template < class T >
class Tree
{
protected:
T data;
Tree< T >* left;
Tree< T >* right;

public:
Tree();
~Tree();

static Tree< T > Create();
static void Destroy(Tree< T >* tree);
bool Find(T element); // recursive
void Print(); // recursive
void Delete(T element); // recursive
void Insert(T element); // recursive
};

Also, your element type T needs key information and operators like <,>,= etc.