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

  Create and implement dynamic programming algorithm

Create and implement such dynamic programming algorithm and examine it. You are not sure if CEO must get invited to party, but you suspect that you might get fired if he is not.

  Sort array of elements using the quick sort algorithm

"sort an array of 10,000 elements using quick sort algorithm as follows: sort the array using pivot as middle element of the array

  Database design activities

Assume Ray wishes to start a DVD rental program at his stores that he plans to call Henry's DVD Club. He refers to each of his consumers as members.

  Finding total available storage capacity

A certain hard disk has 480 cylinders, sixteen tracks, and thirty-two sectors of 512 bytes each. It spins at 4800 revolutions per minute, and has an adjacent cylinder seek time of eighty msec, and a max seek time of onde hundred msec.

  Implementing ajax programming

In the AJAX scripts construct, refer to the DSN datasource as flamingo. Even though its not in your own folder or directory, it has been set up as SYSTEM DSN, so your AJAX script will have access to it.

  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?

  Draw an eer or er diagram for the conceptual design

Translate your EERD or ERD to tables. Clearly show the primary key, foreign keys, and alternate keys.

  Create algorithm prompt for and receive employee number

Create algorithm which will prompt for and receive the employee number from operator at terminal. Your program is to search array of valid employee numbers to check that employee number is XXXXX,

  Draw flowchart to print average for each student

Draw a flowchart to print the average for each student in a class. Input. Input consists of student records each containing a student's name(STUDENT-NAME), score for first test(TEST), score for second test(TEST2), and score for third test(TEST3)..

  What is the machine run time in second for sorting array

Write computer program to implement this algorithm and demonstrate the results and what is the machine run time in second for sorting array A

  Data speed effect on fundamental business decisions

Can the speed in which data is transmitted have an adverse effect on fundamental business decisions? Yes, speed that is traveling at big rates of speed can have an affect on fundamental business decisions.

  Order statistic tree to count number of inversions in array

Demonstrate how to use an order-statistic tree to count the number of inversions in an array of size n in time O(n lg n).

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