
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
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.)](https://content.bartleby.com/qna-images/question/cb038966-3b12-4dbc-9d6f-80b13d0e9e13/620d6bdd-52dd-465c-8a3d-b62a5e24041d/a761qs8_thumbnail.jpeg)
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

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 nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
Similar questions
- Coding in Python, we have the function to perform this task, V col_Hdeg whichinputs the adjacency matrix A of the graph and initializes the array vert_color s tohold vertex colors. It then calculates the degree of each vertex and stores it in thearray degrees.The while loop iterates until all vertices are colored and at each iteration, thevertex v with the highest degree is colored. The array temp is used to find the currentcolors of the neighbors of vertex v and an unused smallest color is determined aftersorting this array.arrow_forwardGiven two sorted arrays, write a function to merge them into a single sorted array. What is the time complexity of your solution?arrow_forwardWrite a loop in assembly that increments each element of array x as defined in the previous problem. The size of the array (6) may be hard-coded. Previous Problem array: x dq 43,12,13,53,-1,21arrow_forward
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

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