C Everything
This is a C repository containing a curated set of generic data structures and algorithm.
tree.h
Go to the documentation of this file.
1 
5 #pragma once
6 #include "common.h"
7 
9 typedef struct tree_node {
11  struct tree_node *lchild;
12  struct tree_node *rchild;
13  int height;
15 
17 typedef enum {
18  eBST,
19  eAVL,
20 } e_treetype;
21 
22 
24 typedef struct tree {
25  // tree info params
26  char *name;
28  int count;
29 
30  // tree root
32 
33  // tree routines
48 
49  // routies for operating on data
55 
57 t_gen create_tree(char *name, e_treetype, t_dparams *prm);
Top level include containg common headers.
data params struct defn
Definition: common.h:18
tree node
Definition: tree.h:9
struct tree_node * rchild
Pointer to node right child.
Definition: tree.h:12
t_gen key
Pointer to node key.
Definition: tree.h:10
int height
height of node
Definition: tree.h:13
struct tree_node * lchild
Pointer to node left child.
Definition: tree.h:11
tree struct defn
Definition: tree.h:24
f_gen min
routine to get minm element in tree
Definition: tree.h:39
f_find find
routine to find element in tree
Definition: tree.h:36
f_cmpr cmpr
Definition: tree.h:50
f_len height
routine to get height of tree
Definition: tree.h:41
f_gen2 pred
routine to get predecessor to given node
Definition: tree.h:37
f_ins insert
routine to insert element in tree
Definition: tree.h:34
f_len node_count
routine to get total nodes in tree
Definition: tree.h:42
f_swap swap
Definition: tree.h:51
f_print print
routine to print tree level by level
Definition: tree.h:46
e_treetype type
Tree Type.
Definition: tree.h:27
char * name
Tree instance name.
Definition: tree.h:26
f_print inorder
routine to print inorder traversal of tree
Definition: tree.h:43
f_gen max
routine to get maxm element in tree
Definition: tree.h:40
f_destroy destroy
routine to destroy the tree instance
Definition: tree.h:47
f_free free
Definition: tree.h:52
f_print preorder
routine to print preorder traversal of tree
Definition: tree.h:44
t_gen root
Root node of the tree.
Definition: tree.h:31
f_print print_data
Definition: tree.h:53
f_gen2 succ
routine to get successor to given node
Definition: tree.h:38
f_del del
routine to delete element in tree
Definition: tree.h:35
int count
Tree node count.
Definition: tree.h:28
f_print postorder
routine to print postorder traversal of tree
Definition: tree.h:45
t_gen create_tree(char *name, e_treetype, t_dparams *prm)
tree interface API
Definition: tree.c:45
struct tree_node t_tree_node
tree node
e_treetype
Types of trees.
Definition: tree.h:17
@ eBST
Binary Search Tree.
Definition: tree.h:18
@ eAVL
AVL Tree.
Definition: tree.h:19
struct tree t_tree
tree struct defn
f_gen2 f_find
fn type of find a elem function
Definition: typedefs.h:60
void(* f_free)(t_gen, char *, int)
Definition: typedefs.h:67
f_vgen f_print
fn type to print function
Definition: typedefs.h:56
f_vgen f_destroy
fn type of destroy function
Definition: typedefs.h:61
e_cmpr(* f_cmpr)(t_gen, t_gen)
Basic operations required for generic data type support.
Definition: typedefs.h:66
t_gen(* f_gen2)(t_gen, t_gen)
fn ptr that takes two gen ptr and return gen ptr
Definition: typedefs.h:47
int(* f_len)(t_gen)
fn type of get len function
Definition: typedefs.h:55
void * t_gen
Base Data type used for all data structure and data elements.
Definition: typedefs.h:41
f_vgen2 f_ins
fn type of insert elem function
Definition: typedefs.h:58
t_gen(* f_gen)(t_gen)
Generic data pointer definitions that are common to most data structure operations.
Definition: typedefs.h:46
f_vgen2 f_swap
Definition: typedefs.h:69
f_gen2 f_del
fn type of delete elem function
Definition: typedefs.h:59