
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

Transcribed Image Text:Consider the following three sorting algorithms: Insertion Sort,
Heapsort, and Quicksort.
Here are three statements.
A. Iam an incredibly fast sorting algorithm that runs in O(n log n)
time on average, though my worst case run time is O(n2).
B. I run very quickly for small values of n, but unfortunately am
really slow when n is large. My average run time is O(n2).
C. I am an in-place sorting algorithm whose average case and
worst case running time is O(n log n).
For each statement (A, B, C), determine the correct sorting
algorithm.
Expert Solution

arrow_forward
Introduction
Sorting is a process of arranging all the given values in an order
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
- 4. Consider the following algorithm. ALGORITHM Mystery(n) /Input: A nonnegative integer n S+ 0 for i +1 to n do S+S+i *i return S a. What does this algorithm compute? b. What is its basic operation? c. How many times is the basic operation executed? d. What is the efficiency class of this algorithm?arrow_forwardTrace the steps of this algorithm with the following array input: [71,59,28,23,30,8]arrow_forward1. Suppose you are responsible for organizing and determining the results of an election. An election has a winner if one person gets at least half of the votes. For an election with n voters and k candidates, design a divide and conquer algorithm to determine if the election has a winner and finds that winner. Your algorithm should run in O(nlogn) and is allowed to use 0(1) extra memory.arrow_forward
- 2. Given three different sorting algorithms to solve a sorting problem and their runtimes are expressed as given below: T₁(N) = O(N²) T₂(N) = (N²) T3(N) = Q(N²) Which algorithm should be preferred and which one should not be. Give your answer by using the definitions of the three symbols used.arrow_forwardConsider the following algorithm. What does this algorithm compute? What is its basic operation? How many times is the basic operation executed? What is the efficiency class of this algorithm? Suggest an improvement of the given algorithm, and indicate its efficiency class. If you cannot do it, try to prove that, in fact, it cannot be done.arrow_forwardConsider the Sort-and-Count algorithm explained in section 5.3 of our text: "Counting Inversions"Suppose that the initial list is: 92 71 36 91 27 48 14 34 81 26 24 65 78 51 37 22 Sort-and-Count makes two recursive calls. The first recursive call inputs the first half of the initial list: 92 71 36 91 27 48 14 34 and returns the sorted version of the first half, as well as the number of inversions found in the first half (22). The second recursive call inputs the second half of the initial list: 81 26 24 65 78 51 37 22 and returns the sorted version of the second half, as well as the number of inversions found in the second half (19). Sort-and-Count then calls Merge-and-Count. To Merge-and-Count, Sort-and-Count passes the sorted versions of the two halves of the original list: 14 27 34 36 48 71 91 92, and 22 24 26 37 51 65 78 81 Merge-and-Count begins merging the two half-lists together, while counting…arrow_forward
- You are given an array A[1, ., n] in which the elements A[2] to A[n] are already sorted, i.e., A[2, .., n] is a sorted array. Write down an efficient algorithm with proper pseudocode for moving A[1] in the correct place, so that the full array A[1, ..., n] is sorted.arrow_forwardAssume that we are given n pairs of items as input, where the first item is a number and the second item is one of three colors (red, blue, or yellow). Further assume that the items are sorted by number. Give an O(n) algorithm to sort the items by color (all reds before all blues before all yellows) such that the numbers for identical colors stay sorted. For example: (1,blue), (3,red), (4,blue), (6,yellow), (9,red) should become (3,red), (9,red), (1,blue), (4,blue), (6,yellow).arrow_forwardSuppose that each row of an n × n array A consists of 1's and 0's such that in any row of A all the 1's come before any O's in that row. Assuming that A is already in memory, describe an algorithm running in O(n) time for finding the row that contains the most 1's. Write the algorithm following the style of your course-notes.arrow_forward
- Write an efficient algorithm for the following problem (either pseudocode or java), and describe your reasoning. Determine the Time complexity and if you cannot find any polynomial time algorithm, then give a backtracking algorithm. Problem will be on repeat numbers input will be ARRAY[1,2, ... , n] number of positive numbes. Output will any one number that is repeated more than n/3 times. for example, if you have [1,1,2,2,2,1], since n = 6 and n/3 = 2, both 1 and 2 showed up more than n/3 times. the output will be either 1 or 2 (just one of the values are required) if you have [1,1,3,4,5,6,7,8,9], since 1 is only repeated twice, and n/3 = 3, output will be "none"arrow_forwardYou want to design an algorithm, called minMax(A,p,r), that takes an array of integers and indexes of the first and last elements, and returns the minimum and maximum values in that range. Now write the pseudo code of a divide and conquer (and therefore, recursive) algorithm with the same time complexity (Θ(n)). You can assume that p ≤ r. Also, in your code, you can return two numbers by returning a pair, e.g. “return (a, b)”, and can save the output in a similar way, e.g. “(a, b) = minMax(parameters)”. (Short answer please)arrow_forward1. a.An algorithm can be specified in various ways. Identify and explain four ways in which an algorithm can be specified. b. (b). Two algorithms A, B sort the same problem. When you go through each algorithm and break them down into their primitive operations, each can be represented as follows:A = 2n7 + 100n4 + 26n + 50 B = 7n4 + 22n2 + nlogn + 200For very large values of n, which of the algorithms A or B will runin the shortest time to solve the problem and why? (c). Two Computer Science students, Priscilla and Julius, are discussing how to compare two algorithms for solving a given problem. Priscilla suggests that they should use the execution times of the algorithms as criterion; but Julius insists that they should use the number of statements the algorithms execute as criterion. (i). Discuss the reasons why both criteria they are considering are not good for comparing algorithms.(ii). Recommend an ideal solution/criterion that they should rather use for comparing algorithmsarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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