Starting Out with C++: Early Objects
Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
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
A dequeue is a list from which elements can be inserted or deleted at either end a. Develop an array based implementation for dequeue. b. Develop a pointer based implementation dequeue.
This chapter describes the array implementation of queues that use a special array slot, called the reserved slot, to distinguish between an empty and a full queue. Write the definition of the class and the definitions of the function members of this queue design. Also, write a program (in main.cpp) to test various operations on a queue. //Header file QueueAsArray   #ifndef H_QueueAsArray #define H_QueueAsArray   #include <iostream> #include <cassert>   using namespace std;   template<class Type> class queueType { public:     const queueType<Type>& operator=(const queueType<Type>&);             // overload the assignment operator     void initializeQueue();     int isEmptyQueue() const;     int isFullQueue() const;       Type front() const;       Type back() const;       void addQueue(Type queueElement);     void deleteQueue();       queueType(int queueSize = 100);     queueType(const queueType<Type>& otherQueue); // copy constructor…
It is not desirable to use a static array like aux[] in library software since numerous clients may be using the class at once. Give a Merge implementation that doesn't depend on a static array. Do not localise aux[] to combine()Hint: Pass the auxiliary array to the recursive sort() function as an argument.

Chapter 15 Solutions

Starting Out with C++: Early Objects

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning