1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jenyasd209 [6]
3 years ago
13

Write down a recurrence relation for this version of QuickSort, and solve it asymp-totically. Show your work. Assume that the ti

me it takes to find the pivot (eitherbest or worst, depending on the level of recursion) is Θ(n) for lists of lengthn.
Computers and Technology
1 answer:
torisob [31]3 years ago
5 0

Answer:As in merge sort, the time for a given recursive call on an n-element subarray is Θ(n). In merge sort, that was the time for merging, but in quicksort it's the time for partitioning.

Explanation:

Worst-case running time:

When quicksort always has the most unbalanced partitions possible, then the original call takes cncnc, n time for some constant ccc, the recursive call on n-1n−1n, minus, 1 elements takes c(n-1)c(n−1)c, left parenthesis, n, minus, 1, right parenthesis time, the recursive call on n-2n−2n, minus, 2 elements takes c(n-2)c(n−2)c, left parenthesis, n, minus, 2, right parenthesis time, and so on. cn+c(n−1)+c(n−2)+⋯+2c=c(n+(n−1)+(n−2)+⋯+2)

=c((n+1)(n/2)−1)

The last line is because 1 + 2 + 3 +...... n is the arithmetic series

Best-case running time:

Quicksort's best case occurs when the partitions are as evenly balanced as possible: their sizes either are equal or are within 1 of each other. The former case occurs if the subarray has an odd number of elements and the pivot is right in the middle after partitioning, and each partition has (n-1)/ 2 elements. The latter case occurs if the subarray has an even number n of elements and one partition has n/2 elements with the other having n/2-1.In either of these cases, each partition has at most n/2 elements.

Using big-Θ notation, we get the same result as for merge sort: Θ(nlog2n)

You might be interested in
Python - Write a program to print the multiplication table as shown in the image by using for loops.
Galina-37 [17]

Answer:

Explanation:

The following python code creates the multiplication table for 10 rows and 10 columns. This code uses nested for loops to traverse the table and print out the product of each multiplication. The image attached shows the output of the code.

for x in range(1, 11):

       for y in range(1, 11):

           z = x * y

           print(z, end="\t")

       print()

8 0
2 years ago
The market is in <br> until the price of goods reflects equal supply and demand.
katen-ka-za [31]
Supply and demand us an economic model of price determination in a market if demand increses and supply remains unchanged then it leads to higher equalibrium price and higher quantity if demand decreases s and supply remains unchanged then it lead to lower equilibrium price and lower quantity hope this helps XD
7 0
2 years ago
Windows is a GUI Operating System, what is the other type?
alekssr [168]

Answer:

If you are looking for a different type of GUI operating system then :

Linux or mac

if you are looking for a different type of operating system (non-GUI):

Command-line interface

Explanation:

3 0
2 years ago
Write a logical expression using only and, or and not that is equivalent to the Exclusive NOR (XNOR) gate on 2 inputs, called in
denis-greek [22]

Answer:

in1 = int(input("Enter value one: "))

in2 = int(input("Enter value two: "))

print(in1,type(in1), in2, type(in2))

if (in1 <=0 and in2 <=0) or (not in1 <=0 and not in2<=0):

   print( True)

else:

   print( False)

Explanation:

The if statement of the python source code is used to implement an Exclusive-NOR logic gate that gives a true or high value if both inputs are either true or false.

5 0
3 years ago
What is a symptom of a failing power supply? The display has only a blinking cursor. The computer displays a POST error code. Th
Mariulka [41]

Answer:

A sympton of a failing power supply is The computer sometimes does not turn on.

Explanation:

All right, the power supply is the terminal that receives electric current to process it and distribute it to the different parts of the hardware that compose the computer. When it fails, the current is not distributed and doesn't reach the different pieces of hardware. Therefore, option D) is the correct one. Another error that could be related is the malfunction of fans but it could be related to wires more than the power itself.

7 0
3 years ago
Other questions:
  • What does CPL stand for
    9·2 answers
  • What are two statements that are true about using an external hard drive for backing up data
    14·1 answer
  • ___________is a security strategy that applies multiple layers of defense because there is an assumption that any single protect
    12·1 answer
  • What uses HTML hypertext links that users can click to access different locations or information?
    11·1 answer
  • For Excel:
    5·1 answer
  • What does the CFO of a company do
    14·1 answer
  • when files on storage are scattered throughout different disks or different parts of a disk, what is it called
    10·1 answer
  • Describe FIVE distinct features of multi-threaded programming. Your answer should be language independent. g
    9·1 answer
  • Select the correct answer.
    8·1 answer
  • Effective online learning method for students
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!