C Program to Perform Searching in a BST

This is a C Program to perform searching an element in BST. To search a given key in Bianry Search Tree, we first compare it with root, if the key is present at root, we return root. If key is greater than root’s key, we recur for right subtree of root node. Otherwise we recur … Read more

advertisement

C Program to Implement Splay Tree

This is a C Program to implement Splay tree. Like AVL and Red-Black Trees, Splay tree is also self-balancing BST. The main idea of splay tree is to bring the recently accessed item to root of the tree, this makes the recently searched item to be accessible in O(1) time if accessed again. The idea … Read more

advertisement

C Program to Perform Left and Right Rotation on a Binary Search Tree

This is a C Program to Perform Left and Right Rotation on a Binary Search Tree. These trees are binary search trees in which the height of two siblings are not allowed to differ by more than one. Here is source code of the C Program to Perform Left Rotation on a Binary Search Tree. … Read more

advertisement

C Program to Implement AVL Tree

What is an AVL Tree? The AVL tree in C is a height-balanced binary search tree which means it is also a binary tree that is balanced by the left and right subtree of a node. The tree is said to be balanced when the balance factor of each node is either -1, 0, or … Read more

advertisement

C Program to Implement Ternary Tree

This is a C Program to implement ternary tree. A ternary search tree is a special trie data structure where the child nodes of a standard trie are ordered as a binary search tree. Representation of ternary search trees: Unlike trie(standard) data structure where each node contains 26 pointers for its children, each node in … Read more

advertisement

C Program to Check if Binary Tree is Subtree of Another Tree

This is a C Program program to check whether a binary tree is subtree of another tree. Given two binary trees, check if the first tree is subtree of the second one. A subtree of a tree T is a tree S consisting of a node in T and all of its descendants in T. … Read more

advertisement

C Program to Implement Threaded Binary Tree

This is a C Program to implement threaded binary search tree. A binary tree is threaded by making all right child pointers that would normally be null point to the inorder successor of the node (if it exists) , and all left child pointers that would normally be null point to the inorder predecessor of … Read more

advertisement

C Program to Find the Height of Tree using Recursion

This is a C Program to find the Height of a Tree using Recursion. Problem Description We are given a tree, and we have to write a C program to find out the height of that tree using recursion. We have to create a recursive function which takes in root of the tree as input … Read more

advertisement

C Program to Create Mirror Image of Binary Tree

This is a C Program for creating a mirror image of a Binary Tree using recursion. Problem Description We will be given a Tree and we have to create its mirror image and perform level order traversal on the tree before and after creating its mirror image. Expected Input and Output Case 1. If the … Read more

advertisement

C Program to Find the Lowest Common Ancestor of a Binary Search Tree

This is a C Program to find the Lowest Common Ancestor of a given tree. Problem Description We will be given a Binary Tree and we have to write a C program to find out the Lowest Common Ancestor of the two nodes of same tree taken as input from user. Lowest Common Ancestor: In … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.