Login
Register
Dark Mode
Brightness
Ambient Glow – Questions list
Register
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged cormen
0
0 votes
0
0 answers
430
430 views
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.heapsi...
akash.dinkar12
430
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
408
408 views
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?
akash.dinkar12
408
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
1
1 vote
0
0 answers
530
530 views
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.
akash.dinkar12
530
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
417
417 views
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...
akash.dinkar12
417
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
771
771 views
Cormen Edition 3 Exercise 6.5 Question 1 (Page No. 164)
HEAP-EXTRACT-MAX(A) 1 if A.heap-size < 1 2 error “heap underflow” 3 max=A 4 A =A[A.heapsize] 5 A.heapsize=A.heapsize-1 6 MAX-HEAPIFY(A,1) 7 return max Illustrate th...
akash.dinkar12
771
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
505
505 views
Cormen Edition 3 Exercise 6.4 Question 5 (Page No. 161)
Show that when all elements are distinct, the best-case running time of HEAPSORT is $\Omega(n\lg\ n)$.
akash.dinkar12
505
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
heap-sort
descriptive
difficult
+
–
0
0 votes
0
0 answers
471
471 views
Cormen Edition 3 Exercise 6.4 Question 4 (Page No. 160)
Show that the worst-case running time of HEAPSORT is $\Omega(n\lg\ n)$.
akash.dinkar12
471
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
heap-sort
descriptive
+
–
0
0 votes
0
0 answers
435
435 views
Cormen Edition 3 Exercise 6.4 Question 3 (Page No. 160)
What is the running time of HEAPSORT on an array $A$ of length $n$ that is already sorted in increasing order? What about decreasing order?
akash.dinkar12
435
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
heap-sort
descriptive
+
–
0
0 votes
0
0 answers
540
540 views
Cormen Edition 3 Exercise 6.4 Question 2 (Page No. 160)
Argue the correctness of HEAPSORT using the following loop invariant:At the start of each iteration of the for loop of lines $2–5$,the subarray $A[1..i]$ is a max-heap co...
akash.dinkar12
540
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
heap-sort
descriptive
+
–
0
0 votes
0
0 answers
525
525 views
Cormen Edition 3 Exercise 6.4 Question 1 (Page No. 160)
HEAPSORT(A) 1 BUILD-MAX-HEAP(A) 2 for i = A.length down to 2 3 exchange A with A[i] 4 A.heapsize=A.heapsize – 1 5 MAX-HEAPIFY(A,1)illustrate the operation of HEAPSORT on...
akash.dinkar12
525
views
asked
Jun 27, 2019
Algorithms
cormen
algorithms
binary-heap
heap-sort
descriptive
+
–
0
0 votes
0
0 answers
391
391 views
Cormen Edition 3 Exercise 6.3 Question 3 (Page No. 159)
Show that there are at most $\lceil n/2^{h+1}\rceil$ nodes of height $h$ in any $n-$element heap.
akash.dinkar12
391
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
377
377 views
Cormen Edition 3 Exercise 6.3 Question 2 (Page No. 159)
Why do we want the loop index $i$ in line $2$ of BUILD-MAX-HEAP to decrease from $\lfloor A.length/2 \rfloor$ to 1 rather than increase from 1 to $\lfloor A.length/2 \rfl...
akash.dinkar12
377
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
698
698 views
Cormen Edition 3 Exercise 6.3 Question 1 (Page No. 159)
BUILD-MAX-HEAP(A) 1 A.heapsize=A.length 2 for i=A.length/2 downto 1 3 MAX-HEAPIFY(A,i)Using Figure $6.3$ as a model, illustrate the operation of BUILD-MAX-HEAP on the arr...
akash.dinkar12
698
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
436
436 views
Cormen Edition 3 Exercise 6.2 Question 6 (Page No. 156)
Show that the worst-case running time of MAX-HEAPIFY on a heap of size $n$ is $\Omega(lg\ n)$.(Hint: For a heap with $n$ nodes, give node values that cause MAXHEAPIFY to ...
akash.dinkar12
436
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
419
419 views
Cormen Edition 3 Exercise 6.2 Question 5 (Page No. 156)
The code for MAX-HEAPIFY is quite efficient in terms of constant factors, except possibly for the recursive call in line 10, which might cause some compilers to produce i...
akash.dinkar12
419
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
295
295 views
Cormen Edition 3 Exercise 6.2 Question 4 (Page No. 156)
What is the effect of calling MAX-HEAPIFY$(A,i)$ for $i A.heapsize/2$.
akash.dinkar12
295
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
297
297 views
Cormen Edition 3 Exercise 6.2 Question 3 (Page No. 156)
What is the effect of calling MAX-HEAPIFY$(A, i)$ when the element $A[i]$ is larger than its children?
akash.dinkar12
297
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
479
479 views
Cormen Edition 3 Exercise 6.2 Question 2 (Page No. 156)
Starting with the procedure MAX-HEAPIFY, write pseudocode for the procedure MIN-HEAPIFY$(A, i )$, which performs the corresponding manipulation on a minheap. How does the...
akash.dinkar12
479
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
0
0 answers
574
574 views
Cormen Edition 3 Exercise 6.2 Question 1 (Page No. 156)
MAX-HEAPIFY(A,i) 1 l=Left(i) 2 r=Right(i) 3 if l <= A.heapsize and A[l] A[i] 4 largest=l 5 else largest = i 6 if r <= A.heapsize and A[r] A[largest] 7 largest=r...
akash.dinkar12
574
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
0 votes
2
2 answers
675
675 views
Cormen Edition 3 Exercise 3.2 Question 3 (Page No. 60)
Prove that $n!=\omega(2^n)$ and $n!=o(n^n)$.
akash.dinkar12
675
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
asymptotic-notations
descriptive
+
–
0
0 votes
0
0 answers
396
396 views
Cormen Edition 3 Exercise 2.4 Question 4 (Page No. 42)
Give an algorithm that determines the number of inversions in any permutation on $n$ elements in $\Theta (n\ lg\ n)$ worst-case time. (Hint: Modify merge sort.)
akash.dinkar12
396
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
algorithm-design-techniques
inversion
descriptive
+
–
0
0 votes
0
0 answers
281
281 views
Cormen Edition 3 Exercise 2.4 Question 3 (Page No. 42)
What is the relationship between the running time of insertion sort and the number of inversions in the input array? Justify your answer.
akash.dinkar12
281
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
inversion
descriptive
+
–
0
0 votes
1
1 answer
600
600 views
Cormen Edition 3 Exercise 2.4 Question 2 (Page No. 42)
What array with elements from the set $\{1,2,\dots n\}$ has the most inversions? How many does it have?
akash.dinkar12
600
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
inversion
descriptive
+
–
0
0 votes
1
1 answer
455
455 views
Cormen Edition 3 Exercise 2.4 Question 1 (Page No. 41)
List the five inversions of the array $\langle 2,3,8,6,1\rangle$
akash.dinkar12
455
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
inversion
descriptive
+
–
0
0 votes
1
1 answer
893
893 views
Cormen Edition 3 Exercise 2.3 Question 3 (Page No. 39)
Use mathematical induction to show that when $n$ is an exact power of $2$, the solution of the recurrence$T(n) = \begin{cases} 2 \text{, if n=2, } ...
akash.dinkar12
893
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
recurrence-relation
time-complexity
descriptive
+
–
0
0 votes
1
1 answer
584
584 views
Cormen Edition 3 Exercise 2.3 Question 7 (Page No. 39)
Describe a $\Theta(n\ lg\ n)$ time algorithm that, given a set $S$ of $n$ integers and another integer $x$, determines whether or not there exist two elements in $S$ whos...
akash.dinkar12
584
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
algorithm-design-techniques
descriptive
difficult
+
–
0
0 votes
1
1 answer
1.2k
1.2k views
Cormen Edition 3 Exercise 2.3 Question 6 (Page No. 39)
Observe that the while loop of the INSERTION-SORT procedure uses a linear search to scan (backward) through the sorted subarray $A[i\dots j-1]$ Can we use a binary search...
akash.dinkar12
1.2k
views
asked
Jun 26, 2019
Algorithms
algorithms
cormen
searching
descriptive
+
–
0
0 votes
0
0 answers
503
503 views
Cormen Edition 3 Exercise 2.3 Question 5 (Page No. 39)
Referring back to the searching problem (see Exercise 2.1-3), observe that if the sequence $A$ is sorted, we can check the midpoint of the sequence against $v$ and elimin...
akash.dinkar12
503
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
searching
descriptive
+
–
0
0 votes
1
1 answer
708
708 views
Cormen Edition 3 Exercise 2.3 Question 4 (Page No. 38)
We can express the insertion sort as a recursive procedure as follows.In order to sort $A[1\dots n]$, we recursively sort $A[1 \dots n-1]$ and then insert $A[n]$ into the...
akash.dinkar12
708
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
sorting
time-complexity
descriptive
+
–
0
0 votes
0
0 answers
786
786 views
Cormen Edition 3 Exercise 2.3 Question 2 (Page No. 37)
Rewrite the MERGE procedure so that it does not use sentinels, instead of stopping once either array $L$ or $R$ has had all its elements copied back to $A$ and then copyi...
akash.dinkar12
786
views
asked
Jun 26, 2019
Algorithms
cormen
algorithms
sorting
merge-sort
descriptive
+
–
Page:
« prev
1
2
3
4
5
6
7
next »