Skip to content

ritam-student/java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is my complete Data Structure and Algorithm repository.

Binary Tree : It is a Hierarchial data structure composed of nodes , where each node has atmost 2 children refffered to as left and right child.

Level and depth starts from 0 and last till leaf node(node that doesn't have any child).

               1                Level : 1 , depth : 1
              / \
             2   3              Level : 2 , depth : 2
            / \   \
           4   5   6            Level : 3 , depth : 3
          / \       \
         7   8       9          Level : 4 , depth : 4

Here leaf nodes are 7,8,5,9 | children of 4 : 7,8 | parent of 6 : 3 | subtree of 2 : left subtree(4,7,8) , right subtree(5) Ancester of 8 : 4,2,1

Tree traversal :

  1. Preorder Traversal : Print root.data -> go to the left subtree -> right subtree (use recursion)
  2. inorder Traversal : go to the left subtree -> Print root.data -> right subtree (use recursion)
  3. postorder Traversal : go to the left subtree -> right subtree -> Print root.data (use recursion)
  4. levelorder Traversal : go to each level -> add data in queue -> remove data from queue and Print data (traverse iteratively)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages