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
create using c++ One problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example, you might want to add or delete entries from the array similar to the behavior of a vector . This project asks you to create a class called DynamicStringArray that includes member functions that allow it to emulate the behavior of a vector of strings. The class should have the following A private member variable called dynamicArray that references a dynamic array of type string. A private member variable called size that holds the number of entries in the array. A default constructor that sets the dynamic array to NULL and sets size to 0. A function that returns size . A function named addEntry that takes a string as input. The function should create a new dynamic array one element larger than dynamicArray , copy all elements from dynamicArray into the new array, add the new string onto the end of the new array, increment size, delete the…

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