Search/binarySearchTreeInteger.c File Reference

Task to perform number of binary search operations on a non-balanced binary tree

Receive integers one by one (in sorted order) and create a binary tree which means the tree heavily leans to the right and ultimately forms a linked list. More...

#include <malloc.h>
#include <string.h>
#include "report.h"

Classes

struct  node
 Standard Binary tree data structure to use. More...

Typedefs

typedef node NODE
typedef nodeNODE_PTR

Functions

void construct (int n)
 Method to construct the initial search structure to contain 'sz' elements.
static void insertNode (NODE_PTR node, int value)
 Helper method to populate tree with actual nodes.
void insert (int s)
 Method to insert an integer element into the search structure.
int search (int target, int(*cmp)(const int, const int))
 Method to search for an integer element in the search structure.

Variables

static NODE_PTR root = NULL
 Root of the binary search tree.


Detailed Description

Task to perform number of binary search operations on a non-balanced binary tree

Receive integers one by one (in sorted order) and create a binary tree which means the tree heavily leans to the right and ultimately forms a linked list.

Author:
George Heineman
Date:
6/15/08

Typedef Documentation

typedef struct node NODE

typedef struct node * NODE_PTR


Function Documentation

void construct ( int  n  ) 

Method to construct the initial search structure to contain 'sz' elements.

No work done since binary tree is constructed on the fly via insert(char *) method invocations.

Parameters:
n the total number of elements to be inserted.

void insert ( int  s  ) 

Method to insert an integer element into the search structure.

In our case, we insert the elements into a non-balancing tree.

Parameters:
s Value to be inserted.

static void insertNode ( NODE_PTR  node,
int  value 
) [static]

Helper method to populate tree with actual nodes.

int search ( int  target,
int(*)(const int, const int)  cmp 
)

Method to search for an integer element in the search structure.

Parameters:
target the desired target
cmp the comparison function between two string elements.


Variable Documentation

NODE_PTR root = NULL [static]

Root of the binary search tree.

Algorithm Development Kit 1.0