
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![Consider the following algorithm, which may be called on an array that is not necessarily sorted.
and returns the array in sorted form.
GoofySort (A) :
if (len (A) <= 3): SelectionSort(A)
else:
[len(A)/3]
+ GoofySort (A[1:2t])
GoofySort (A[t+1:n]) //sort the back 2/3rds
+ GoofySort (A[1:2t])
Let t +
A[1:2t]
//sort the front 2/3rds
A[t+1:n]
A[1:2t]
//sort the front 2/3rds
(a) Write a recurrence which captures the runtime of this algorithm. Your recurrence should
be of the form T (n) =?. You can ignore any non-recursive operations (i.e. you only need to
focus on operations in the last three lines). You do not need to handle base cases here. You
can assumen is divisible by 3 for convenience.
(b) Solve your recurrence using the substitution method. Show your work. You may assume a
base case of T (1) = 1. State what the big-0 runtime is for this algorithm (hint: it should be a
polynomial written in the form nº).](https://content.bartleby.com/qna-images/question/095f44ba-d1fe-4c35-9931-1f02ef37ab83/7925db66-8a19-4e78-8bb8-b364a73f90d2/wnnj0fu_thumbnail.jpeg)
Transcribed Image Text:Consider the following algorithm, which may be called on an array that is not necessarily sorted.
and returns the array in sorted form.
GoofySort (A) :
if (len (A) <= 3): SelectionSort(A)
else:
[len(A)/3]
+ GoofySort (A[1:2t])
GoofySort (A[t+1:n]) //sort the back 2/3rds
+ GoofySort (A[1:2t])
Let t +
A[1:2t]
//sort the front 2/3rds
A[t+1:n]
A[1:2t]
//sort the front 2/3rds
(a) Write a recurrence which captures the runtime of this algorithm. Your recurrence should
be of the form T (n) =?. You can ignore any non-recursive operations (i.e. you only need to
focus on operations in the last three lines). You do not need to handle base cases here. You
can assumen is divisible by 3 for convenience.
(b) Solve your recurrence using the substitution method. Show your work. You may assume a
base case of T (1) = 1. State what the big-0 runtime is for this algorithm (hint: it should be a
polynomial written in the form nº).
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- The contents of the array below represent a BST (Binary Search Tree). What would be the contents of the array after 30 is deleted. Briefly explain how 30 would be deleted. Use an X to represent any empty spots in the array. 30 2050 10 25 40 60arrow_forwardJava: Consider the following algorithm for searching in an unsorted array. If the size of the array is 1, then check if it contains the element to be searched. Otherwise, divide the array into two halves, and recursively search both halves. Which of (a)–(c) is false? The running time of this algorithm is O(N) The actual running time of this algorithm is likely to be better than sequential search. This is an example of a divide‐and‐conquer algorithm all of the above are true none of the above is truearrow_forwardLet A = [n, n − 1, n − 2, . . . , 3, 2, 1] be an array where the first n positive integers are listed in decreasing order. Determine whether Heapsort or Quicksort sorts this array faster.For this question, assume the Quicksort pivot is always the right-most element.arrow_forward
- PYTHON: Please provide a screenshot of your code in Python. Thank you!arrow_forward15. Consider the problem of finding the first position in which an array b occurs as a subsequence of an array a. Write two nested loops: let result undefined for (let i = 0; i < a.length - b.length; i++) { for (let j = 0; j < b.length; j++) { if (a[i+j] = b[j]) . . . } } Complete with labeled break and continue statements.arrow_forwardBackground for Question 14-20: Below is a bubble sort program that sorts the elements in an array. static void bubbleSort(int[] arr) { int n = arr.length; int temp = 0; for (int i = 0; i < n; i++) { for (int j = 1; j < (n - i); j++) { if (arr[j - 1] > arr[j]) { temp = arr[j - 1]; arr[j - 1] = arr[j]; arr[j] = temp; } } } } Based on the program above, please draw a control flow graph for it. In your control flow graph, what are the test requirements for edge coverage? List test path(s) that achieves the edge coverage. Provide test cases for each test path you list in the previous question. If it is not possible to find the test input for certain test path, describe the reason. In your control flow graph, what are the test requirements for…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education