Problem 1. (a) Describe an algorithm that sorts an input array A[1... n] by calling a subroutine 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 Vn is an integer.) Your algorithm is only allowed to inspect or modify the input array by calling SQRISORT; 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 assuming that these algorithms cannot do anything other than calling SQRTSORT repeatedly. (Hint: Think of a typical worst case example for any sorting algorithm) (c) Now suppose SQRTSORT is implemented recursively, by calling your sorting algo- 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.)
Problem 1. (a) Describe an algorithm that sorts an input array A[1... n] by calling a subroutine 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 Vn is an integer.) Your algorithm is only allowed to inspect or modify the input array by calling SQRISORT; 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 assuming that these algorithms cannot do anything other than calling SQRTSORT repeatedly. (Hint: Think of a typical worst case example for any sorting algorithm) (c) Now suppose SQRTSORT is implemented recursively, by calling your sorting algo- 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.)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY