Develop modified versions of the quicksort and mergesort

Assignment Help Data Structure & Algorithms
Reference no: EM13336646

Task 1.2 Prove this fact rigorously, by mathematical induction.

Please note that the last permutation produced in this sequence is (n, ..., 2, 1). And this is the only permutation that does not have the "next" permutation to it.

Example. Below is the sequence of permutations for n = 3, produced by applying nextPermutation consecutively:

(1 2 3); (1 3 2); (3 1 2); (2 1 3); (2 3 1); (3 2 1)
So, the nextPermutation applied to (1 , 2, 3) produces (1, 3, 2),
applied to (1 , 3, 2) it produces (3, 1, 2),
applied to (3, 1, 2) it produces (2, 1, 3),
etc.

Task 2.2. Iterative version. This is a difficult task, although awarded only two marks.

Using the recursive algorithm, described in the previous section, develop an iterative function with the same functionality as the recursive nextPermutation function. Recall, that the iterative function should not contain recursive calls - it uses only looping constructs.

Task 3. Adding counters to the sorting functions. Develop modified versions of the quickSort and mergeSort functions discussed in the lectures.

I.e. you need to add integer counters to the sorting methods that count the number of comparisons made by each of the functions during the sorting process.

 

 

Reference no: EM13336646

Questions Cloud

Depict lewis structure of no3cl include lone pairs : Draw lewis structure of NO3Cl include lone pairs of electrons, resonance structures and formal charges (minimized). The basic structure is O=N(-O)(-O-Cl). Where N is double bonded to one O and single bonded to two O atoms. Also, one of the O atoms..
How does brakes affect the time required to come to a stop : Assume that the brakes in your car create a constant deceleration, regardless of how fast you are going. If you double your driving speed, how does this affect the time required to come to a stop
Calculate the pressure exerted on the floor by the heel : As a woman walks, her entire weight is momentarily placed on one heel of her high-heeled shoes. Calculate the pressure exerted on the floor by the heel
How do you calculate the molarity of kmno4 : How do you calculate the molarity of KMnO4 after it has been titrated by .0505 M (COOH)2? The only information you are given is .0011 mol of KMnO4 and no volume...this is for prelab 6.
Develop modified versions of the quicksort and mergesort : Using the recursive algorithm, described in the previous section, develop an iterative function with the same functionality as the recursive nextPermutation function. Recall, that the iterative function should not contain recursive calls - it uses..
Explain the sedimentation coefficient of a certain dna : The sedimentation coefficient of a certain DNA in 1 M NaCl at 20 oC was measured by boundary sedimentation at 24,630 rpm. The following data were recorded time (min) distance (cm) 16 6.2687 32 6.3507 48 6.4380 64 6.5174 80 6.6047 96 6.6814 A.
What is the acceleration of the system : Two masses, m1 and m2 are connected by a cord and hang straight down from either side of a light frictionless pulley. What is the acceleration of the system
Calculate the electric potential half way between two rings : For two concentric conducting rings, the inner radius of the larger ring is 12.0 cm and the outer radius of the smaller ring is 4.0 cm. The electric potential of the inner ring is 0 and that of the outer ring is 10 V.
Calculate the refractive power of a magnifying glass : A stamp collector is viewing a stamp with a magnifying glass held next to her eye. Her near point is 22 cm from her eye. What is the refractive power of a magnifying glass that has an angular magnification of 6.32 when the image of the stamp is loca..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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