-
Notifications
You must be signed in to change notification settings - Fork 0
/
bst.h
63 lines (49 loc) · 1.45 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
#ifndef NAT_BT_BST_BST_H
#define NAT_BT_BST_BST_H
#include "../../record.h"
#include "../bt.h"
/**
* @brief Search for node with record r in (sub)tree with root u
*
* @param u Pointer to node
* @param r Pointer to record
* @param f Pointer to recordsCompare function
* @return B_Node* Pointer to node if found else NULL
*/
B_Node* BST_searchR(B_Node *u, NAT_Record *r, int (*f) (NAT_Record *r1, NAT_Record *r2));
/**
* @brief Search for node with record r in tree t
*
* @param t Pointer to tree
* @param r Pointer to record
* @return B_Node* Pointer to node if found else NULL
*/
B_Node* BST_search(B_Tree *t, NAT_Record *r);
/**
* @brief (Create and) Insert node with record r in (sub)tree with root u.
* Doesn't insert duplicates, instead returns pre-existing node.
*
* @param u Pointer to (sub)tree root
* @param r Pointer to record
* @param f Pointer to recordsCompare function
* @return B_Node*
*/
B_Node* BST_insertR(B_Node *u, NAT_Record *r, int (*f) (NAT_Record *r1, NAT_Record *r2));
/**
* @brief (Create and) Insert node with record r in tree t.
* Doesn't insert duplicates, instead returns pre-existing node.
*
* @param t Pointer to tree
* @param r Pointer to record
* @return B_Node*
*/
void BST_insert(B_Tree *t, NAT_Record *r);
/**
* @brief Delete node with record r from tree t
*
* @param t Pointer to tree
* @param r Pointer to record
* @return B_Node*
*/
B_Node* BST_delete(B_Tree *t, NAT_Record *r);
#endif