CS301 Finalterm Subjective 2013 Solved - 2
CS301 Finalterm Subjective 2013 Solved - 2
CS301 Finalterm Subjective 2013 Solved - 2
Pattren:
Total Questions: 52
Total Marks: 80
Total MCQs: 40 (Each of 1 Mark)
Total Short Questions: 4 (Each of 2 Mark)
Total Short Questions: 4 (Each of 3 Mark)
Total Long Questions: 4 (Each of 5 Mark)
Subjective questions:
Questions of 2 marks
Note: Try to Prepare Mcqz and subjective files of Moaaz brother.
2. For smaller lists, linear insertion sort performs well, but for larger lists, quick sort is
suitable to apply." Justify why?
Answer:
Since for smaller lists number of comparisons and interchange (if needed) decreases
radically in insertion sort than quick sort. For larger lists, opposite occurs in both sorting
techniques.
3. If we want to delete the node from BST which has left and right child then which
rotation is applied?
Answer:
After deleting the node we traverse up the tree from the deleted node checking the
balance of each node at each level up to the root.
2. One tree is given question is it heap or not if it is heap then write its type
Answer: Consult Page no 333-335 Ch:29
Due to the violation, the value of child is less than that of the parent it is not a heap
2. One array is given we require to sort it using bubble sort and write only 2
iterations?
Answer:
Page no: 486
3. One tree is given which not the heap but after minimum changes it becomes max
heap make it?
Answer:
Chapter no 29 page no 335
========================================================================
2. Suppose we have the following representation child nodes and Parent node of the
node D.
Answer:
question is not clear
3. .Consider the following max heap. Add node 24 in it and show the resultant Heap.
Answer:
Page no 337-340 Chapter no 29
4. Give any three characteristics of Union by Weight method
Answer: Page no 408 Chapter no : 36
original array 6 5 3 9 1 2 10 8 -
1 2 3 4 5 6 7 8
Answer:
2(i)=2
2(i)+1=4+1=5
2. Give any three characteristics of Union by Weight method.
Answer: Repeat
1. Here is an array with exactly 15 elements: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15.
Suppose that we are doing a binary search for an element. Indicate any elements
that will be found by examining two or fewer numbers from the array.
Answer:
Quadratic Probing:
Answer: Page no 466 chapter no 42
Linear Probing:
Suppose the hash table of height 7 (index 0 to 6), hash function H (key) = (2 *key + 5)
Mode 7 and pass these numbers [5, 23, 17, 14, 44] from the hash function to resolve
the collision by the linear probing. (5)
Answer:
Mode = 15mode7= 7(2) + 1, in which 1 is the remainder. And this reminder is mode.
H(5)=(2*5+5)mode7=2*5+5=15mode7=1
H(23)= (2*23+5)mode7=2
….so on
An array was given and we have to draw maximum-heap and also show the resultant
array. (5)
1 2 3 4 5
union(4,2)
union(3,1)
union(5,4)
union(5,3)
AnsweR:
Answer:
Q2.
What is heap data structure.Write its types.
Q6.
Let's call the node as "A" that require rebalancig, considered the two cases below
An insertion into left subtree of the left child of A
An insertion into the right subtree of the right child of A
which statement is true in these cases;
Single rotation
Double rotation
Q7
Array is given
3598170264
Draw after 1st iteration of main loop in selection sort algorithm.
AnsweR:
0598173264
Q8
How does heap sort works?
Q9
Suppose we have the following representation for a complete Binary Search Tree, tell
the Left and Right child nodes and Parent node of the node D
A B C D E F G H I J K L M N O P Q R S T …
Answer:
2(i)+1=right node=2*4+1=9=I
2(i)=left node=2*4=8=H
i/2=parent node=4/2=2=B
My Paper:
Q:1 A complete binary tre was given we will have to find out
Left child
Right child
Parent
Answer:
Q:2 Hashing function h(x)= (x*2)%table size the values. Table size=10
1.
2. 11
3.
4.
5.
6.
8.
9.
10.
ANSWER:
Do remaining by yourself.
Q:3 Write a non recursive procedure a pointer to the node of a binary search tree of
integers and a pointer to a new created node which insert the new node as a leaf node
in right place.
Answer:
AnsweR: Repeat
Q:5 A hash function was given and f(h)=keymod12 identify key that may cause
collusion.
36 ,30 ,84
AnsweR:
f(h)=36mod12=12*3+0=0
f(h)=30mod12=12*2+6=6
f(h)=84mod12=12*7+0=0
Q:6 A program was given the function of BST_Fun was asked to write.
1 -1
2 -1
3 -1
4 -1
5 -1
6 -1
7 -1
8 -1
Answer:
1 97
3 61 1 97
4 42 2 76
5 54 3 86
6 59 4 42
7 31 5 54
8 32 6 61
9 17 7 31
10 44 8 32
11 19 9 17
12 10 44
11 19
12 59
Answer:
Image Segmentation
In image segmentation, we will divide the image into different parts. An image may be
segmented with regard to the intensity of the pixels.