-
Notifications
You must be signed in to change notification settings - Fork 0
/
BST.h
61 lines (43 loc) · 1.43 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
/*
* COMP2521 - Data Structures and Algorithms
* Assignment 2 - Simple Search Engines
*
* Group: TwoBrothers
*
* Partners: Kurt Banwell-Pachernegg (Z5022859)
* Sam Eager (Z3414861)
*
* An AVL Tree ADT that compares values based on the provided compare
* function at creation time.
*/
#ifndef BST_H
#define BST_H
#include <stdlib.h>
#include <stdio.h>
#include "Queue.h"
typedef struct BST * BST;
BST newBST(int (*compare)(void * a, void * b));
// Time complexity: O(log(n))
int addBST(BST tree, void * value); // Add value to BST
// Time complexity: O(log(n)))
void * removeBST(BST tree, void * value); // Remove value from BST
// Time complexity: O(log(n))
void * getBST(BST tree, void * value); // Returns value if it exits
// Time complexity: O(log(n))
int existsBST(BST tree, void * value); // Check if value exists in BST
// Time complexity: O(n)
void printBST(BST tree); // Print entire BST
// Time complexity: O(1)
int sizeBST(BST tree); // Number of nodes in BST
// Time complexity: O(1)
int emptyBST(BST tree); // Check if BST is empty
// Time complexity: O(1)
void * rootBST(BST tree);
// Time complexity: O(log(n))
void * maxBST(BST tree); // Maximum value in BST
// Time complexity: O(log(n))
void * minBST(BST tree); // Minimum value in BST
// Time complexity: O(n)
Queue getQueueBST(BST tree);
void freeBST(BST tree);
#endif