CSc 352: Assignment-5: Structures, Union, Lists

Due Wednesday, July 17

The assignment name for turnin is cs352_hw5

Binary Search Trees

a) Modify tree.h file so that the data values can be any one of char, integer, float, or string(char *). (Similar to what we did for the stacks in stack.h, in order to handle different data types.)

b) Write a function insert with the prototype:

void insert(btree *, data_type);

that inserts a node with the given data value into the binary search tree.(Look at the notes for Lecture 15.)

c) Write a function inorder with the prototype:

void inorder(btree);

that does an inorder traversal of the binary tree, and prints out the data values for each node traversed. (Similar to the inorder function we have in traversal.c.)

d) Write a function lookup with the prototype:

btree lookup(btree, data_type);

that searches for a given data value in the bst and returns the pointer to that node if it exists, ow returns NULL.(Look at the notes.)

e) Write a function delete with the prototype:

void delete(btree *, data_type);

that deletes the node with a given data value from the bst.(Look at the notes.)

Put all your functions from parts b-e in a file named bstopers.c