STARTING OUT WITH C++ MPL
STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
Question
Book Icon
Chapter 15, Problem 2PC
Program Plan Intro

Analysis of Quicksort

Program Plan:

  • Include the required header files to the program.
  • Define “AbstractSort” class.
    • In public, declare the pure virtual function.
      • In the “get_comparison” function return the total number of comparison.
    • In protected, declare the “compare” function.
      • In the “reset_comparison” function reset the comparison value to “0”.
    • In private, declare the required variable.
  • Define the “compare” function outside the class definition.
    • Inside the function, increment the comparison count and return the number of comparison.
  • Define the derived class “Quicksort”.
    • In public, declare the “sort” function.
    • In private, declare the “quick” function and “partition” function.
  • Define the “quick” function.
    • If the least number is greater than the highest number, return the value to the function.
    • Call the “partition”, quick” functions.
  • Define the “partition” function.
    • Set the pivot value.
    • Declare and set the “front” variable.
    • If the “front” value is less than “u”, swap the values and increment the pivot variable.
    • Increment the “front” variable.
  • Define the “main()” function.
    • Declare and initialize the required variables.
    • Get the array value from the user.
    • Check the array value with array index.
      • If the array value is greater than index value exits the program.
    • Initialize the random number generator and generate the random numbers.
    • Create the object for the class “Quicksort”.
    • Call the “sort” function.
    • Display the result.

Blurred answer
Students have asked these similar questions
C++ programming Recall that in C++, there is no check on an array index out of bounds. However, during program execution, an array index out of bounds can cause serious problems. Also, in C++, the array index starts at 0. Design and implement the class myArray that solves the array index out of bounds problem and also allows the user to begin the array index starting at any integer, positive or negative. Every object of type myArray is an array of type int. During execution, when accessing an array component, if the index is out of bounds, the program must terminate with an appropriate error message. Consider the following statements: myArray list(5);                 //Line1 myArray myList(2, 13);    //Line 2 myArray yourList(-5, 9);   //Line 3 The statement in Line 1 declares list to be an array of five components, the component type is int, and the components are: list[0], list[1], ..., list[4]; The statement in Line 2 declares myList to be an array of 11 components, the component…
Programming Language: C++ I need the codes for arrayListType.h, main.cpp, myString.cpp, myString.h
JAVA CODE Learning Objectives: Detailed understanding of the linked list and its implementation. Practice with inorder sorting. Practice with use of Java exceptions. Practice use of generics.   You have been provided with java code for SomeList<T> class.  This code is for a general linked list implementation where the elements are not ordered.  For this assignment you will modify the code provided to create a SortedList<T> class that will maintain elements in a linked list in ascending order and allow the removal of objects from both the front and back.  You will be required to add methods for inserting an object in order (InsertInorder) and removing an object from the front or back.  You will write a test program, ListTest, that inserts 25 random integers, between 0 and 100, into the linked list resulting in an in-order list.  Your code to remove an object must include the exception NoSuchElementException.  Demonstrate your code by displaying the ordered linked list and…

Chapter 15 Solutions

STARTING OUT WITH C++ MPL

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning