Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
This file is a simple implementation of a Threaded Binary Tree. More...
#include <stdio.h>
#include <stdlib.h>
Data Structures | |
struct | Node |
Node, the basic data structure of the tree. More... | |
Typedefs | |
typedef struct Node | node |
Node, the basic data structure of the tree. | |
Functions | |
node * | create_node (int data) |
creates a new node param[in] data value to be inserted | |
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 tree param[in] data value to be inserted into the tree | |
void | search (node *root, int ele) |
searches for the element | |
void | inorder_display (node *curr) |
performs inorder traversal param[in] curr node pointer to the topmost node of the tree | |
void | postorder_display (node *curr) |
performs postorder traversal param[in] curr node pointer to the topmost node of the tree | |
void | preorder_display (node *curr) |
performs preorder traversal param[in] curr node pointer to the topmost node of the tree | |
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. | |
int | main () |
main function | |
This file is a simple implementation of a Threaded Binary Tree.
Threaded Binary Tree is a binary tree variant in which all left child pointers that are NULL (in Linked list representation) point to its in-order predecessor, and all right child pointers that are NULL (in Linked list representation) point to its in-order successor. It has the following functionalities:
-see binary_search_tree.c
node * create_node | ( | int | data | ) |
creates a new node param[in] data value to be inserted
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.
param[in,out] root pointer to node pointer to the topmost node of the tree param[in] ele value to be deleted from the tree
void inorder_display | ( | node * | curr | ) |
performs inorder traversal param[in] curr node pointer to the topmost node of the tree
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 tree param[in] data value to be inserted into the tree
int main | ( | void | ) |
main function
void postorder_display | ( | node * | curr | ) |
performs postorder traversal param[in] curr node pointer to the topmost node of the tree
void preorder_display | ( | node * | curr | ) |
performs preorder traversal param[in] curr node pointer to the topmost node of the tree
void search | ( | node * | root, |
int | ele | ||
) |
searches for the element
[in] | root | node pointer to the topmost node of the tree |
[in] | ele | value searched for |