Graph and tree basics terminologies


Vitex/Virtices :
Nodes of Graph/Tree

Edge: 
Connecting path/line between two Nodes/Vitex

Graph:
Series of Interconnected nodes with edges.


Tree: 

Tree is a graph where there is one one path to reach a node.
Just line tree, once a branch is created, you can not reach that branch's leafs via any other path.


Leaf nodes: 
The last nodes in a tree, which doesn't have any further child. just like leafs of a tree.


Below are types of trees 







Graph programming question:

1. Find number of leaf nodes if given Binary tree ? or Graph

Ans :

In BFS, while iterating the list of child's, just check of child doen't have any left of right child, then add it to a list of leafs, and finally print the size of leaf list.


2. create an AVL tree

3. Perform insertion in a complete Binary tree.

4. Binary search





Comments

Popular posts from this blog