Algorithms_in_C
1.0.0
Set of algorithms implemented in C.
|
11 #define MAXELEMENTS 1000
23 void *elements[MAXELEMENTS];
26 int number_of_elements;
42 int add_item_label(
Dictionary *,
char label[],
void *);
48 int add_item_index(
Dictionary *,
int index,
void *);
void delete_bt(node **root, int ele)
deletion of a node from the tree if the node isn't present in the tree, it takes no action.
Definition: threaded_binary_trees.c:173
int main()
Main funcion.
Definition: binary_search_tree.c:249
void minimum(const void *a, const void *b, void *c)
Utility for test A function compare for minimum between two integers This function is used as combine...
Definition: segment_tree.c:194
Definition: prime_factoriziation.c:25
Node, the basic data structure in the tree.
Definition: binary_search_tree.c:15
void inOrder(node *root)
Traversal procedure to list the current keys in the tree in order of value (from the left to the righ...
Definition: binary_search_tree.c:238
void segment_tree_update(segment_tree *tree, size_t index, void *val)
For point updates This function updates the element at given index and also updates segment tree acco...
Definition: segment_tree.c:79
int data
data of the node
Definition: binary_search_tree.c:18
node * newNode(int data)
The node constructor, which receives the key value input and returns a node pointer.
Definition: binary_search_tree.c:28
int data
stores the number
Definition: threaded_binary_trees.c:28
struct Node * rlink
link to right child
Definition: threaded_binary_trees.c:30
Node, the basic data structure of the tree.
Definition: threaded_binary_trees.c:27
void(* combine_function)(const void *a, const void *b, void *result)
Function that combines two data to generate a new one The name of function might be misleading actual...
Definition: segment_tree.c:33
int main()
Driver code.
Definition: client.c:70
void * root
the root of formed segment tree
Definition: segment_tree.c:40
int main()
Main Function.
Definition: segment_tree.c:231
void * identity
identity element for combine function
Definition: segment_tree.c:41
combine_function combine
the function to be used to combine two node's data to form parent's data
Definition: segment_tree.c:47
void postorder_display(node *curr)
performs postorder traversal param[in] curr node pointer to the topmost node of the tree
Definition: threaded_binary_trees.c:143
struct Node node
Node, the basic data structure of the tree.
void search(node *root, int ele)
searches for the element
Definition: threaded_binary_trees.c:98
int find(node *root, int data)
Search procedure, which looks for the input key in the tree and returns 1 if it's present or 0 if it'...
Definition: binary_search_tree.c:152
static void test()
Test RMQ Testing Segment tree using Range Minimum Queries.
Definition: segment_tree.c:205
node * getMax(node *root)
Utilitary procedure to find the greatest key in the left subtree.
Definition: binary_search_tree.c:72
struct Node * llink
link to left child
Definition: threaded_binary_trees.c:29
void preorder_display(node *curr)
performs preorder traversal param[in] curr node pointer to the topmost node of the tree
Definition: threaded_binary_trees.c:157
#define max(a, b)
shorthand for maximum value
Definition: kohonen_som_topology.c:39
segment_tree * segment_tree_init(void *arr, size_t elem_size, size_t len, void *identity, combine_function func)
Initializes Segment Tree Accquires memory for segment tree and fill the leaves of segment tree with d...
Definition: segment_tree.c:140
struct node * left
left child
Definition: binary_search_tree.c:16
void inorder_display(node *curr)
performs inorder traversal param[in] curr node pointer to the topmost node of the tree
Definition: threaded_binary_trees.c:129
void segment_tree_dispose(segment_tree *tree)
Dispose Segment Tree Frees all heap memory accquired by segment tree.
Definition: segment_tree.c:162
void func(int sockfd)
Continuous loop to send and receive over the socket.
Definition: client.c:37
void segment_tree_build(segment_tree *tree)
Builds a Segment tree It is assumed that leaves of tree already contains data.
Definition: segment_tree.c:55
struct node node
Node, the basic data structure in the tree.
node * insert(node *root, int data)
Insertion procedure, which inserts the input key in a new node in the tree.
Definition: binary_search_tree.c:46
node * create_node(int data)
creates a new node param[in] data value to be inserted
Definition: threaded_binary_trees.c:38
void segment_tree_query(segment_tree *tree, long long l, long long r, void *res)
Query the segment tree This function helps in range query of segment tree This function assumes that ...
Definition: segment_tree.c:105
void segment_tree_print_int(segment_tree *tree)
Prints the data in segment tree The data should be of int type A utility to print segment tree with d...
Definition: segment_tree.c:175
void insert_bt(node **root, int data)
inserts a node into the tree param[in,out] root pointer to node pointer to the topmost node of the tr...
Definition: threaded_binary_trees.c:51
size_t elem_size
size in bytes of each data element
Definition: segment_tree.c:42
size_t length
total size of array which segment tree represents
Definition: segment_tree.c:43
This structures holds all the data that is required by a segment tree.
Definition: segment_tree.c:39
int height(node *root)
Utilitary procedure to measure the height of the binary tree.
Definition: binary_search_tree.c:187
struct node * right
right child
Definition: binary_search_tree.c:17
void purge(node *root)
Utilitary procedure to free all nodes in a tree.
Definition: binary_search_tree.c:217
struct segment_tree segment_tree
This structures holds all the data that is required by a segment tree.
int main()
main function
Definition: threaded_binary_trees.c:255