Starting Out With C++: Early Objects (10th Edition)
Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 9PC

Sorting Benchmarks

Write a program that uses two identical arrays of at least 20 integers stored in a random order. It should call a function that uses the bubble sort algorithm to sort one of the arrays in ascending order. The function should count the number of exchanges it makes. The program should then call a function that uses the selection sort algorithm to sort the other array. It should also count the number of exchanges it makes. Display these two counts on the screen.

Blurred answer
Students have asked these similar questions
Median Function – In statistics, the median of a set of values is the value that lies in the middle when the values are arranged in sorted order.   If the set has an even number of values, the median is the average of the two middle values.  Your program should start with two arrays of integers containing the following values: Even numbered array:  17 32 45 68 99 101 67 89 22 27 Odd numbered array:   17 32 45 68 99 101 67 89 22 Using a sort function of your choice, first sort the arrays.  NOTE:  you may use the Standard Template Library sort function or your own sort function. Then, write a function that determines the median of a sorted array.   The function should take an array of numbers and an integer indicating the size of the array and return the median of the values in the array.   The same function should be called twice – once for the even array and once for the odd array. Your program should also have a printArray function that can be used to print the sorted array. (It…
""" HouseholdSize.py - This program uses a bubble sort to arrange household sizes                     in descending order and then prints the mean and median                     household size. Input:  Interactive. Output:  Mean and median household size. """ # Initialize variables. householdSizes = []  # Array used to store household sizes. numSizes = 0 total = 0.0 mean = 0.0 median = 0.0 # Input household size householdSizeString = input("Enter household size or 999 to quit: ") householdSize = int(householdSizeString) # This is the work done in the fillArray() function while (householdSize != 999):     # Place value in array.     householdSizes.append(householdSize)     # Calculate total of household sizes     numSizes += 1  # We have one more house     householdSizeString = input("Enter household size or 999 to quit: ")     householdSize = int(householdSizeString) # Find the mean # This is the work done in the sortArray() function # This is the work done in the displayArray()…
CST-201 Project 0: Array Warm-Up The purpose of this assignment is to practice manipulating arrays. This assignment assesses your ability to: ▪Implement sequential and binary search algorithms for array structures. ▪Implement iterative sorting algorithms for array data. For this assignment, write a program that reads a text file and stores each word in an array. Write one of the iterative sorting algorithms to sort your data. Once the data is sorted, write a binary sort algorithm that, when given a string, returns either the index of the string or a -1 to indicate the string was not found in the array. Your program should allow the user to continually enter strings. An entry of 0 indicates the user is finished searching for strings. Start your program by reading strings from a file and populating a string array. Declare the array with a capacity for 10,000 strings. An input file is included with this assignment: ‘text.txt’. Next, write a method that implements either bubble sort,…

Chapter 9 Solutions

Starting Out With C++: Early Objects (10th Edition)

Ch. 9.6 - Prob. 9.11CPCh. 9.6 - Prob. 9.12CPCh. 9.6 - Prob. 9.13CPCh. 9.6 - Prob. 9.14CPCh. 9.6 - Prob. 9.15CPCh. 9 - Prob. 1RQECh. 9 - Prob. 2RQECh. 9 - Prob. 3RQECh. 9 - Prob. 4RQECh. 9 - Prob. 5RQECh. 9 - Prob. 6RQECh. 9 - Prob. 7RQECh. 9 - A binary search will find the value it is looking...Ch. 9 - The maximum number of comparisons that a binary...Ch. 9 - Prob. 11RQECh. 9 - Prob. 12RQECh. 9 - Bubble sort places ______ number(s) in place on...Ch. 9 - Selection sort places ______ number(s) in place on...Ch. 9 - Prob. 15RQECh. 9 - Prob. 16RQECh. 9 - Why is selection sort more efficient than bubble...Ch. 9 - Prob. 18RQECh. 9 - Prob. 19RQECh. 9 - Prob. 20RQECh. 9 - Prob. 21RQECh. 9 - Charge Account Validation Write a program that...Ch. 9 - Lottery Winners A lottery ticket buyer purchases...Ch. 9 - Lottery Winners Modification Modify the program...Ch. 9 - Batting Averages Write a program that creates and...Ch. 9 - Hit the Slopes Write a program that can be used by...Ch. 9 - String Selection Sort Modify the selectionSort...Ch. 9 - Binary String Search Modify the binarySearch...Ch. 9 - Search Benchmarks Write a program that has at...Ch. 9 - Sorting Benchmarks Write a program that uses two...Ch. 9 - Sorting Orders Write a program that uses two...Ch. 9 - Ascending Circles Program 8-31 from Chapter 8...Ch. 9 - Modified Bin Manager Class Modify the BinManager...Ch. 9 - Using Files-Birthday List Write a program that...Ch. 9 - Prob. 14PCCh. 9 - Using Files-String Selection Sort Modification...Ch. 9 - Using Vectors String Selection Sort Modification...
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++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License