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
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_forwardA stable population of 35,000 birds lives on three islands. Each year 10% of the population on island A migrates to island B, 20% of the population on island B migrates to island C, and 5% of the population on island C migrates to island A. Find the number of birds on each island if the population count on each island does not vary from year to year.arrow_forwardThe hard disk drive on a computer holds 800 gigabytes of information. That is 800,000 megabytes. The formatting information, operating system, and applications software take up 4000 megabytes of disk space. The operator wants to store on his computer a collection of digitized pictures, each of which requires 4 megabytes of space. (d) After putting a number of pictures on the disk drive, the operator executes the directory command, and at the end of the list the computer displays the message 748,000,000,000 bytes free. This message means that there are 748,000 megabytes of storage space left on the computer. How many pictures are stored on the disk drive?pictures How many additional pictures can be added before the disk drive is filled?picturesarrow_forward
- The Digital Star Company makes two different models of computer tablets, which are assembled on two different assembly lines. Line 1 can assemble 34 units of the Star model and 40 units of the Prostar model per hour, and line 2 can assemble 170 units of the Star model and 40 units of the Prostar model per hour. The company needs to produce at least 306units of the Star model and 200 units of the Prostar model to fill an order. If it costs $200 per hour to run line 1 and $600 per hour to run line 2, how many hours should each line be run to fill the order at the minimum cost?arrow_forwardThe Royal Fruit Company produces two types of fruit drinks. The first type is 30% pure fruit juice, and the second type is 80% pure fruit juice. The company is attempting to produce a fruit drink that contains 40% pure fruit juice. How many pints of each of the two existing types of drink must be used to make 180 pints of a mixture that is 40% pure fruit juice? Note that the ALEKS graphing calculator can be used to make computations easier.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_forward
- A chemical company makes two brands of antifreeze. The first brand is 45% pure antifreeze, and the second brand is 65% pure antifreeze. In order to obtain 120 gallons of a mixture that contains 60% pure antifreeze, how many gallons of each brand of antifreeze must be used? Note that the ALEKS graphing calculator can be used to make computations easier.arrow_forwardA teacher sees students straggling into her class at highly diverse times. She secretly records when each person comes into her class. Everyone in the class at the bell gets a score of zero. Then, as each late person comes in, the number of seconds after the bell that the person arrives is recorded. Number of seconds late, then, is each person's individual score. The scores ranged from 0 to 600 (for people who were 10 minutes late). The teacher also has each person's exam average over the semester. She wants some estimate of the degree of relationship between a person's lateness and his or her exam scores in her class. Which statistic should she use? a. Z-test b. One Sample t-test c. Independent groups t-test d. Dependent groups t-test e. One Factor ANOVA f. Two factor ANOVA g. t-test for r > 0 h. Chi-square test i. Phi Coefficient j. Cramer’s Phi k. Point Biserial r L. Eta-squared m. r-squared or rarrow_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_forward
- A family is coloring eggs and wants to make two shades of purple, “light purple” and “deep purple”. They have 30 tablespoons of red solution and 2 tablespoons of blue solution. If “light purple” consists of 2% blue solution, and “deep purple” consists of 10% blue solution, how much of each version of purple solution can be created? Let x represent thenumber of tablespoons of “light purple” to be created, and let y represent the number of tablespoons of “deep purple”. Based on the information provided, the two tablespoons of blue solution will be distributed according to the following linear equation. 2 = ? x + ? y Complete the equation above by filling in the boxes, then write a similar linear equation that shows the distribution of the red solution. Solve the resulting system of linear equations.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_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.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_forward
- College Algebra (MindTap Course List)AlgebraISBN:9781305652231Author:R. David Gustafson, Jeff HughesPublisher:Cengage LearningElementary Linear Algebra (MindTap Course List)AlgebraISBN:9781305658004Author:Ron LarsonPublisher:Cengage Learning