Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Filter
Profile
Wall
Recent activity
All questions
All answers
Exams Taken
All Blogs
Questions by akash.dinkar12
0
votes
1
answer
41
Cormen Edition 3 Exercise 7.3 Question 2 (Page No. 180)
RANDOMIZED-QUICKSORT(A, p, r) 1 if p < r 2 q = RANDOMIZED-PARTITION(A, p, r) 3 RANDOMIZED-QUICKSORT(A, p, q - 1) 4 RANDOMIZED-QUICKSORT(A, q + 1, r) RANDOMIZED-PARTITION(A, p, r) 1 i = RANDOM(p, r) 2 ... made to the random number generator RANDOM in the worst case? How about in the best case? Give your answer in terms of $\Theta$ notation.
RANDOMIZED-QUICKSORT(A, p, r) 1 if p < r 2 q = RANDOMIZED-PARTITION(A, p, r) 3 RANDOMIZED-QUICKSORT(A, p, q – 1) 4 RANDOMIZED-QUICKSORT(A, q + 1, r) RANDOMIZED-PARTITIO...
500
views
asked
Jun 28, 2019
Algorithms
cormen
algorithms
quick-sort
descriptive
+
–
0
votes
1
answer
42
Cormen Edition 3 Exercise 7.3 Question 1 (Page No. 180)
Why do we analyze the expected running time of a randomized algorithm and not its worst-case running time?
Why do we analyze the expected running time of a randomized algorithm and not its worst-case running time?
353
views
asked
Jun 28, 2019
Algorithms
cormen
algorithms
quick-sort
descriptive
+
–
1
votes
1
answer
43
Cormen Edition 3 Exercise 7.2 Question 6 (Page No. 179)
Argue that for any constant $0<\alpha\leq 1/2$, the probability is approximately $1-2\alpha$ that on a random input array, PARTITION produces a split more balanced than $1-\alpha$ to $\alpha$.
Argue that for any constant $0<\alpha\leq 1/2$, the probability is approximately $1-2\alpha$ that on a random input array, PARTITION produces a split more balanced than $...
424
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
quick-sort
descriptive
difficult
+
–
0
votes
0
answers
44
Cormen Edition 3 Exercise 7.2 Question 5 (Page No. 178)
Suppose that the splits at every level of quicksort are in the proportion $1-\alpha$ to $\alpha$, where $0<\alpha\leq1/2$ is a constant. Show that the minimum depth of a leaf in the recursion tree is approximately $-lg\ n /lg\ \alpha$ and the maximum depth is approximately $-lg\ n / lg\ (1-\alpha)$.(Don’t worry about integer round-off.)
Suppose that the splits at every level of quicksort are in the proportion $1-\alpha$ to $\alpha$, where $0<\alpha\leq1/2$ is a constant. Show that the minimum depth of a ...
331
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
quick-sort
descriptive
+
–
0
votes
0
answers
45
Cormen Edition 3 Exercise 7.2 Question 4 (Page No. 178)
Banks often record transactions on an account in order of the times of the transactions, but many people like to receive their bank statements with checks listed in order by check number. People usually write checks in order ... -sorted input. Argue that the procedure INSERTION-SORT would tend to beat the procedure QUICKSORT on this problem.
Banks often record transactions on an account in order of the times of the transactions, but many people like to receive their bank statements with checks listed in order...
506
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
sorting
quick-sort
descriptive
+
–
0
votes
1
answer
46
Cormen Edition 3 Exercise 7.2 Question 3 (Page No. 178)
Show that the running time of QUICKSORT is $\Theta(n^2)$ when the array $A$ contains distinct elements and is sorted in decreasing order.
Show that the running time of QUICKSORT is $\Theta(n^2)$ when the array $A$ contains distinct elements and is sorted in decreasing order.
1.1k
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
quick-sort
time-complexity
descriptive
+
–
1
votes
2
answers
47
Cormen Edition 3 Exercise 7.2 Question 2 (Page No. 178)
What is the running time of QUICKSORT when all elements of the array $A$ have the same value?
What is the running time of QUICKSORT when all elements of the array $A$ have the same value?
536
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
quick-sort
time-complexity
descriptive
+
–
0
votes
1
answer
48
Cormen Edition 3 Exercise 7.2 Question 1 (Page No. 178)
Use the substitution method to prove that the recurrence $T(n)=T(n-1) + \Theta(n)$ has the solution $T(n) =\Theta(n^2)$.
Use the substitution method to prove that the recurrence $T(n)=T(n-1) + \Theta(n)$ has the solution $T(n) =\Theta(n^2)$.
301
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
recurrence-relation
descriptive
+
–
0
votes
1
answer
49
Cormen Edition 3 Exercise 7.1 Question 4 (Page No. 174)
QUICKSORT(A,p,r) 1 if p < r 2 q = PARTITION(A,p,r) 3 QUICKSORT(A, p , q-1) 4 QUICKSORT(A, q + 1, r) How would you modify QUICKSORT to sort into nonincreasing order?
QUICKSORT(A,p,r) 1 if p < r 2 q = PARTITION(A,p,r) 3 QUICKSORT(A, p , q-1) 4 QUICKSORT(A, q + 1, r)How would you modify QUICKSORT to sort into nonincreasing order?
933
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
quick-sort
descriptive
+
–
0
votes
1
answer
50
Cormen Edition 3 Exercise 7.1 Question 3 (Page No. 174)
Give a brief argument that the running time of PARTITION on a subarray of size $n$ is $\Theta(n)$.
Give a brief argument that the running time of PARTITION on a subarray of size $n$ is $\Theta(n)$.
1.5k
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
quick-sort
descriptive
+
–
0
votes
1
answer
51
Cormen Edition 3 Exercise 7.1 Question 2 (Page No. 174)
What value of $q$ does PARTITION return when all elements in the array $A[p..r]$ have the same value? Modify PARTITION so that $q=\lfloor(p+r)/2 \rfloor$ when all elements in the array $A[p..r]$ have the same value.
What value of $q$ does PARTITION return when all elements in the array $A[p..r]$ have the same value? Modify PARTITION so that $q=\lfloor(p+r)/2 \rfloor$ when all element...
1.7k
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
sorting
quick-sort
descriptive
+
–
0
votes
1
answer
52
Cormen Edition 3 Exercise 7.1 Question 1 (Page No. 173)
PARTITION(A,p,r) 1 x = A[r] 2 i = p – 1 3 for j = p to r – 1 4 if A[j] <= x 5 i = i + 1 6 exchange A[i] with A[j] 7 exchange A[i+1] with A[r] 8 return i + 1 illustrate the operation of PARTITION on the array $A=\langle 13,19,9,5,12,8,7,4,21,2,6,11\rangle$
PARTITION(A,p,r) 1 x = A[r] 2 i = p – 1 3 for j = p to r – 1 4 if A[j] <= x 5 i = i + 1 6 exchange A[i] with A[j] 7 exchange A[i+1] with A[r] 8 return i + 1 illustrat...
1.5k
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
sorting
quick-sort
descriptive
+
–
0
votes
0
answers
53
Cormen Edition 3 Exercise 6.5 Question 9 (Page No. 166)
Give an $O(n\lg\ k)$- time algorithm to merge $k$ sorted lists into one sorted list, where $n$ is the total number of elements in all the input lists. (Hint: Use a minheap for $k$-way merging.)
Give an $O(n\lg\ k)$- time algorithm to merge $k$ sorted lists into one sorted list, where $n$ is the total number of elements in all the input lists. (Hint: Use a minhea...
315
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
1
answer
54
Cormen Edition 3 Exercise 6.5 Question 8 (Page No. 166)
The operation HEAP-DELETE$(A, i)$ deletes the item in node $i$ from heap $A$. Give an implementation of HEAP-DELETE that runs in $O(lg\ n)$ time for an $n-$element max-heap.
The operation HEAP-DELETE$(A, i)$ deletes the item in node $i$ from heap $A$. Give an implementation of HEAP-DELETE that runs in $O(lg\ n)$ time for an $n-$element max-h...
529
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
55
Cormen Edition 3 Exercise 6.5 Question 7 (Page No. 166)
Show how to implement a first-in, first-out queue with a priority queue. Show how to implement a stack with a priority queue.
Show how to implement a first-in, first-out queue with a priority queue. Show how to implement a stack with a priority queue.
372
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
priority-queue
descriptive
+
–
0
votes
0
answers
56
Cormen Edition 3 Exercise 6.5 Question 6 (Page No. 166)
Each exchange operation on line $5$ of HEAP-INCREASE-KEY typically requires three assignments. Show how to use the idea of the inner loop of INSERTION-SORT to reduce the three assignments down to just one assignment.
Each exchange operation on line $5$ of HEAP-INCREASE-KEY typically requires three assignments. Show how to use the idea of the inner loop of INSERTION-SORT to reduce the ...
262
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
57
Cormen Edition 3 Exercise 6.5 Question 5 (Page No. 166)
Argue the correctness of HEAP-INCREASE-KEY using the following loop invariant: At the start of each iteration of the while loop of lines $4-6$, the subarray $A[1..A.heapsize]$ satisfies the max-heap property, except that there ... assume that the subarray $A[a..heapsize]$ satisfies the max-heap property at the time HEAP-INCREASE-KEY is called.
Argue the correctness of HEAP-INCREASE-KEY using the following loop invariant:At the start of each iteration of the while loop of lines $4–6$, the subarray $A[1..A.heap...
279
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
58
Cormen Edition 3 Exercise 6.5 Question 4 (Page No. 165)
Why do we bother setting the key of the inserted node to $-\infty$ in line $2$ of MAX-HEAP-INSERT when the next thing we do is increase its key to the desired value?
Why do we bother setting the key of the inserted node to $-\infty$ in line $2$ of MAX-HEAP-INSERT when the next thing we do is increase its key to the desired value?
280
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
1
votes
0
answers
59
Cormen Edition 3 Exercise 6.5 Question 3 (Page No. 165)
Write pseudo code for the procedures HEAP-MINIMUM, HEAP-EXTRACT-MIN, HEAP-DECREASE-KEY, and MIN-HEAP-INSERT that implement a min-priority queue with a min-heap.
Write pseudo code for the procedures HEAP-MINIMUM, HEAP-EXTRACT-MIN, HEAP-DECREASE-KEY, and MIN-HEAP-INSERT that implement a min-priority queue with a min-heap.
362
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
60
Cormen Edition 3 Exercise 6.5 Question 2 (Page No. 165)
HEAP-INCREASE-KEY(A,i,key) 1 if key < A[i] 2 error new key is smaller than current key 3 A[i] = key 4 while i > 1 and A[parent(i)] < A[i] 5 exchange A[i] with A[parent(i)] 6 i=parent(i) MAX-HEAP-INSERT(A,key) 1 A ... ,key) Illustrate the operation of MAX-HEAP-INSERT$(A,10)$ on the heap $A=\langle 15,13,9,5,12,8,7,4,0,6,2,1 \rangle$.
HEAP-INCREASE-KEY(A,i,key) 1 if key < A[i] 2 error “new key is smaller than current key” 3 A[i] = key 4 while i 1 and A[parent(i)] < A[i] 5 exchange A[i] with A[pare...
291
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
Page:
« prev
1
2
3
4
5
6
7
8
...
28
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register