Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question
Problem 1.
Describe an algorithm that sorts an input array A[1 · . · n] by calling a subroutine
(a)
SQRTSORT (k), which sorts the subarray A[k+1...k+ vn] in place, given an arbitrary integer
k between 0 and n
Vn as input. (To simplify the problem, assume that n is an integer.)
Your algorithm is only allowed to inspect or modify the input array by calling SQRTSORT; in
particular, your algorithm must not directly compare, move or copy array elements. How
many times does your algorithm call SQRTSORT in the worst case? Give pseudocode. Remem-
ber that you cannot use anything other than calling the SQRTSORT routine and maybe some
loops. No formal proof of correctness is mandatory. But write a few sentences justifying
your approach.
Prove that your algorithm from part (a) is optimal up to constant factors. In
(b)
other words, if f(n) is the number of times your algorithm calls SQRTSORT, prove that no
algorithm can sort using o(f(n)) calls to SQRTSORT. Note that here we are assum
these algorithms cannot do anything other than calling SQRTSORT repeatedly.
that
(Hint: Think of a typical worst case example for any sorting algorithm)
Now suppose SQRTSORT is implemented recursively, by calling your sorting algo-
(c)
rithm from part (a). For example, at the second level of recursion, the algorithm is sorting
arrays roughly of size n'/4. What is the worst-case running time of the resulting sorting
algorithm? (To simplify the analysis, assume that the array size n has the form 22"), so that
repeated square roots are always integers.)
expand button
Transcribed Image Text:Problem 1. Describe an algorithm that sorts an input array A[1 · . · n] by calling a subroutine (a) SQRTSORT (k), which sorts the subarray A[k+1...k+ vn] in place, given an arbitrary integer k between 0 and n Vn as input. (To simplify the problem, assume that n is an integer.) Your algorithm is only allowed to inspect or modify the input array by calling SQRTSORT; in particular, your algorithm must not directly compare, move or copy array elements. How many times does your algorithm call SQRTSORT in the worst case? Give pseudocode. Remem- ber that you cannot use anything other than calling the SQRTSORT routine and maybe some loops. No formal proof of correctness is mandatory. But write a few sentences justifying your approach. Prove that your algorithm from part (a) is optimal up to constant factors. In (b) other words, if f(n) is the number of times your algorithm calls SQRTSORT, prove that no algorithm can sort using o(f(n)) calls to SQRTSORT. Note that here we are assum these algorithms cannot do anything other than calling SQRTSORT repeatedly. that (Hint: Think of a typical worst case example for any sorting algorithm) Now suppose SQRTSORT is implemented recursively, by calling your sorting algo- (c) rithm from part (a). For example, at the second level of recursion, the algorithm is sorting arrays roughly of size n'/4. What is the worst-case running time of the resulting sorting algorithm? (To simplify the analysis, assume that the array size n has the form 22"), so that repeated square roots are always integers.)
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY