The bubble sort is an inefficient, but easy-to-program, sorting technique. The idea behind the sort is to move down through an array comparing adjacent pairs and swapping the values if they are out of order. For this method to sort the array completely, it may need to pass through it many times. As the passes proceed for an ascending-order sort, the smaller elements in the array appear to rise toward the top like bubbles. Eventually, there will be a pass through the array where no swaps are required. Then, the array is sorted. After the first pass, the largest value in the array drops directly to the bottom. Consequently, the second pass only has to proceed to the second-to-last value, and so on. Develop a program to set up an array of 20 random numbers and sort them in ascending order with the bubble sort (Fig. P2.12).
FIGURE P2.12
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Numerical Methods For Engineers, 7 Ed
Additional Math Textbook Solutions
Basic Technical Mathematics
Fundamentals of Differential Equations (9th Edition)
Advanced Engineering Mathematics
Thinking Mathematically (6th Edition)
- Find the sequence of the elementary matrices whose product is the non singular matrix below. [2410]arrow_forwardThe Phony TV company makes two different types of television sets, OLED and LED, which are assembled by two different assembly lines. When Line One operates it assembles 30 units of the OLED model and 50 units of the LED model per hour. Line Two assembles 40 units of the OLED model and 40 units of the LED model per hour. Let x be the number of hours that Line One operates and y the number of hours Line Two operates. Phony needs to produce at least 3000 units of the OLED model and 4000 units of the LED model to fill an order. (a) Write down the inequalities that describe the assembly constraints. (b) Graph the feasible region determined by these constraints.arrow_forwardanswer part 2 onlyarrow_forward
- Anela is a computer scientist who is formulating a large and complicated program for a type of data processing. Anela has three ways of storing and retrieving data: cloud storage, disk, or hard drive. As an experiment, Anela sets up her program in three different ways: one using cloud storage, one using disks, and the other using a hard drive. Then Anela makes four test runs of this type of data processing on each program. The time required to execute each program is shown in the following table (in minutes). Use a 0.01 level of significance to test the hypothesis that the mean processing time is the same for each method. Hard Drive Cloud Disks 8.7 7.2 7.0 9.3 9.1 6.4 7.9 7.5 9.8 8.0 7.7 8.2arrow_forwardA carpenter builds bookshelves and tables for a living. Each bookshelf takes one box of screws, two 2 ✕ 4's, and three sheets of plywood to make. Each table takes two boxes of screws, two 2 ✕ 4's, and four sheets of plywood. The carpenter has 55 boxes of screws, 70 2 ✕ 4's, and 115 sheets of plywood on hand. In order to maximize their profit using these materials on hand, the carpenter has determined that they must build 10 shelves and 20 tables. How many of each of the materials (boxes of screws, 2 ✕ 4's, and sheets of plywood) are leftover, when the carpenter builds 10 shelves and 20 tables? The carpenter has _ boxes of screws, _ 2 ✕ 4's, and _ sheets of plywood leftover.arrow_forwardAnela is a computer scientist who is formulating a large and complicated program for a type of data processing. She has three ways of storing and retrieving data: cloud storage, disk, or hard drive. As an experiment, she sets up her program in three different ways: one using cloud storage, one using disks, and the other using a hard drive. Then she makes four test runs of this type of data processing on each program. The time required to execute each program is shown in the following table (in minutes). Use a 0.01 level of significance to test the hypothesis that the mean processing time is the same for each method. Hard Drive Cloud Disks 8.4 6.8 7.2 9.3 9.6 6.8 8.1 7.0 9.6 8.3 7.9 8.6 (ii) Find the sample test statistic. (Round your F Ratio to two decimal places. Round all other answers to four decimal places.) (vi) In the case of one-way ANOVA, make a summary table. (Round your answers to three decimal places.)arrow_forward
- Anela is a computer scientist who is formulating a large and complicated program for a type of data processing. She has three ways of storing and retrieving data: cloud storage, disk, or hard drive. As an experiment, she sets up her program in three different ways: one using cloud storage, one using disks, and the other using a hard drive. Then she makes four test runs of this type of data processing on each program. The time required to execute each program is shown in the following table (in minutes). Use a 0.01 level of significance to test the hypothesis that the mean processing time is the same for each method. Hard Drive Cloud Disks 8.8 7.5 7.1 8.8 9.2 6.6 8.0 7.2 10.2 7.6 7.9 8.0 (i) Give the value of the level of significance. (ii) Find the sample test statistic. (Round your F Ratio to two decimal places. Round all other answers to four decimal places.) (vi) In the case of one-way ANOVA, make a summary table. (Round your answers to three decimal places.)…arrow_forwardThe Gotham City Police Department employs 30police officers. Each officer works 5 days per week. Thecrime rate fluctuates with the day of the week, so the numberof police officers required each day depends on which dayof the week it is: Saturday, 28; Sunday, 18; Monday, 18;Tuesday, 24; Wednesday, 25; Thursday, 16; Friday, 21. Thepolice department wants to schedule police officers tominimize the number whose days off are not consecutive.Formulate an LP that will accomplish this goal. (Hint: Havea constraint for each day of the week that ensures that theproper number of officers are not working on the given day.)arrow_forwardA company has 288 sales representatives, each to be assigned to one of four marketing teams. If the first team is to have three times as many members as the second team and the third team is to have twice as many members as the fourth team, how can the members be distributed among the teams? (Let x denote the number of members assigned to the first team, y the number assigned to the second team, z the number assigned to the third team, and w the number assigned to the fourth team. Let w be the parameter.)arrow_forward
- Draw the cuts in A (2 by 3) and B (3 by 4) and AB to show how each of the four multiplication rules is really a block multiplication:(1) Matrix A times columns of B. Columns of AB(2) Rows of A times the matrix B. Rows of AB(3) Rows of A times columns of B. Inner products (numbers in AB)(4) Columns of A times rows of B. Outer products (matrices add to AB)arrow_forwardOliver starts with a collection of bricks in which the combined number of blue and green bricks is odd. Explain why he cannot end up with a combined number of blue and green bricks that is even.arrow_forwardDonna wants to grow corn on the farm she just bought. The previous farmer grew corn for several decades and kept detailed records of his crop production each year. These records include the amount of sunlight, the amount of rain, the average yield, and other such figures. In an effort to help Donna out, the previous farmer compares his records of using two popular fertilizers: Earthy and SunX. He pulls his records for the 7 seasons he used Earthy on his corn and the records for the 7 seasons that he used SunX on his corn. He uses these records to compare the average corn yield for the 7 seasons that he used Earthy to the average corn yield for the 7 seasons that he used SunX. If applicable, he will recommend the better fertilizer to Donna. (a)First choose whether the procedure described above is an observational study or a designed experiment. Then further categorize the procedure by choosing the correct type of observational study or designed experiment. Observational study Designed…arrow_forward
- Linear Algebra: A Modern IntroductionAlgebraISBN:9781285463247Author:David PoolePublisher:Cengage LearningCollege Algebra (MindTap Course List)AlgebraISBN:9781305652231Author:R. David Gustafson, Jeff HughesPublisher:Cengage LearningAlgebra & Trigonometry with Analytic GeometryAlgebraISBN:9781133382119Author:SwokowskiPublisher:Cengage
- Elementary Linear Algebra (MindTap Course List)AlgebraISBN:9781305658004Author:Ron LarsonPublisher:Cengage LearningAlgebra for College StudentsAlgebraISBN:9781285195780Author:Jerome E. Kaufmann, Karen L. SchwittersPublisher:Cengage LearningAlgebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal Littell