Algorithms_in_C  1.0.0
Set of algorithms implemented in C.
dict.h
1 /*
2  author: Christian Bender
3  public interface for the dictionary.
4 
5  The dictionary prepares space for 1000 elements.
6 */
7 
8 #ifndef __DICT__H
9 #define __DICT__H
10 
11 #define MAXELEMENTS 1000
12 
13 /*
14  special data type called 'Dictionary'
15  for generic use
16 */
17 typedef struct Dict
18 {
19  /*
20  void* array for generic use of the dictionary.
21  there actual saves the entries.
22  */
23  void *elements[MAXELEMENTS];
24 
25  /* contains the number of elements in this dictionary */
26  int number_of_elements;
27 
28 } Dictionary;
29 
30 /*
31  create_dict: is a simple constructor for creating
32  a dictionary and setting up the
33  member field 'number_of_elements'
34  and prepares the inner array 'elements'
35 */
36 Dictionary *create_dict(void);
37 
38 /*
39  add_item_label: adds item (void*) to the dictionary at given label
40  returns 0 if adding was sucessful otherwise -1
41 */
42 int add_item_label(Dictionary *, char label[], void *);
43 
44 /*
45  add_item_index: adds item (void*) to the dictionary at given index (int)
46  returns 0 if adding was sucessful otherwise -1
47 */
48 int add_item_index(Dictionary *, int index, void *);
49 
50 /*
51  get_element: returns the element at given label
52 */
53 void *get_element_label(Dictionary *, char[]);
54 
55 /*
56  get_element: returns the element at given index
57 */
58 void *get_element_index(Dictionary *, int);
59 
60 /*
61  simple destrcutor function
62 */
63 void destroy(Dictionary *);
64 
65 #endif
delete_bt
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
data
Definition: prime_factoriziation.c:25
node
Kyler Smith, 2017 Stack data structure implementation.
Definition: binary_search_tree.c:14
AVLnode
Definition: avl.c:5
Node::data
int data
stores the number
Definition: threaded_binary_trees.c:28
Node::rlink
struct Node * rlink
link to right child
Definition: threaded_binary_trees.c:30
Node
Node, the basic data structure of the tree.
Definition: threaded_binary_trees.c:27
Dict
Definition: dict.h:18
postorder_display
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
find
int find(int *p, int x)
Find index of or value in an array.
Definition: union_find.c:17
node
struct Node node
Node, the basic data structure of the tree.
search
void search(node *root, int ele)
searches for the element
Definition: threaded_binary_trees.c:98
Node::llink
struct Node * llink
link to left child
Definition: threaded_binary_trees.c:29
preorder_display
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
max
#define max(a, b)
shorthand for maximum value
Definition: kohonen_som_topology.c:39
main
int main(int argc, char **argv)
the main function take one argument of type char* example : .
Definition: c_atoi_str_to_integer.c:72
CArray
Definition: carray.h:32
inorder_display
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
create_node
node * create_node(int data)
creates a new node param[in] data value to be inserted
Definition: threaded_binary_trees.c:38
insert_bt
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
main
int main()
main function
Definition: threaded_binary_trees.c:255