Compute the total number of comparisons used to sort

Assignment Help Data Structure & Algorithms
Reference no: EM131379742

1. The file contains all of the integers between 1 and 10,000 (inclusive, with no repeats) in unsorted order. The integer in the ith row of the file gives you the ith entry of an input array.

Your task is to compute the total number of comparisons used to sort the given input file by Quicksort. For this part you should always use the first element of the array as the pivot element.

You should not count comparisons one-by-one. Rather, when there is a recursive call on a subarray of length m, you should simply add m-1 to your running total of comparisons.

2. Compute the number of comparisons (as in Part 1), always using the final element of the given array as the pivot element.

3. Compute the number of comparisons (as in Part 1), using the "median-of-three" pivot rule.

In more detail, you should choose the pivot as follows. Consider the first, middle, and final elements of the given array. If the array has odd length it should be clear what the middle element is. For an array with even length 2k, use the kth element as the middle element. So for the array 4 5 6 7, the middle element is the second one - 5 and not 6. Identify which of these three elements is the median, and use this as your pivot.

Reference no: EM131379742

Questions Cloud

Explain the process once she gets to the us : Go to the USCIS website and find the initial USCIS application/form that Frank must complete to begin the process of bringing his finance over from France. What is the name of the Visa she will use to come over? Explain the process once she gets t..
Did court agree that gulf breached its contract : Did the American court have jurisdiction over an exclusively American contract affected by an international incident, such as the 1973 oil embargo? Did the court agree that Gulf breached its contract with Eastern Airlines? Explain.
What are advantages of java as compared to the other two : What are the advantages and disadvantages of Java as compared to the other two? Your report should include a use case describing the career path of a Java developer in the IT industry.
Why was the court involved in this scenario : Assess whether this was a constitutional or unconstitutional delegation of power. Why was the court involved in this scenario? Why is this case significant for public administrators in understanding the delegation doctrine
Compute the total number of comparisons used to sort : Your task is to compute the total number of comparisons used to sort the given input file by Quicksort. For this part you should always use the first element of the array as the pivot element.
Explain was arkansas correct in the given situation : Arkansas argued that the federal district court had no extraterritorial power to mediate this international trade dispute. Was Arkansas correct? Explain.
What percentage of these movies were comedies : Which of the following can you learn from this table? Give the answer if you can find it from the table. i) The percentage of PG-13 movies that were comedies
Case brief - oberschlake vs veterinary animal associates : Complete a case brief for Oberschlake v. Veterinary Animal Associates. We have read through this case before so you should know it well at this point. Come prepared with the brief by the date indicated on the calendar
Identify unknown vocabulary and technical terms : Does it present research on an important topic that has not yet been studied to any real extent? Articles of this type may present new research or the analysis and translation of a significant primary source.Is the author presenting new research a..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Show state of memory after processes by best fit algorithm

Using the best fit algorithm, show the state of memory after processes of 212K, 417K, 112K and 350K (in request order) arrive.

  What numbers are compared to 72 if a sequential search is

question 1. what numbers are compared to 72 if a sequential search is used 2 5 7 9 11 17 18 21 28 30 45 5465 69 72.

  How to create simple indexed files

How to create simple indexed files and multiple indexed files in file structures in c++?

  Create a graph showing best average and worst case

Create a graph showing best, average, and worst case T scores for your code in number 3 above for n = powers of 2 from 21 to 216. If there are any results you cannot provide be specific as to the reason. You can modify the best/worst by modifying ..

  What is the benefit of creating multiple levels of dfds

What is the benefit of creating multiple levels of DFDs? Consider the concept of DFD consistency. Why is consistency important to take advantage of the multiple levels of DFDs that may be created

  1decryption speeda certain cryptography vendor was

1.decryption speeda certain cryptography vendor was providing an encryption technology that was breakable within 10

  Design an algorithm to find the selling price of item sold

To make a profit, the prices of the items sold in a furniture store are marked up by 60%. Design an algorithm to find the selling price of an item sold at the furniture store. What information do you need to find the selling price?

  Question 1you are required to undertake a detailed analysis

question 1you are required to undertake a detailed analysis of the avl tree sorting algorithm for avlsort.to do this

  Decryption speed and diffie-hellman

Increase of a single bit in the size of the encryption key doubles the amount of needed computations - Show how the recipient of the message, who knows e, produces the plaintext.

  Question about damaged database

Suppose if you were one of the users of a damaged database, discuss how would you be affected by such a failure and what measures could you take to prevent it?

  Evaluate a virtual memory system

The objective of this lab is to simulate and evaluate a virtual memory system, and experiment with different page replacement algorithms. You will need a threads package, e.g., pThreads thread package

  Creating villian

Announce a new Villian called sharpay who has a wit of 24, a stealth of sixteen, and who has currently claimed three victims: Chad, Troy, and Gabriella.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd