Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

DIVISION OF COMPUTER SCIENCE AND ENGINEERING

SCHOOL OF ENGINEERING

B. TECH DEGREE II INTERNAL EXAMINATION MAY 2022

Semester VI Course Title: 19-202-0603 ANALYSIS AND DESIGN OF ALGORITHMS

Faculty: Mrs Remyamol K M

Time: 2Hrs Max. Marks: 50

CO1: Analyse a given algorithm and express its worst, best and average time and space complexities in
asymptotic notations..
CO5: Design efficient algorithms using Backtracking and Branch and Bound Techniques for solving
problems.
CO6: Familiarize some approximation algorithms and the benefit of using them.
CO7: Classify computational problems into P, NP, NP-Hard and NP-Complete complexity classes.
Part A (Answer All Questions) (5x 4 = 20) PO
I. a. What is meant by amortized analysis.? CO1 1,2,3
b. Discuss the properties of RBT. CO1 1,2,3
c. Differentiate Binomial heap and Fibonacci heap CO1 1,2,3
d. What are approximation algorithms.? CO6 3,10
e Describe about PRAM models.?Give an example. CO6 3,10
Bloom’s taxonomy levels(L1-Remember, L2-Understand, L3-Apply, L4-Analyze L5-Evaluate L6-Create),PO-Program
outcome

Part B (Answer Any Three Questions)


(3 x 10 = 30)
II. Discuss backtracking with an algorithm and example. CO5 3
III. Differentiate P, NP, NP hard and NP complete complexity classes. CO7 4,5
IV. Explain the approximation algorithm for TSP. CO6 3,10
V. Explain the approximation algorithm for Graph coloring. CO6 3,10
L1=37% L2=40% L3=% L4=23% L5= % L6=%

Answer Key
I.
a) Amortized analysis -1 mark
There are three main techniques used for amortized analysis: .( 1 mark each)
 The aggregate method, where the total running time for a se-
quence of operations is analyzed
 The accounting (or banker's) method, where we impose an extra
charge on inexpensive operations and use it to pay for expensive opera-
tions later on.
 The potential (or physicist's) method, in which we derive a po-
tential function characterizing the amount of extra work we can do in
each step. This potential either increases or decreases with each suc-
cessive operation, but cannot be negative.
b) Properties of RBT .( 1 mark each)
A red-black tree must satisfy these properties:
1. The root is always black.
2. A nil is recognized to be black. This factor that every non-NIL node has two
children.
3. Black Children Rule: The children of any red node are black.
4. Black Height Rule: For particular node v, there exists an integer bh (v) such that
specific downward path from v to a nil has correctly bh (v) black real (i.e. non-nil)
nodes. Call this portion the black height of v. We determine the black height of an
RB tree to be the black height of its root.

c)
A binomial tree of order 0 has 1 node only. We can construct a binomial tree of k order by taking
two binomial trees of order k-1 and making one tree as the leftmost child or other. Fibonacci Heap:
Fibonacci heap is a collection of trees that follows the property of min heap or max heap. Fibonacci
heaps can have any shape even if all trees can have a single node. In Fibonacci heaps, we’ll
maintain a pointer to a minimum value i.e. root of the tree.
All tree roots are connected using a circular doubly linked. Therefore, we can access all of them
using a single pointer.
( 1 mark each):

 binomial heaps use a singly linked circular link list and fibonacci heaps use a doubly linked
circular linked list.:
 Data members in a node for binomial heaps are data, link, degree, child. whereas in
fibonacci heaps it is data,parent, childcut, child, link, degree.
 every binomial heaps is a fibonacci heaps but every fibonacci heaps is not a binomial heaps.
 operations delete, decrease key and cascading cut are extra that can be performed in the
fibonacci heaps including those in the binomial heaps. i.e. deletemin, insert.
 deletemin in binomial heaps involves the combining of trees where as deletemin or delete
in fibonacci heaps is performed without joining the trees obtained after deletion.

d) The goal of the approximation algorithm is to come as close as possible to the optimal solution in
polynomial time. Such algorithms are called approximation algorithms or heuristic algorithms.
The features of the Approximation Algorithm as follows. ( 1 mark each):
 An approximation algorithm guarantees to run in polynomial time though it does not
guarantee the most effective solution.
 An approximation algorithm guarantees to seek out high accuracy and top quality
solution(say within 1% of optimum)
 Approximation algorithms are used to get an answer near the (optimal) solution of an
optimization problem in polynomial time

e) PRAM model -2 marks


Example-2 marks
II. Define Backtracking -2
Backtracking algorithm-5 marks
Example -3marks

III. ( 2.5 mark each):


P Class
The P in the P class stands for Polynomial Time. It is the collection of decision
problems(problems with a “yes” or “no” answer) that can be solved by a deterministic
machine in polynomial time.
Features:
1. The solution to P problems is easy to find.
2. P is often a class of computational problems that are solvable and tractable. Tractable
means that the problems can be solved in theory as well as in practice. But the problems
that can be solved in theory but not in practice are known as intractable.
NP Class
The NP in NP class stands for Non-deterministic Polynomial Time. It is the collection of
decision problems that can be solved by a non-deterministic machine in polynomial time.
Features:
1. The solutions of the NP class are hard to find since they are being solved by a non-
deterministic machine but the solutions are easy to verify.
2. Problems of NP can be verified by a Turing machine in polynomial time.
This class contains many problems that one would like to be able to solve effectively:
1. Boolean Satisfiability Problem (SAT).
2. Hamiltonian Path Problem.
3. Graph coloring.
NP-hard class
An NP-hard problem is at least as hard as the hardest problem in NP and it is the class of the
problems such that every problem in NP reduces to NP-hard.
Features:
1. All NP-hard problems are not in NP.
2. It takes a long time to check them. This means if a solution for an NP-hard problem is
given then it takes a long time to check whether it is right or not.
3. A problem A is in NP-hard if, for every problem L in NP, there exists a polynomial-time
reduction from L to A.
Some of the examples of problems in Np-hard are:
1. Halting problem.
2. Qualified Boolean formulas.
3. No Hamiltonian cycle.
NP-complete class
A problem is NP-complete if it is both NP and NP-hard. NP-complete problems are the hard
problems in NP.
Features:
1. NP-complete problems are special as any problem in NP class can be transformed or
reduced into NP-complete problems in polynomial time.
2. If one could solve an NP-complete problem in polynomial time, then one could also
solve any NP problem in polynomial time.
Some example problems include:
1. Decision version of 0/1 Knapsack.
2. Hamiltonian Cycle.
3. Satisfiability.
4. Vertex cover.

IV. Approximation algorithm-7 marks


Example -3marks

V. Define travelling salesman problem-2 marks


Two strategies for TSP
-Nearest neighbor strategy-4marks
-Shortest link strategy -4 marks

You might also like