Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
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
JAVA LANGUAGE
Don't use vector array .using c++ language
Course: Data Structure and Algorithms Language: C++ Question is well explained   Question #2Implement a class for Circular Doubly Linked List (with a dummy header node) which stores integers in unsorted order. Your class definitions should look like as shown below: class CDLinkedList;class DNode {friend class CDLinkedList;private int data;private DNode next;private DNode prev;};class CDLinkedList   {private:DNode head;                          // Dummy header nodepublic CDLinkedList();            // Default constructorpublic bool insert (int val);       public bool removeSecondLastValue ();                    public void findMiddleValue();                  public void display();                       };

Chapter 15 Solutions

Starting Out with C++: Early Objects (9th Edition)

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