It102 ST 1
It102 ST 1
•• l~ ••
•• i.'nI: ••
••••••
§LIIJr
••••••
~•••• p:
_ITI02-Software Technology-l
I Duration: 3 Hours I
Instructions to Candidates:
• This paper has FOUR questions. Answer All Questions.
• Total Marks 100.
• This paper contains 6 pages with the cover pag .
30/03/2016
00123
a) A stack object A has the stack frame A and a stack object B has the stac frame B as shown
in figure 1. Draw the stack frames after executing the below operations. (5 marks)
B.push (A.pop ());
B.push (A.pop ());
B.push(A.peek());
if (A. Ls Emp t y () )
. A.push('Z');
else
J3. push ( 'Z' ) ;
Top -7 E
D
G
figure 1
b) Following numbers are added to a circular queue in the given order. Ifth values are retrieved
from from the queue in what order will they appear? (2 marks)
2 5 7 1 6 2
c) Consider the constructor of a stack class called myStack given below an answer the
questions.
myStack: :myStack()
{
maxSize = 10;
top = -1;
stArray = new int[maxSize];
iv) Is it possible to store 10 real numbers in this stack? Justify y ur answer. (2 marks)
Page 1 of 5
30/03/2016
00123
d) A doctor can consult 15 patients per day in a hospital. Patients should take an appointment
number according to the order they visit the hospital.
i) Suggest a data structure to maintain the appointment numbers. J stify your answer.
(4 marks)
ii) Implement the class definition for the above data structure. Add the required methods
and attributes. The class should have a method called getAppointmentO to get the
new appointment no. (4 marks)
iii) Implement the method getAppointmentO to get an appointment umber for the
doctor. This method should store the appointment numbers in th order they are made
and should return the newest appointment number. (4 marks)
b) Merge the following two arrays. (Draw all the steps, indicating whic values are compared
at each step ) ( 4 marks)
o 1 2 3 4 o 1 2
c) Show all steRs taken to sort the following words in the alphabetical rder using selection
sort method. ( 3 marks)
d) Write the Bubble Sort method to sort the above 20 character array i reverse alphabetical
order ( z to a). ( 5 marks)
Page 2 of 5
30/03/2016
00123
ii) How do you calculate the index of the middle element of a array when you are
given the top and the bottom indices ?
iii) Can we use the Binary Search Method to search for a value in the Linked List?
Why?
iv)' What is the pre-condition that should be satisfied before applying Binary Search
in an Array?
1\
~
f) Write the "Binary Search" Method in a recursive manner. (5 marks)
r
Question 03 (25 marks)
L1 --.j,-_10
__ L2 -1_5__ L3 ---.1~20__
i) Draw the link list after executing the following statements. (4 marks)
L2->next Ll;
Ll->next = L3;
L3->next = NULL;
first = L2;
ii) Write statements to remove L2 link from the above linked I st. (2 marks)
Page 3 of 5
30/03/2016
00123
iii) Implement displayNameListO method of the Link list class. The isplayNameListO
method displays the names of all the links in the link list. (4 marks)
2) Call appropriate methods and create the following link list (3 marks)
first --1 H
.
200
Menaka
207
Roshan
H 300
Suml
i) What is the! advantage of using a Tree data structure to store data? (2 marks)
ii) What are the rules applied in a Binary Search Tree when storing d ta in to the Tree?
(2 marks)
iii) State two applications where Trees can be used to store data? (2 marks)
Page 4 of 5
30/03/2016
00123
ii) What are the types of Nodes you need to consider when del ting a node from a
Binary Search Tree? (2 mark)
iii) How do you find the number of Nodes in a Complete Binary Tree? ( 1 mark)
iv) Explain the following types of Binary Trees with examples. (3 marks)
b)
92 100 56 89 45 63 94 105
t ii) Print the Nodes in the above Tree according to the Post Order traversal method.
(2 marks)
iii) What should you do to make the above Tree a Complete Tree? ( 1 mark)
d) Do the following operations into above Tree ( in part c ). Show how the Tree changes
after each step is done. ( 4 marks)
i) insert ('G');
ii) delete ('I');
iii) insert ('S');
iv) delete ('K');
30/03/2016