Modify quicksort so that it sorts array in ascending order

Assignment Help Data Structure & Algorithms
Reference no: EM131168830

Programming Assignment-

Instructions:

Consider the following quicksort program and modify it so that it sorts the array in ascending order, uses pointers instead of indexes, and works with vectors.

Test the program on several data input arrays.

//Quick Sort Functions for Descending Order
//From https://mathbits.com/MathBits/CompSci/Arrays/Quick.htm void QuickSort(int * num, int top, int bottom)
{
// top = subscript of beginning of array
// bottom = subscript of end of array

int middle;
if (top < bottom)
{
middle = partition(num, top, bottom); quicksort(num, top, middle); // sort first section
quicksort(num, middle+1, bottom); // sort second section
}
return;
}

//Function to determine the partitions
// partitions the array and returns the middle subscript int partition(int * array, int top, int bottom)
{
int x = array[top]; int i = top - 1;
int j = bottom + 1; int temp;
do
{
do
{
j - -;
}while (x >array[j]);

do
{
i++;
} while (x <array[i]);

if (i < j)
{
temp = array[i]; array[i] = array[j]; array[j] = temp;
}
}while (i < j);
return j; // returns middle subscript
}

Reference no: EM131168830

Questions Cloud

Differences between the house of representatives and senate : Short essay responses should of at least 300 words Please use intro, body and conclusion format. Minimum of 2 sources each for a total of 4. Has to be submitted through turnitin.com for a plagiarism check. What are the differences between the Hous..
Does this filter remove any edges : Does this filter remove any edges that are not removed by vertex-degree filtering?- Does it remove any that are not removed by alldiff filtering?
What is the anticipated stock price at the beginning of 2011 : Justin Cement Company has had the following pattern of earnings per share over the last five years: . Project earnings and dividends for the next year (2011).  If the required rate of return (Ke) is 13 percent, what is the anticipated stock price (P0..
What most important factors in determining why people vote : What are the most important factors in determining why people vote? Are there particular factors that appear to be more important than other factors? Does this hold true for all countries or just the United States?
Modify quicksort so that it sorts array in ascending order : Consider the following quicksort program and modify it so that it sorts the array in ascending order, uses pointers instead of indexes, and works with vectors.
How various explanations are competitive in the literature : How the various explanations are competitive in the literature on the particular case, and how the various causes or different causes of similar or different cases help contribute to the theories and general explanations of WAR.
Describe how to use this oracle : ssume there is an oracle that can quickly tell whether a graph is hamiltonian. - Describe how to use this oracle to check quickly whether a particular edge in a graph is hamiltonian.
Write the resulting benders cut : Suppose that a Benders method is applied to a minimum total tardiness planning and scheduling problem.- Write the resulting Benders cut (3.147).
Draw a graph with five vertices and many edges as possible : [BB] Draw a graph with five vertices and as many edges as possible. How many edges does your graph contain? What is the name of this graph and how is it denoted?

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