|
Algorithms_in_C
1.0.0
Set of algorithms implemented in C.
|
A basic unbalanced binary search tree implementation in C. More...
#include <stdio.h>#include <stdlib.h>Data Structures | |
| struct | node |
| Node, the basic data structure in the tree. More... | |
Typedefs | |
| typedef struct node | node |
| Node, the basic data structure in the tree. | |
Functions | |
| node * | newNode (int data) |
| The node constructor, which receives the key value input and returns a node pointer. More... | |
| node * | insert (node *root, int data) |
| Insertion procedure, which inserts the input key in a new node in the tree. More... | |
| node * | getMax (node *root) |
| Utilitary procedure to find the greatest key in the left subtree. More... | |
| node * | delete (node *root, int data) |
| Deletion procedure, which searches for the input key in the tree and removes it if present. More... | |
| 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's not in the tree. More... | |
| int | height (node *root) |
| Utilitary procedure to measure the height of the binary tree. More... | |
| void | purge (node *root) |
| Utilitary procedure to free all nodes in a tree. More... | |
| void | inOrder (node *root) |
| Traversal procedure to list the current keys in the tree in order of value (from the left to the right) More... | |
| int | main () |
| Main funcion. | |
A basic unbalanced binary search tree implementation in C.
The implementation has the following functionalities implemented:
Deletion procedure, which searches for the input key in the tree and removes it if present.
| root | pointer to parent node |
| data | value to search for int the node |
| 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's not in the tree.
| root | pointer to parent node |
| data | value to store int he new node |
Utilitary procedure to find the greatest key in the left subtree.
| root | pointer to parent node |
| int height | ( | node * | root | ) |
Utilitary procedure to measure the height of the binary tree.
| root | pointer to parent node |
| data | value to store int he new node |
| void inOrder | ( | node * | root | ) |
Insertion procedure, which inserts the input key in a new node in the tree.
| root | pointer to parent node |
| data | value to store int he new node |
| node* newNode | ( | int | data | ) |
The node constructor, which receives the key value input and returns a node pointer.
| data | data to store in a new node |
| void purge | ( | node * | root | ) |
Utilitary procedure to free all nodes in a tree.
| root | pointer to parent node |