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
bartleby

Concept explainers

Question
Book Icon
Chapter 15, Problem 1PC
Program Plan Intro

Analysis of Sorting Algorithms

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 the “reset_comparison” function reset the comparison value to “0”.
    • In protected, declare the “compare” function.
    • 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 “Max_sort”.
    • In public, declare the “sort” function.
  • Define the “sort” function.
    • Get the array of numbers from the main method and swap operation is performed.
  • 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 “Max_sort”.
    • Call the “sort” function.
    • Display the result.

Blurred answer
Students have asked these similar questions
object oriented programing Design a class that has an array of floating-point numbers. The constructor should accept an integer argument and dynamically allocate the array to hold that many numbers. The destructor should free the memory held by the array. In addition, there should be member functions to perform the following operations: • Store a number at any index of the array • Retrieve a number from any index of the array • Return the highest value stored in the array • Return the lowest value stored in the array • Return the average of all the numbers stored in the array
Object Oriented Programming C++ A designer in 3D graphics company wants to design a matrix as a two-dimensional array. The size of 2D array could be the last two digit of arid number. Initially he creates a class matrix that provides the member function to check that no array index is out of bounds. Make the member data in the matrix class a 10-by-10 array. A constructor should allow the programmer to specify the actual dimensions of the matrix (provided theyre less than 10 by 10). The member functions that access data in the matrix will now need two index numbers: one for each dimension of the array. Heres what a fragment of a main() program that operates on such a class might look like:If the Number is 738 then: // in case of zero consider next digitmatrix m1(5, 4); // define a matrix objectint temp = 12345; // define an int value m1.putel(7, 4, temp); // insert value of temp into matrix at 7,4 temp = m1.getel(7, 4); // obtain value from matrix at 7,4
Bookstore class uses a dynamic array to hold names book titles. class BookStore { public: BookStore (); BookStore (const Bookstore & b); // POST: object made from b -BookStore (); void insert(string title); // POST: add title to the end of the titles list private: string store; int capacity; int size; }; Describe two different situations in which the copy constructor function is called. Write a short code snippet illustrating each situation. Explain the problem if this class did not provide a deep copy constructor function. // POST: empty object with room for 10 titles // POST: object is destructed // pointer to dynamic array of book titles // capacity of array // number of books used in the bookstore

Chapter 15 Solutions

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

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
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