GithubHelp home page GithubHelp logo

binary-tree-using-c's Introduction

Binary Tree

A binary tree is defined as finite set of elements called nodes such that the tree contains a distinguished node called root of the tree and the remaining nodes form a ordered pair of disjoint binary tree T1 T2

Every node contain atmost 2 child
The degree of binary tree highest possible is 2

In short binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child.

Traversal of binary tree

Pre-order

  1. Check if the current node is empty or null.
  2. Display the data part of the root (or current node).
  3. Traverse the left subtree by recursively calling the pre-order function.
  4. Traverse the right subtree by recursively calling the pre-order function.


Pre-order: F, B, A, D, C, E, G, I, H

In-order

  1. Check if the current node is empty or null.
  2. Traverse the left subtree by recursively calling the in-order function.
  3. Display the data part of the root (or current node).
  4. Traverse the right subtree by recursively calling the in-order function.


In-order: A, B, C, D, E, F, G, H, I

In a binary search tree, in-order traversal retrieves data in sorted order

Post-order

  1. Check if the current node is empty or null.
  2. Traverse the left subtree by recursively calling the post-order function.
  3. Traverse the right subtree by recursively calling the post-order function.
  4. Display the data part of the root (or current node).


Post-order: A, C, E, D, B, H, I, G, F

binary-tree-using-c's People

Contributors

ilavisharma avatar

Stargazers

 avatar Anil Kumar S avatar Aromal S avatar

Watchers

James Cloos avatar

Forkers

jakarinsint

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.