Binary Search Tree

April 24, 2009 at 14:15:07
Specs: Windows XP
I want to create a BST(binary search tree) using a fixed array sequence. I'm not able to add nodes to the tree.


CODE:

#include<stdio.h>

int N = 7;
int bst[8];

int array[8] = {-1,10,8,4,9,15,11,20};// fixed sequence

void addBST(int root,int newNode);

int main()
{

for(int i = 1;i<=8;i++)//initialize bst array
bst[i] = -1;

for(int i = 1;i<=N;i++)//add nodes to bst one by one from array
{
addBST(1,array[i]);

}
printf("BST Array Sequence:");
for(int i =1;i<=N;i++)
printf("%d ",bst[i]);

printf("\n");

}

void addBST(int root,int newNode)
{
dunno how to start this section
}



See More: Binary Search Tree

Report •


#1
April 26, 2009 at 04:26:57

Report •
Related Solutions


Ask Question