(i) A linked list is formed from the objects of the class given below
  class Node
  {
  double sal; 
  Node next;
  }
  Write an Algorithm OR a Method to add a node at the end of an existing linked list. The method declaration is as follows:
  void addNode(Node ptr, double ss)
  (ii) Answer the following questions from the diagram of a Binary Tree given below:
  
  (a) Write the pre-order traversal of the above tree structure.
  (b) Name the parent of the nodes D and B.
  (c) State the level of nodes E and F when the root is at level 0.


Solution



void addNode(Node ptr,double ss)
  
{
   Node t=new Node();
   t.sal=ss;
while(ptr.next!=null)
{
   ptr=ptr.next;
}
ptr.next=t;
}
(b) A,F,D,G,B,A,E
D=F and B=A
E=3 and F=1


Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com