2.1-2 For sorting in Non increasing order
INSERTION-SORT(A)
for j 2 to length[A]
do key A[j]
Insert A[j] into the sorted
sequence A[1 _ j - 1].
ij-1
while i > 0 and A[i] < key
do A[i + 1] A[i]
ii-1
A[
Chapter 7 Quiz Solution
1.
2.
3.
4.
O(n^2)
C
B
Because in randomized algorithm, worst-case occurs very rarely and we are not
interested in that, so every time pivot number would be random so there are
Chapter 4
Answer 1 When sub problem becomes small enough that we no longer recurse it ,
then the recursion is bottoms out.
Answer 2 Different method of solving recursion are as follow:Substitution , R
CS 312 Fall 15
Name:
CIN:
Quiz 1
1. Define an algorithm
(1 mark)
Informally, an algorithm is any well-defined computational procedure that takes
some value, or set of values, as input and produces som
Chapter 5
1. (i) Define Indicator Random Variable.
Answer
(ii) Using Indicator Random Variable, show the expected number of tails after flipping a fair coin
one time. Clearly state your assumptions an