Data is stored in the array NameList [1:10]. This data is to be sorted using a bubble
Question:
Data is stored in the array NameList [1:10]. This data is to be sorted using a bubble sort:
a) A special case is when NameList is already in order. The algorithm above is applied to this special case.
Explain how many iterations are carried out for each of the loops.
b) Rewrite the algorithm using pseudocode, to reduce the number of unnecessary comparisons.
Use the same variable names where appropriate.
Transcribed Image Text:
FOR ThisPointer e 1 TO 9 FOR Pointer + 1 TO 9 IF NameList [Pointer] > NameList[Pointer + 1] THEN Temp NameList [Pointer] NameList [Pointer] + NameList [Pointer + 1] NameList (Pointer + 1] Temp ENDIF NEXT NEXT
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (5 reviews)
a For the first loop there will be 9 iterations For the second loop there will be 8 iterat...View the full answer
Answered By
Dansteve Matoke
As a consequence of more than three years of experience in ACADEMIC WRITING, I have vast, diverse knowledge and impeccable grammar. I guarantee the quality of my work across multiple fields. I intend to precisely meet the clients' expectations. Let's work together to achieve exceptional grades.
0.00
0 Reviews
10+ Question Solved
Related Book For
Cambridge International AS & A Level Computer Science
ISBN: 9781510457591
1st Edition
Authors: David Watson, Helen Williams
Question Posted:
Students also viewed these Computer science questions
-
Using a bubble sort involves _____________. a. Comparing parallel arrays b. Comparing each array element to the average c. Comparing each array element to the adjacent array element d. Swapping every...
-
How raster image is stored in the computer memory explain in detail.
-
How much energy is stored in the forewing when a force at the tip deflects it by 3.5 mm? A. 0.766 mJ B. 49.0 mJ C. 0.219 J D. 1.70 kJ 2L/3- 6.0- Hindwing 5.0 1/ Forewing 4.0- 3.0 2.0- Hindwing 3 1.0...
-
Clark had brain surgery. Insurance will not pay for the surgery until the deductible of $1,000 is hit. Then Clark's coinsurance of 80% / 20% kicks in. Clark has an out-of-pocket maximum of $7,500....
-
At Burnt Mesa Pueblo, the method of tree-ring dating gave the following years A.D. for an archaeological excavation site (Bandelier Archaeological Excavation Project: Summer 1990 Excavations at Burnt...
-
1. What should Mary do? 2. What is the difference between real property and intellectual property? Does intellectual property deserve the legal protection we give real property? Why or why not? 3....
-
Co-INSURANCE CLAUSES. Isla Potter had a homeowner's insurance policy with $175,000 of coverage on the dwelling. Would a 90 percent co-insurance clause be better than an 80 per- cent clause in such a...
-
The following data (in pounds), which were selected randomly from a normally distributed population of values, represent measurements of a machine part that is supposed to weigh, on average, 8.3...
-
In distinguishing between an annuity payment and capital instalments of a purchase price, the courts generally: will be governed by the description given by the parties in their agreement. are...
-
A tile-iron consists of a massive plate maintained at 150C by an imbedded electrical heater. The iron is placed in contact with a tile to soften the adhesive, allowing the tile to be easily lifted...
-
a) Write pseudocode to set up a text file to store records like this, with one record on every line. b) Write pseudocode to append a record. c) Write pseudocode to find and delete a record. d) Write...
-
A queue Abstract Data Type (ADT) has these associated operations: Create queue Add item to queue Remove item from queue The queue ADT is to be implemented as a linked list of nodes. Each node...
-
Vivian starts a fraud action against Dennis, a used car seller, arising from the sale of a car. Vivian asserts that Dennis advertised the car as new when in fact its odometer had been set back to...
-
Are there more children diagnosed with Autism Spectrum Disorder (ASD) in states that have larger urban areas over states that are mostly rural? In the state of Pennsylvania, a fairly urban state,...
-
Problem PS9.2.4 0/5 points (graded)Suppose that in this economy all the funds for capital come from savings by the 10 individuals. Firms' demand for capital is given by QD=100100r . What is the...
-
As Renata explained her frustration with a coworker to the human resource manager, the manager quickly averted her eyes and began shuffling papers on her desk. Renata immediately felt uncomfortable....
-
Confidential counselling for mental health issues is available through the organization's: Multiple Choice group insurance plan workers' Compensation plan preventive care program employee recognition...
-
ABC Credit Finance is a credit card provider with regional payment processing centers. You are a manager of one of these centers. You are an at-will employee in a typical at-will jurisdiction. ABC is...
-
A fire destroyed a warehouse of the Goren Group, Inc., on May 4, 2021. Accounting records on that date indicated the following: Merchandise inventory, January 1, 2021 .............$1,900,000...
-
Question 6.10 Current and deferred tax worksheets and tax entries From the hip Ltd?s statement of profit or loss for the year ended 30 June 2007 and extracts from its statements of financial position...
-
The dining philosophers problem is a classic problem of synchronization and concurrency. The general problem is stated as philosophers sitting at a round table doing one of two things: eating or...
-
We would like to execute the loop below as efficiently as possible. We have two different machines, a MIMD machine and a SIMD machine. for (i=0; i < 2000; i++) for (j=0; j <3000; j++) X_array[i][j] =...
-
Refer to Figure 6.14b, which shows an n-cube interconnect topology of order 3 that interconnects 8 nodes. One attractive feature of an n-cube interconnection network topology is its ability to...
-
Use the following information: \ table [ [ Country , \ table [ [ Consumer Prices ] ] , Interest Rates,Current Units ( per US$ ) ] , [ Forecast , 3 - month, 1 - yx Covt Bond,, ] , [ 2 0 2 4 e ,...
-
Year-to-date, Yum Brands had earned a 3.70 percent return. During the same time period, Raytheon earned 4.58 percent and Coca-Cola earned 0.53 percent. If you have a portfolio made up of 40 percent...
-
Rate of Return If State Occurs State of Probability of Economy State of Economy Stock A Stock B Stock C Boom .15 .31 .41 .21 Good .60 .16 .12 .10 Poor .20 .03 .06 .04 Bust .05 .11 .16 .08 a. Your...
Study smarter with the SolutionInn App