Algorithm design questions
Algorithm design questions
Q. No Question
1. Show that the deferred acceptance always terminates with a stable assignment.
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.
Q. No Question
2.
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.
a) linear search
b) binary search
5. Use the insertion sort to put the elements of the list 3, 2, 4, 1, 5 in increasing
order.
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?
3. How can you modify any sorting algorithm to have a good best-case running
time?
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
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.
Q. No Question