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

  Explain algorithm which gives initial infection of computer

Explain an O(m+n) algorithm which, given an initial infection of a computer Ca at time t determines for each other computer the earliest time at which it can become infected.

  Algorithm for finding smallest element in unsorted array

Consider the following algorithm for finding the smallest element in an unsorted array: RANDOMMIN(A[1 .. n]). What is the exact expected number of executions of line ( )?

  Primitives-remove ambiguities in algorithm-s representation

Describe how the use of primitives helps remove ambiguities in an algorithm's representation.

  Question about software importance

Determine what makes software so important and list a number of ways that software has an impact on our life.

  True or false about networking

2- A print queue must be set up for every printer on the network served by a print server. True False

  Describe a fair coin algorithm to returns either 0 or 1

Describe a FAIRCOIN algorithm that returns either 0 or 1 with equal probability, using ONEINTHREE as your only source of randomness.

  Describe the need for complex data structures

Describe the need for complex data structures and how they are used. Describe the design and application of arrays and how the array simplifies program development.

  Irected graph g = (v,e) in which edges that leave the source

Suppose that we are given a weighted, directed graph G = (V,E) in which edges that leave the source vertex s may have negative weights, all weights are nonnegative, and there are no negative-weight cycles. Argue that Dijkstra's algorithm correctly fi..

  Identify data structures to organize typical file cabinet

Identify at least two data structures that are used to organize a typical file cabinet. Why do you feel it is necessary to emulate these types of data structures in a computer program?

  Write schedule produced by earliest deadline first algorithm

Given below are two sets of real-time, periodic tasks. For (a), will the schedule produced by Earliest Deadline First algorithm meet all the deadlines?

  Developing gui application with jframe

Make a GUI application with JFrame that haves 5-labels explaining reasons that a customer might not buy a specific product.

  Algorithm to concatenate string in single binary search tree

Create algorithm which concatenates T1 and T2 into single binary search tree. Worst case running time must be O(h).

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