Mailam Engineering College: Mailam (Po), Villupuram (DT) - Pin: 604 304 Department of Computer Applications
Mailam Engineering College: Mailam (Po), Villupuram (DT) - Pin: 604 304 Department of Computer Applications
It will have only 6 (ie,5+1) null branches. In general, a binary tree with n nodes has
exactly n+1 null nodes.
3. How many different trees are possible with 10 nodes?
1014
Explanation:
For example, consider a tree with 3 nodes (n=3), it will have the maximum
combination of 5 different (ie, 2 3 3 = 5) trees.
Prepared by
Mrs. A.Subathra Devi
ALGORITHMS LAB
4. There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them
could have formed a full binary tree?
15
In general: There are 2 n 1 nodes in a full binary tree.
Full binary trees contain odd number of nodes. So there cannot be full binary trees
with 8 or 14 nodes, so rejected. With 13 nodes you can form a complete binary tree but not
a full binary tree. So the correct answer is 15.
5. In the given binary tree, using array, at which location can you store the node
4?
Answer: At location 6
Explanation:
Where LCn means Left Child of node n and RCn means Right Child of node n
6. What is Dynamic Programming?
Dynamic Programming is an algorithm design method that can be used when the
solution to a problem can be viewed as the result of a sequence of decisions. An example
for algorithm using dynamic programming is multistage graphs.
7. What are the time complexities for the following algorithms?
Binary search : O(logn)
8. For the following array, find the average number of key comparison made by
binary search in a successful search in the array. (Assume that each key is
searched for with the same probability)
[ 4, 20, 25, 30, 40, 42, 60, 70, 80, 90, 95, 98, 100 ].
Time complexity for binary search = O(log n)
Here n = 13
Average no. of key comparisions = O(log 213)
= log10 13 / log10 2
= 1.114 / 0.301
= 3.7
9. Which is the fastest searching technique?
If the list is in sorted order, Binary search is the fastest searching technique, but if the
list is not in sorted order, Sequential search is the fastest searching technique.
STAFF HANDLING
HOD
PRINCIPAL
Prepared by
Mrs. A.Subathra Devi
ALGORITHMS LAB
6. What is the difference between dynamic programming and divide and conquer?
Prepared by
Mrs. A.Subathra Devi
ALGORITHMS LAB
Dynamic Programming
STAFF HANDLING
HOD
PRINCIPAL
ALGORITHMS LAB
(Approved by AICTE, New Delhi, Affiliated to Anna University, Chennai
& Accredited by National Board of Accreditation (NBA), New Delhi)
[JUN 12]
Merge sort
Quick sort
Tree traversals
Binary search
Matrix multiplication-Strassens algorithm
Prepared by
Mrs. A.Subathra Devi
ALGORITHMS LAB
c00
c01
c10
c11
m1
m2
m3
m4
m5
m6
m7
=
=
=
=
=
=
=
a00
a01
a10
a11
b00
b01
b10
b11
m1+m4-m5+m7
m3+m5
m2+m4
m1+m3-m2+m6
STAFF HANDLING
HOD
PRINCIPAL
Prepared by
Mrs. A.Subathra Devi