0% found this document useful (0 votes)
11 views

Algorithm design questions

Algorithm design questions

Uploaded by

himanshujhaa4262
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Algorithm design questions

Algorithm design questions

Uploaded by

himanshujhaa4262
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DAA Assignment 1 :

Topic: RecurrenceStable matching, Asymptotic notation, Linear and Binary search,


Bubble sort, selection sort, insertion sort, Amortized analysis based on aggregate,
potential and accounting methods

Topic: Stable Matching

Q. No Question

1. Show that the deferred acceptance always terminates with a stable assignment.

2. Q.1 Which pair is unstable in the matching { A–X, B–Z, C–Y } ?

3. Decide whether you think the following statement is true or false. If it is


true, give a short explanation. If it is false, give a counterexample.

True or false? In every instance of the Stable Matching Problem, there is a


stable matching containing a pair (m, w) such that m is ranked first on the
preference list of w and w is ranked first on the preference list of m.

Topic: Recurrence

Q. No Question

1.

2.

3.

5. Find a recurrence relation for the number of ternary strings of length n that do
not contain two consecu-
tive 0s.

Topic: Asymptotic notation

Q. No Question

1 Determine the Big-O estimate for the function:


f(x)=(x+1) log(x2+1)+3x2

2.

3. Express the function n3 / 1000 + 100n2 - 100n + 3 in terms of Ө notation.

Topic: Linear and Binary search

Q. No Question

1 List all the steps used to search for 9 in the sequence 1,3, 4, 5, 6, 8, 9, 11 using
a) linear search b) binary search

2.

3. Describe how the number of comparisons used in the


worst case changes when these algorithms are used to
search for an element of a list when the size of the list
doubles from n to 2n, where n is a positive integer.

a) linear search
b) binary search

4. Sort these lists using the selection sort.


a) 3, 5, 4, 1, 2
b) 5, 4, 3, 2, 1

5. Use the insertion sort to put the elements of the list 3, 2, 4, 1, 5 in increasing
order.

6 What is the average-case computational complexity of the linear search algorithm,


if the probability that the element for which we search is in the list is 1/3 and it is
equally likely that this element is any of the n elements in the list?
Topic: Bubble sort, selection sort, insertion sort,

Q. No Question

1. a. Use the bubble sort to sort 3, 1, 5, 7, 4, showing the lists obtained at each
step.
b. Use the insertion sort to sort 6, 2, 3, 1, 5, 4, showing the lists obtained at
each step
c. How many comparisons does the insertion sort use to sort the list 1, 2,…,
n?

2. Use the bubble sort algorithm to sort the list 5, 2, 4,1, 3.

3. How can you modify any sorting algorithm to have a good best-case running
time?

Topic: Amortized analysis based on Aggregate Method

Q. No Question

1 a. What is the total cost of executing n of the stack operations PUSH, POP,
and MULTIPOP, assuming that the stack begins with s0 objects and
finishes with sn objects?
b. Suppose we perform a sequence of n operations on a data structure in
which the ith operation costs i if i is an exact power of 2, and 1 otherwise.
Use aggregate analysis to determine the amortized cost per operation

Topic: Amortized analysis based on Potential Method

Q. No Question

1. What is the total cost of executing n of the stack operations PUSH, POP, and
MULTIPOP, assuming that the stack begins with s0 objects and ûnishes with sn
objects?

2. Use Potential method of analysis to determine the amortized cost per operation
for a sequence of n operations on a data structure in which the ith operation
costs i if i is an exact
power of 2, and 1 otherwise.

Topic: Amortized analysis based on Accounting

Q. No Question

1. Use accounting method of analysis to determine the amortized cost per


operation for a sequence of n operations on a data structure in which the ith
operation costs i if i is an exact
power of 2, and 1 otherwise.
2. Suppose we perform a sequence of stack operations on a stack whose size
never exceeds k. After every k operations, we make a copy of the entire stack for
backup purposes. Show that the cost of n stack operations, including copying
the stack, is O(n) by assigning suitable amortized costs to the various stack
operations.

You might also like