Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 9, Problem 20RQE
Explanation of Solution
Given:
The “empName” and “empID” are the two parallel arrays of size “numEmp” which holds employee data.
Pseudocode
do //Line 1
Set temp flag to false //Line 2
for count =0 to next-to-last array subscript //Line 3
if empID[count]>empID[count+1] //Line 4
Swap empId[count] with empId[count+1]//Line5
Swap empName[count] with
empName[count+1] //Line 6
...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Easy C++ program please answer fast
Maximum Subarray Sum Rabbit Jerry downloads the list of N (2 ≤ N ≤ 105 ) stock prices of RABJ and stores them into a circular buffer/array in a clockwise manner (i.e., the first stock price follows the N-th stock price on the circular buffer) starting from index position 0. It is worth pointing out that the stock prices can be negative numbers in the rabbit stock market. He is curious about the maximum subarray sum over this circular buffer. Certainly, the maximum subarray can possibly straddle over both index positions 0 and N-1.
Output the maximum subarray sum. The maximum subarray must contain at least one element.
INPUT FORMAT (input arrives from the terminal / stdin):
First line contains N. The next line contains N space-separated integers denoting the input sequence. The price ranges from -1,000,000 to 1,000,000.
OUTPUT FORMAT (print output to the terminal / stdout):
A single line containing the maximum subarray sum. Note that the output can…
Assume an array of structures is in order by the customerlD field of the record,where customer IDs go from 101 to 500.A) Write the most efficient pseudocode algorithm you can to find the record witha specific customerlD if every single customer ID from 101 to 500 is used andthe array has 400 elements.B) Write the most efficient pseudocode algorithm you can to find a record with acustomer ID near the end of the IDs, say 494, if not every single customer IDin the range of 101 to 500 is used and the array size is only 300
Write a code segment that displays the items in a three-dimensional array. Each line of data should represent all the items at a given row and column, stretching back from the first depth position to the last one. The traversal should start at the first row, column, and depth positions and move through depths, columns, and rows
Chapter 9 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 9.2 - Prob. 9.1CPCh. 9.2 - Prob. 9.2CPCh. 9.2 - Prob. 9.3CPCh. 9.2 - Prob. 9.4CPCh. 9.3 - True or false: Any sort can be modified to sort in...Ch. 9.3 - Prob. 9.6CPCh. 9.3 - Prob. 9.7CPCh. 9.3 - Prob. 9.8CPCh. 9.3 - Prob. 9.9CPCh. 9.6 - Prob. 9.10CP
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
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
- Create two Arrays A with 10 unsorted integer elements and B with 10 unsorted floatelements. Find the largest element in A and B and then sum both of them calling afunction SumAB() by reference. Sort A and B and then call another function StichAB()to merge B with A. Be careful about memory leakage.arrow_forwardsolve in python coding 3. Selection Sort• The idea in a selection sort is that you locate the largest item out of a set ofunsorted items, and move it into position at the end of the unsorted items. Asorted region grows one item at a time, while an unsorted region shrinks.• As done in Part 1, fill an array with random numbers.• Write a function that locates the largest element in the portion of the arraybeginning at the start of the array, up to a given index, and swaps the largestitem with the item at the given index.• E.g. If searching a[0] to a[7] locates the largest item at a[4], a[4] and a[7] would beswapped.• Write a second function that calls the first function repeatedly, until the entirearray is sorted. (Each time the first function is called, it will search one fewerelement)arrow_forwardC++ LANGUAGE Write a program that asks for two integers X and Y as input and creates two arrays with sizes X and Y using calloc. Then, ask for the elements of the two arrays using a loop of your preference and concatenate the two arrays into one. Elements in X must come first. One line containing an integer for the size of the array X Print the concatenated elements inside a pair of square brackets [ ] where each elements are separated by a comma and a space. At the end of the program, don't forget to free the memory space. Input 1. One line containing an integer for the size of the array X 2. One or more lines containing an integer for the elements of array X 3. One line containing an integer for the size of the array Y 4. One or more lines containing an integer for the elements of array Y OUTPUT: Enter size of array 1: 3 Enter element 1: 1 Enter element 2: 2 Enter element 3: 3 Enter size of array 2: 2 Enter element 1: 4 Enter element 2: 5 [1, 2, 3, 4, 5]arrow_forward
- Q1)Suppose you are given an array A of n elements. Your task is to sort n numbers stored in array A by reading the first element of A and placing it on its original position (position after sorting). Then read the second element of A, and place it on its original position. Continue in this manner for the first n-1 elements of A. What type of sorting is this? Write the algorithm and also mention the name of this sorting algorithm. What loop invariant does this algorithm maintain? Give the best-case and worst-case running times of this sorting algorithm. Q2)Consider an array consisting of the following sequence: 1, 4, 9, 16, 25, 49, …, n Suppose a number in the sequence is missing. Write the mathematical process to find the missing number, i.e. some equation. What is the time complexity of finding the missing number in the sequence? Q3)Sort the text “SARHAD UNIVERSITY” in ascending order using the insertion sort algorithm. Discuss also the best, worst and average case complexity of the…arrow_forwardThe code below computes the intersection (the number of entries shared by two arrays). It is assumed that neither array contains any duplicates. It computes the intersection by sorting one array (array b) and then iterating over array a to see if each value is in b (through binary search). What is its duration? nt intersection(int[] a, int[] b) {mergesort(b);}int intersect = 0;for (int x : a) {if (binarySearch(b, x) >= 0) {intersect++;return intersect; }}arrow_forwardGiven these two arrays, char arrA[] = {'a', 'e', 'i', 'o', 'u'} and char arrB[] = {'T', 'A', 'B','L','E'}, merge these two arrays into a new array. Make sure that the contents of arrA is interspersed with contents of arrB.arrow_forward
- Write the function that returns the total number of the searched value according to the 1000 sized integer array (all the numbers should be generated between 0 to 100) sent into it and array length, on an array withinitial values.arrow_forwardTake number n from user and create an array A of random integers of sizen. The size of n can be in the order of billion (10^9).a) Find the largest element LP and smallest element SP of the array.b) Swap the position of Largest element and Smallest element in the array callingfunction SWAP (A, LP, SP) by pointer (not reference).c) Then calculate the cumulative sum of the numbers in the array A and put it in thesame array A.arrow_forwardIn C program language, You are to read 10 numbers from a data file into an array named List. Create another 10 element array named Reverse that is to contain the same items as List but in reverse order. For example, the first element in List will be placed in the last position of Reverse, the second element in List will be placed in the second-to-last position in Reverse, etc. After Reverse has been created, output the contents of both arrays.arrow_forward
- Programming ProblemWrite a program to implement the sorting and searching algorithms discussed in the class. Theprogram should display the following menu repeatedly to allow user to read strings into thestring array, print the content of the array, sort the string array elements based on thealphabetic order of the initial letter of each string array element, search for a key letter(one single letter) in the array, or exit from the program.1. Read2. Print3. Sort4. Search0. QuitOption 3 should trigger the following submenu:1. Quick sort2. Merge sort0. QuitOption 4 should use the following submenu:1. Sequential search2. Binary search0. QuitNote• Assume all the input strings start with different letters.• The user is able to determine how many input strings are entered.• The key letter for searching is one single letter, the program should output the position ofthis key letter.Submission:Zip the Java source code folder and Submit it on Blackboard.Grading1. Demonstrate to Instructor (Bonus…arrow_forwardIN C PROGRAMMING LANGUAGE AND COMMENT EVERY LINE PLEASE SO I CAN UNDERSTAND EVERY STEP , The selection sort is one of several techniques for sorting an array. A selection sort compares every element of an array with all the other elements of the array and exchanges their values if they are out of order. After the first pass of a selection sort, the first array element is in the correct position; after the second pass the first two elements of the array are in the correct position, and so on. Thus, after each pass of a selection sort, the unsorted portion of the array contains one less element. Write and test a function that implements this sorting method.arrow_forward1.3 Write a complete algorithm to solve the following problem: You have been tasked to develop a payroll system for a company to calculate the net salary that each employee must receive. The information about each employee is stored in 5 parallel arrays, with examples of the values in the arrays, as follows: empNum empName empGrossSal numDependants taxPerc 813465 T Mahlangu 10200.00 3 20% 548926 R Pretorius 15700.00 1 35% 662908 K More 12600.00 4 30% 713890 F Knauff 5200.00 2 18% 412579 V Raphiri 35000.00 2 45% 916356 H Raseroka 11500.00 4 27% 528349 M Malebane 13000.00 1 30% 920345 Z Kgoete 10500.00 0 25% 710293 S Meintjes 7800.00 2 15% . . . . . 820394 T Radebe 5800.00 3 0% You can assume that there are…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning