I am trying to write a program using binary search trees, we have to use binary search trees, that will hopefully show the exact date in 2016 when a user inputs any number (day number) between 1 and 366 (leap year), e.g

``>enter a number: 1Friday the 1st of January!``

I am currently just trying to make the tree and then will get on to mapping the numbers to the dates (not sure how yet), but I don't know how to actually make a tree with 366 integers in it. Ive got structures for a node and functions for creating a new tree and to insert in to the tree etc, but not sure where to go from here. Code below:

``//Binary search tree implementation#include <stdio.h>#include <stdlib.h>//node structurestruct node {int data;struct node* left;struct node* right;} ;//tree wrapper structurestruct tree {struct node *root;} ;typedef struct tree Tree;typedef struct node Node;//create a new treeTree *new_tree() {Tree *t = malloc(sizeof(Tree));t->root = NULL;return t;}//create a new nodeNode* NewNode(int data) {Node* node = malloc(sizeof(Node));node->data = data;node->left = NULL;node->right = NULL;return(node);}//insert in to the binary treeNode* insert(Node* node, int data) {//If the tree is empty, return a new, single nodeif (node == NULL) {return(NewNode(data));}else {// 2. Otherwise, recur down the treeif (data <= node->data) node->left = insert(node->left, data);else node->right = insert(node->right, data);return(node); // return the (unchanged) node pointer}}int main(){return 0;}``

Top