Thanks, Mark.
#include <stdio.h>
#include <stdlib.h>
typedef struct TreeNode
{
int item; // The data in this node.
struct TreeNode *left; // Pointer to the left subtree.
struct TreeNode *right; // Pointer to the right subtree.
}TreeNode;
TreeNode *root = NULL;
struct TreeNode *insertion(int data)
{
root = (struct TreeNode*)malloc(sizeof(struct TreeNode));
TreeNode *current = root;
if(current == NULL)
{
current->item = data;
current->left = NULL;
current->right = NULL;
}
}
void print(struct TreeNode *node)
{
if(node == NULL)
{
return;
}
print(node->left);
printf("%d ",node->item);
print(node->right);
}
void menu()
{
int temp = 1;
while(temp == 1)
{
//Prints out the Menu
int i;
printf("");
printf("*** Binary Tree Assignment ***\n");
printf("Press 'i' to insert an element into the hash table\n");
printf("Press 'd' to delete an element from the hash table\n");
printf("Press 'l' to look up an element in the hash table\n");
printf("Press 's' to obtain the size of the table\n");
printf("Press 'p' to print the current table\n");
printf("Press 'e' to exit from the program\n");
printf("Enter a choice:\n");
char input;
scanf("%c", &input); //Getting user input for there selection
switch(input)
{
//Insertion
case 'i': printf("Type the integer you wish to enter into the hashTable:\n");
scanf("%d", &i);
insertion(5);
break;
//Deletion
case 'd': printf("Type the integer you wish to delete from the hashTable:\n");
scanf("%d", &i);
break;
//Size
case 's':
break;
//Print
case 'p': print(root);
break;
//Exit
case 'e': temp = 0;
break;
//If incorrect selection is made
default: printf("Error: Wrong selection, choose again\n");
break;
}
}
}
int main()
{
menu();
return 0;
}

New Topic/Question
Reply



MultiQuote





|