Data Structure and Algorithm Exam
Data Structure and Algorithm Exam
2
(a) What is algorithm?
(b) The three basic control structures in virtually every procedural language are, List and
explain them.
(c) Write the algorithm and draw a flow chat to select the only male from list of 20
students.
4 (a) Write the meaning and the Six (6) Variations/Classes of linked list.
(b) In Linked list, explain the following terms. (i) Node (ii) Pointer (iii) Head (iv) null
(c) Explain the following program and write the possible result that will be visible on the
screen.
int main(void)
{
List list;
list.InsertNode(7.0); // successful
list.InsertNode(5.0); // successful
list.InsertNode(6.0); // successful
list.InsertNode(4.0); // successful
// print all the elements
list.DisplayList();
if(list.FindNode(5.0) > 0) cout << "5.0 found" << endl;
else cout << "5.0 not found" << endl;
if(list.FindNode(4.5) > 0) cout << "4.5 found" << endl;
else cout << "4.5 not found" << endl;
list.DeleteNode(7.0);
list.DisplayList();
return 0;
}
5 (a) What is stack?
(b) Explain the Two basic operation in Stack
(c) What does LIFO stands for?
(d) Using array, fill up the value of queue and show the position of front and rear for each
statement.
1. I am going to execute this code with THREE pushes and ONE pop:
2. IntStack s = new IntStack( );
3. s.push(1);
4. s.push(2);
5. s.push(3);
6. System.out.println(s.pop( ));
Suppose that s is represented by a partially filled array. Draw the state of the private
instance variables of s after the above code:
_______ __________________________________
manyItems| | data| | | | | |
|_______| |______|______|______|______|______|...
[0] [1] [2] [3] [4]
9 (a) Explain the binary Tree and write the four (4) Classifications of Binary Tree
(b) Explain the Following Terms;
• Node:
• Edges:
• Parent Node:
• Grand Parent:
• Child Node:
• Root Node:
• Leaf Node:
• Level:
• Height:
• Degree of Node:
• Siblings:
• Left Child:
• Right child:
• Left Sub tree:
• Right Sub tree: