-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbst.h
89 lines (70 loc) · 1.77 KB
/
bst.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef BST_H_
#define BST_H_
/* A node structure for use with the
* binary search tree.
*/
typedef struct bst_node {
char * data;
struct bst_node * right;
struct bst_node * left;
} bst_node ;
/* Adds a value to the binary search tree.
* Parameters:
* root - the pointer to the root of the tree
* Return value:
* none
*/
void add ( bst_node ** root, char * word );
/* Prints the values stored in the bst to standard output according to
* the inorder traversal. The values should be separated
* by a single space.
* Parameters:
* root - the root of the tree
* Return value:
* none
*/
void inorder ( bst_node * root ) ;
/* Removes the node with the smallest value
* in the tree.
* Parameters:
* root - the pointer to the root of the tree
* Return value:
* the string from the removed node or
* NULL if no node was removed.
*/
char * removeSmallest ( bst_node ** root );
/* Removes the node with the largest value
* in the tree.
* Parameters:
* root - the pointer to the root of the tree
* Return value:
* the string from the removed node or
* NULL if no node was removed.
*/
char * removeLargest ( bst_node ** root );
///////////////////////////////////
// Add other declarations below. //
///////////////////////////////////
//bst_node *addRecurse(bst_node **root, char *word, bst_node *node);
/* creates a new node.
* Parameter:
* data - the data for the new node
* Return:
* new node
*/
bst_node * newNode(char * data);
/* finds smallest node
* Parameter:
* root - the pointer to the root of the tree
* Return:
* smallest node
*/
bst_node *smallest(bst_node *root);
/* finds largest node
* Parameter:
* root - the pointer to the root of the tree
* Return:
* largest node
*/
bst_node *largest(bst_node *root);
#endif