
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
![Q3 QuickSort
Given the QuickSort implementation from class, provide an 18-element list that will take the
least number of recursive calls of QuickSort to complete.
As a counter-example, here is a list that will cause QuickSort to make the MOST number of
recursive calls:
public static List<Integer> input() {
return Accaxsaslist(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
wwwwwww
And here's the QuickSort algorithm, for convenience:
algorithm QuickSart
Input: lists of integers 1st of size N
Output: new list with the elements of lat in sorted order
if N < 2
return st
pivot Jat[N-1]
left = new empty list
right = new empty list
for index = 0, 1, 2,
if lst[i]<= pivot
left.add(lat[i])
=
else
N-2
right add(lat[i])
return QuickSort(left) + [pivot] + QuickSort (right)](https://content.bartleby.com/qna-images/question/7d009b7a-5e1c-499c-a434-821054b9abc8/c7e9aa10-f9ed-4ca9-a16c-e88186e5cd8c/idw9ggt_thumbnail.png)
Transcribed Image Text:Q3 QuickSort
Given the QuickSort implementation from class, provide an 18-element list that will take the
least number of recursive calls of QuickSort to complete.
As a counter-example, here is a list that will cause QuickSort to make the MOST number of
recursive calls:
public static List<Integer> input() {
return Accaxsaslist(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
wwwwwww
And here's the QuickSort algorithm, for convenience:
algorithm QuickSart
Input: lists of integers 1st of size N
Output: new list with the elements of lat in sorted order
if N < 2
return st
pivot Jat[N-1]
left = new empty list
right = new empty list
for index = 0, 1, 2,
if lst[i]<= pivot
left.add(lat[i])
=
else
N-2
right add(lat[i])
return QuickSort(left) + [pivot] + QuickSort (right)
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

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
- This program is about identifying palindromes. A palindrome is a list that reads the same forwardas backward. For example, [2, 5, 2] is a palindrome. [2, 5, 2, 2] is not a palindrome. Write a prologfunction, is_palindrome(X), that returns true if the list X is a palindrome, otherwise it returns false. Notethat an empty list is a palindrome.Examples:is_palindrome([1,1,3,1,1]) should return true.is_palindrome([1,3,1,1]) should return false.is_palindrome([1,3,3,1]) should return true.is_palindrome([a,b,l,e,w,a,s,i,e,r,e,i,s,a,w,e,l,b,a]) should return true.arrow_forwardCan you write a program in python for the dining philosopher problems that do not have deadlock? You have to use semaphores and use the strategy that a philosopher only picks the fork if both (left and right) are available. def philosopher(id: int, fork: list): The main is if __name__ == "__main__": semaphoreList = list() #this list will hold one semaphore per fork Philosophers = 5 for i in range(Philosophers): semaphoreList.append(multiprocessing.Semaphore(1)) philosopherList = list() for i in range(Philosophers): #instantiate all processes representing philosophers philosopherList.append(multiprocessing.Process(target=philosopher, args=(i, semaphoreList))) for j in range(Philosophers): #start all child processes philosopherList[j].start() for k in range(Philosophers): #join all child processes philosopherList[k].join() sample output: DEBUG: philosopher2 has chopstick2 DEBUG: philosopher2 has chopstick3 DEBUG: philosopher2 eating DEBUG: philosopher1 has chopstick1 DEBUG: philosopher0…arrow_forwardImplement a function countMultiples in Python that: accepts a single argument, a 2-dimensional list (e.g, list of lists) containing non-negative integers, and returns the count of those integers that are multiples of 5 but that are not not multiples of 10. (e.g., 65 should be counted, but 80 should not be counted) sample usage: >>> countMultiples( [[1,2,3],[4,5],[6,7,8,9]] ) # 5 counts1arrow_forward
- java In this assignment you will swap a position in an array list with another. swap() gets 3 arguments, an Arraylist, a position, and another position to swap with. Example swap(["one","two","three"],0,2) returns:["three","two","one"] public static ArrayList<String> swap(ArrayList<String> list,int pos1,int pos2) public static void main(String[] args) { Scanner in = new Scanner(System.in); int size = in.nextInt(); int pos1 = in.nextInt(); int pos2 = in.nextInt(); ArrayList<String> list = new ArrayList<>(); for(int i=0; i < size; i++) { list.add(in.next()); } System.out.println(swap(list, pos1, pos2)); } }arrow_forwardJavaarrow_forwardWrite a program for Stack (Array-based or linked list-based) in Python. Test the scenario below with the implementation and with the reasoning of the answer. Make comments with a short description of what is implemented. Include source codes and screen-captured outputs. Stack: A letter means doing a push operation and an asterisk means doing a pop operation in the below sequence. Give the sequence of letters that are returned by the pop operations when this sequence of operations is performed on an initially empty stack. A*BCE**F*GH***I*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