Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged descriptive
0
votes
0
answers
1201
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 \rfloor$?
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
240
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
1202
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 array $A=\langle 5,3,17,10,84,19,6,22,9 \rangle $
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
549
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
1203
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 be called recursively at every node on a simple path from the root down to a leaf).
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
260
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
1204
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 inefficient code. Write an efficient MAX-HEAPIFY that uses an iterative control construct (a loop) instead of recursion.
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
297
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
1205
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$.
What is the effect of calling MAX-HEAPIFY$(A,i)$ for $i A.heapsize/2$.
akash.dinkar12
182
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
1206
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?
What is the effect of calling MAX-HEAPIFY$(A, i)$ when the element $A[i]$ is larger than its children?
akash.dinkar12
175
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
1207
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 running time of MIN-HEAPIFY compare to that of MAXHEAPIFY?
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
333
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
0
answers
1208
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 8 if largest!=i 9 exchange A[i] with A[ ... model, illustrate the operation of MAX-HEAPIFY(A,3) on the array $A=\langle 27,17,3,16,13,10, 1,5,7,12,4,8,9,0 \rangle$
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
406
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
binary-heap
descriptive
+
–
0
votes
2
answers
1209
Cormen Edition 3 Exercise 3.2 Question 3 (Page No. 60)
Prove that $n!=\omega(2^n)$ and $n!=o(n^n)$.
Prove that $n!=\omega(2^n)$ and $n!=o(n^n)$.
akash.dinkar12
376
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
asymptotic-notation
descriptive
+
–
0
votes
0
answers
1210
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.)
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
219
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
algorithm-design-technique
inversion
descriptive
+
–
0
votes
0
answers
1211
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.
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
160
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
inversion
descriptive
+
–
0
votes
1
answer
1212
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?
What array with elements from the set $\{1,2,\dots n\}$ has the most inversions? How many does it have?
akash.dinkar12
331
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
inversion
descriptive
+
–
0
votes
1
answer
1213
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$
List the five inversions of the array $\langle 2,3,8,6,1\rangle$
akash.dinkar12
244
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
inversion
descriptive
+
–
0
votes
1
answer
1214
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, } \\2T(n/2)+n \text{, if n=$2^k$,for k >1} \end{cases}$ is $T(n) = n\ lg\ n$.
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
614
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
recurrence-relation
time-complexity
descriptive
+
–
0
votes
1
answer
1215
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$ whose sum is exactly $x$.
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
374
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
algorithm-design-technique
descriptive
difficult
+
–
0
votes
1
answer
1216
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 (see Exercise 2.3-5) instead to improve the overall worst-case running time of insertion sort to $\Theta(n\ lg\ n)$?
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
826
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
algorithms
cormen
searching
descriptive
+
–
0
votes
0
answers
1217
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 eliminate half of the sequence from further consideration. The binary ... recursive, for binary search. Argue that the worst-case running time of binary search is $\Theta (lg\ n)$.
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
352
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
searching
descriptive
+
–
0
votes
1
answer
1218
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 sorted array $A[1 \dots n-1]$. Write a recurrence for the running time of this recursive version of insertion sort.
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
509
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
sorting
time-complexity
descriptive
+
–
0
votes
0
answers
1219
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 copying the remainder of the other array back into $A$.
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
606
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
sorting
merge-sort
descriptive
+
–
1
votes
1
answer
1220
Cormen Edition 3 Exercise 2.3 Question 1 (Page No. 37)
Using Figure $2.4$ as a model, illustrate the operation of merge sort on the array $A=\langle 3,41,52,26,38,57,9,49 \rangle $
Using Figure $2.4$ as a model, illustrate the operation of merge sort on the array $A=\langle 3,41,52,26,38,57,9,49 \rangle $
akash.dinkar12
1.8k
views
akash.dinkar12
asked
Jun 26, 2019
Algorithms
cormen
algorithms
sorting
merge-sort
descriptive
+
–
0
votes
1
answer
1221
Cormen Edition 3 Exercise 2.2 Question 4 (Page No. 29)
How can we modify almost any algorithm to have a good best-case running time?
How can we modify almost any algorithm to have a good best-case running time?
akash.dinkar12
436
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
cormen
algorithms
time-complexity
descriptive
+
–
0
votes
1
answer
1222
Cormen Edition 3 Exercise 2.2 Question 3 (Page No. 29)
Consider the linear search again (see Exercise 2.1-3). How many elements of the input sequence need to be checked on the average, assuming that the element being searched for is equally likely to be any element in the array? ... case? What are the average-case and worst-case running times of linear search in -notation? Justify your answers.
Consider the linear search again (see Exercise 2.1-3). How many elements of the input sequence need to be checked on the average, assuming that the element being searched...
akash.dinkar12
3.5k
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
cormen
algorithms
searching
descriptive
+
–
0
votes
1
answer
1223
Cormen Edition 3 Exercise 2.2 Question 2 (Page No. 29)
Consider sorting $n$ numbers stored in an array $A$ by first finding the smallest element of $A$ and exchanging it with the element in $A[1]$. Then find the second smallest element of $A$ ... , rather than for all n elements? Give the best-case and worst-case running times of selection sort in $\Theta$-notation
Consider sorting $n$ numbers stored in an array $A$ by first finding the smallest element of $A$ and exchanging it with the element in $A $. Then find the second smallest...
akash.dinkar12
3.7k
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
algorithms
cormen
time-complexity
descriptive
+
–
0
votes
2
answers
1224
Cormen Edition 3 Exercise 2.2 Question 1 (Page No. 29)
Express the function $n^3/1000 -100n^2-100n+3$ in terms of $\Theta$ notation.
Express the function $n^3/1000 -100n^2-100n+3$ in terms of $\Theta$ notation.
akash.dinkar12
2.1k
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
cormen
algorithms
time-complexity
descriptive
+
–
0
votes
1
answer
1225
Cormen Edition 3 Exercise 2.1 Question 4 (Page No. 22-23)
Consider the problem of adding two $n$-bit binary integers, stored in two $n$-element arrays $A$ and $B$.The sum of the two integers should be stored in binary form in an $(n+1)$-element array $C$. State the problem formally and write pseudocode for adding the two integers.
Consider the problem of adding two $n$-bit binary integers, stored in two $n$-element arrays $A$ and $B$.The sum of the two integers should be stored in binary form in an...
akash.dinkar12
1.7k
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
cormen
algorithms
descriptive
+
–
0
votes
0
answers
1226
Cormen Edition 3 Exercise 2.1 Question 3 (Page No. 22)
Consider the searching problem: Input: A sequence of $n$ numbers $A = \langle a_1, a_2,\dots a_n \rangle$ and a value $v$ Output: An index $i$ such that $v=A[i]$ or the special value NIL if $v$ does ... $v$. Using a loop invariant, prove that your algorithm is correct. Make sure that your loop invariant fulfills the three necessary properties.
Consider the searching problem:Input: A sequence of $n$ numbers $A = \langle a_1, a_2,\dots a_n \rangle$ and a value $v$ Output: An index $i$ such that $v=A[i]$ or the s...
akash.dinkar12
438
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
cormen
algorithms
searching
descriptive
+
–
0
votes
1
answer
1227
Cormen Edition 3 Exercise 2.1 Question 2 (Page No. 22)
Rewrite the INSERTION-SORT procedure to sort into non-increasing instead of non-decreasing order.
Rewrite the INSERTION-SORT procedure to sort into non-increasing instead of non-decreasing order.
akash.dinkar12
773
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
cormen
algorithms
sorting
descriptive
+
–
0
votes
1
answer
1228
Cormen Edition 3 Exercise 2.1 Question 1 (Page No. 22)
Using Figure 2.2 as a model, illustrate the operation of INSERTION-SORT on the array $ A =( 31, 41, 59, 26, 41, 58)$
Using Figure 2.2 as a model, illustrate the operation of INSERTION-SORT on the array $ A =( 31, 41, 59, 26, 41, 58)$
akash.dinkar12
644
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
cormen
algorithms
descriptive
+
–
0
votes
0
answers
1229
Cormen Edition 3 Exercise 1.2 Question 3 (Page No. 14)
What is the smallest value of $n$ such that an algorithm whose running time is $100n^2$ runs faster than an algorithm whose running time is $2^n$ on the same machine?
What is the smallest value of $n$ such that an algorithm whose running time is $100n^2$ runs faster than an algorithm whose running time is $2^n$ on the same machine?
akash.dinkar12
394
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
cormen
algorithms
descriptive
+
–
0
votes
0
answers
1230
Cormen Edition 3 Exercise 1.2 Question 2 (Page No. 14)
Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size $n$, insertion sort runs in $8n^2$ steps, while merge sort runs in $64\ n \lg n$ steps. For which values of $n$ does insertion sort beat merge sort?
Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size $n$, insertion sort runs in $8n^2$ steps, while merge so...
akash.dinkar12
634
views
akash.dinkar12
asked
Jun 25, 2019
Algorithms
cormen
algorithms
descriptive
+
–
Page:
« prev
1
...
36
37
38
39
40
41
42
43
44
45
46
...
91
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register