Categories

# Linked List and Binary Tree ISC 2019 Theory

1. A linked list is formed from the objects of the class Node. The class structure of the Node is given below:
``````class Node{
int num;
Node next;
}``````

Write an algorithm or a method to find and display the sum of even integers from an existing linked list.
The method declaration is as follows:
`void sumEvenNode(Node str)`

``````void sumEvenNode(Node str){
int sum = 0;
if(str == null)
System.out.println("Sum = 0");
else{
while(str != null){
if(str.num % 2 == 0)
sum += str.num;
str = str.next;
}
System.out.println("Sum = " + sum);
}``````
2. Answer the following questions from the diagram of a binary tree given below: 1. Write the pre-order traversal of the above tree structure.
A –> E –> G –> I –> C –> H –> B –> D –> F
2. State the size of the tree.
The size of the tree is 4.
3. Name the siblings of the nodes E and G.
Sibling of E is B.
Sibling of G is C.

This site uses Akismet to reduce spam. Learn how your comment data is processed.