The greatest mistake you can make in life is to be continually fearing you will make one

Saturday 20 February 2010

Problems based on Tree

Problem 1:
List out some of the application of tree data structure?
  1. Manipulation of Arithmetic expression
  2. Symbol Table construction
  3. Syntax analysis
Problem 2
In a tree construction which is the suitable efficient data structures?
(a) Array
(b) Linked list
(c) Stack
(d) Queue
(e) None

(b) Linked list

Problem 3 
How many different trees are possible with 10 nodes?
In general If there are n nodes then there exist 2n-n different trees
here n=10
so 210-10==>1024-10=1014
So there are 1014 different possible trees available.

Problem 4
How many differnt trees are possible with 3 nodes and show the possible trees?
here n=3
So a tree with 3 nodes have the maximum combination of 5 different trees.
The different possible trees are shown below

Problem 5
Consider the tree shown in figure

  1. Which node is the root node?
  2. Which nodes are Leaves?
  3. What is the depth of the tree?
  4. What is the degree of the tree?
  5. For each node in the tree
          (A) Name the parent node
          (B) List the children
          (C) List the siblings
          (D) Compute the depth
          (E) Compute the height