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
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 2 Solutions
Numerical Methods For Engineers, 7 Ed
Additional Math Textbook Solutions
Math in Our World
Pathways To Math Literacy (looseleaf)
Precalculus
Precalculus: Mathematics for Calculus (Standalone Book)
Elementary and Intermediate Algebra: Concepts and Applications (7th Edition)
College Algebra (7th Edition)
- Your employer automatically puts 5 percent of your salary into a 401(k) retirement account each year. The account earns 8% interest. Suppose you just got the job, your starting salary is $40000, and you expect to receive a 2% raise each year. For simplicity, assume that interest earned and your raises are given as nominal rates and compound continuously. Find the value of your retirement account after 30 years Value = $arrow_forwardSuppose that a room containing 1300 cubic feet of air is originally free of carbon monoxide (CO). Beginning at time t = 0, cigarette smoke containing 4% CO is introduced into the room at a rate of 0.8 cubic feet per minute. The well-circulated smoke and air mixture is allowed to leave the room at the same rate. Let A(t) represent the amount of CO in the room (in cubic feet) after t minutes. (A) Write the DE model for the time rate of change of CO in the room. Also state the initial condition. dA dt A(0) (B) Solve the IVP to find the amount of CO in the room at any time t > 0. A(t) (C) Extended exposure to a CO concentration as low as 0.00012 is harmful to the human body. Find the time at which this concentration is reached. t= minutesarrow_forwardNewton's Law of Cooling tells us that the rate of change of the temperature of an object is proportional to the temperature difference between the object and its surroundings. This can be modeled by the differential equation dT dt k(TA), where T is the temperature of the object after t units of time have passed, A is the ambient temperature of the object's surroundings, and k is a constant of proportionality. Suppose that a cup of coffee begins at 178 degrees and, after sitting in room temperature of 61 degrees for 12 minutes, the coffee reaches 171 degrees. How long will it take before the coffee reaches 155 degrees? Include at least 2 decimal places in your answer. minutesarrow_forward
- can you help me solve this question and show workings pleasearrow_forwardLet f : X → Y and g : Y → Z be two functions. Prove that(1) if g ◦ f is injective, then f is injective; (2) if g ◦ f is surjective, then g is surjective.arrow_forwardSolve the following boundary value problem using method of separation of variables ди 11.07 (137) 1 J²u + = = 0, -Пarrow_forwardNo chatgpt pls will upvotearrow_forwardEach answer must be justified and all your work should appear. You will be marked on the quality of your explanations. You can discuss the problems with classmates, but you should write your solutions sepa- rately (meaning that you cannot copy the same solution from a joint blackboard, for exam- ple). Your work should be submitted on Moodle, before February 7 at 5 pm. 1. True or false: (a) if E is a subspace of V, then dim(E) + dim(E) = dim(V) (b) Let {i, n} be a basis of the vector space V, where v₁,..., Un are all eigen- vectors for both the matrix A and the matrix B. Then, any eigenvector of A is an eigenvector of B. Justify. 2. Apply Gram-Schmidt orthogonalization to the system of vectors {(1,2,-2), (1, −1, 4), (2, 1, 1)}. 3. Suppose P is the orthogonal projection onto a subspace E, and Q is the orthogonal projection onto the orthogonal complement E. (a) The combinations of projections P+Q and PQ correspond to well-known oper- ators. What are they? Justify your answer. (b) Show…arrow_forward1. True or false: (a) if E is a subspace of V, then dim(E) + dim(E+) = dim(V) (b) Let {i, n} be a basis of the vector space V, where vi,..., are all eigen- vectors for both the matrix A and the matrix B. Then, any eigenvector of A is an eigenvector of B. Justify. 2. Apply Gram-Schmidt orthogonalization to the system of vectors {(1, 2, -2), (1, −1, 4), (2, 1, 1)}. 3. Suppose P is the orthogonal projection onto a subspace E, and Q is the orthogonal projection onto the orthogonal complement E. (a) The combinations of projections P+Q and PQ correspond to well-known oper- ators. What are they? Justify your answer. (b) Show that P - Q is its own inverse. 4. Show that the Frobenius product on n x n-matrices, (A, B) = = Tr(B*A), is an inner product, where B* denotes the Hermitian adjoint of B. 5. Show that if A and B are two n x n-matrices for which {1,..., n} is a basis of eigen- vectors (for both A and B), then AB = BA. Remark: It is also true that if AB = BA, then there exists a common…arrow_forwardQuestion 1. Let f: XY and g: Y Z be two functions. Prove that (1) if go f is injective, then f is injective; (2) if go f is surjective, then g is surjective. Question 2. Prove or disprove: (1) The set X = {k € Z} is countable. (2) The set X = {k EZ,nЄN} is countable. (3) The set X = R\Q = {x ER2 countable. Q} (the set of all irrational numbers) is (4) The set X = {p.√2pQ} is countable. (5) The interval X = [0,1] is countable. Question 3. Let X = {f|f: N→ N}, the set of all functions from N to N. Prove that X is uncountable. Extra practice (not to be submitted). Question. Prove the following by induction. (1) For any nЄN, 1+3+5++2n-1 n². (2) For any nЄ N, 1+2+3++ n = n(n+1). Question. Write explicitly a function f: Nx N N which is bijective.arrow_forward3. Suppose P is the orthogonal projection onto a subspace E, and Q is the orthogonal projection onto the orthogonal complement E. (a) The combinations of projections P+Q and PQ correspond to well-known oper- ators. What are they? Justify your answer. (b) Show that P - Q is its own inverse.arrow_forwardDetermine the moment about the origin O of the force F4i-3j+5k that acts at a Point A. Assume that the position vector of A is (a) r =2i+3j-4k, (b) r=-8i+6j-10k, (c) r=8i-6j+5karrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- College Algebra (MindTap Course List)AlgebraISBN:9781305652231Author:R. David Gustafson, Jeff HughesPublisher:Cengage LearningElementary Linear Algebra (MindTap Course List)AlgebraISBN:9781305658004Author:Ron LarsonPublisher:Cengage LearningLinear Algebra: A Modern IntroductionAlgebraISBN:9781285463247Author:David PoolePublisher:Cengage Learning
- Algebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal LittellAlgebra & Trigonometry with Analytic GeometryAlgebraISBN:9781133382119Author:SwokowskiPublisher:CengageAlgebra for College StudentsAlgebraISBN:9781285195780Author:Jerome E. Kaufmann, Karen L. SchwittersPublisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9781305652231/9781305652231_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781305658004/9781305658004_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781285463247/9781285463247_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780395977224/9780395977224_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781285195780/9781285195780_smallCoverImage.gif)