Saturday, 8 April 2017

Binary Trees

A tree is called binary tree if each node has zero child, one child or two children.

Structure Of Binary Tree


Operations on Binary Trees 

Basic Operations : Binary Tree ADT
  • Inserting an element into a tree 
  • Deleting an element from a tree 
  • Searching for an element 
  • Traversing the tree

Auxiliary Operations 
  • Finding the size of the tree 
  • Finding the height of the tree 
  • Finding the level which has maximum sum 
  • Finding the least common ancestor (LCA) for a given pair of nodes, and many more.

Problems:


  • Problem1 : Find Maximum Element in Binary Tree Using Recursion - See Link Time Complexity: O( n). Space Complexity: O( n).
  • Problem2 : Find the maximum element from the Binary tree withour Recusrsion by using Queue - See Link Time Complexity: O( n). Space Complexity: O( n).
  • Problem3 : Print level order traversal in reverse order - See Link Time Complexity: O( n). Space Complexity: O( n).
  • Problem4 : Give an algorithm for finding the height (or depth) of the binary tree. See Link Time Complexity: O( n). Space Complexity: O( n).
  • Problem5 : Give an algorithm for deleting the tree. See Link Time Complexity: O( n). Space Complexity: O( n).
  • Problem6 : Give an Algorithm to find the number of leave nodes and full nodes in BT. See Link.  Time Complexity: O( n). Space Complexity: O( n).



No comments:

Post a Comment

Array

Program for Array Rotation 1st Method - Using temp array  - Time complexity - O(n), Space - O(d) See algo and code 2nd Method - rotate...