Complete the code as required in the file. note: I want to print the names in order
Fantastic news! We've Found the answer you've been seeking!
Question:
Complete the code as required in the file.
note:
I want to print the names in order
Transcribed Image Text:
Warning! Algorithms Lab Adhere to the Code of Academic Integrity. You may discuss background issues and general strategies with others and seek help from course instructor, but the implementations that you submit must be your own. You are not allowed to work out the detailed coding and solutions with others, copy code from published/Internet sources or let others to do coding for you. If you feel that you cannot complete the checkpoint on you own, seek help from the course instructor. Checkpoint 3: Sorting Algorithm For your third checkpoint, you will implement two sorting algorithms, Bub- ble Sort and Selection Sort. The implemented algorithms shall sort an array of objects from type Person into ascending lexicographic order by name, if two Persons have the exact same name, sort them by age. Checkpoint 3.1: Bubble Sort Bubble sort is a popular sorting algorithm. It works by repeatedly swapping adjacent elements that are out of order. Algorithm 1 BUBBLE-SORT BUBBLE-SORT(A) 1: for each i = 1 to size(A) do 2: 3: 4: for each j = size(A) to i+1 do if A[j] <A[j-1] then A[j] + A[j-1] Given the short description and algorithm above, you are asked to implement bubble sort algorithm. You must handle exceptions by returning the array with no modification. Warning! Algorithms Lab Adhere to the Code of Academic Integrity. You may discuss background issues and general strategies with others and seek help from course instructor, but the implementations that you submit must be your own. You are not allowed to work out the detailed coding and solutions with others, copy code from published/Internet sources or let others to do coding for you. If you feel that you cannot complete the checkpoint on you own, seek help from the course instructor. Checkpoint 3: Sorting Algorithm For your third checkpoint, you will implement two sorting algorithms, Bub- ble Sort and Selection Sort. The implemented algorithms shall sort an array of objects from type Person into ascending lexicographic order by name, if two Persons have the exact same name, sort them by age. Checkpoint 3.1: Bubble Sort Bubble sort is a popular sorting algorithm. It works by repeatedly swapping adjacent elements that are out of order. Algorithm 1 BUBBLE-SORT BUBBLE-SORT(A) 1: for each i = 1 to size(A) do 2: 3: 4: for each j = size(A) to i+1 do if A[j] <A[j-1] then A[j] + A[j-1] Given the short description and algorithm above, you are asked to implement bubble sort algorithm. You must handle exceptions by returning the array with no modification.
Expert Answer:
Answer rating: 100% (QA)
To print the names of the persons in order after sorting them using either Bubble Sort or Selection ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
What pricing system is used to price the water you use at your college or university? Does this pricing system affect your behavior about water use (length of showers, etc.)? How? Could you recommend...
-
On November 14, 2016, Noel sells 2,000 shares of Marker, Inc., stock for $6,000. He had purchased the stock 2 years earlier for $10,000. Because the price of the stock continued to drop, Noel...
-
G. Olde and R. Young share income on a 6 : 4 basis. They have capital balances of $100,000 and $70,000, respectively, when K.Twener is admitted to the partnership. Instructions Prepare the journal...
-
Determine whether each of the following statements is true or false: Management accountants should be proficient in Excel.
-
SolarFlex is a small but very innovative manufacturer of cutting-edge solar panels. A significant portion of the company's success is due to technologically superior product design. SolarFlex has...
-
Differentiate between accelerator principle of investment and investment multiplier. Explain the determinants of induced investment in an economy. Given C=a+bY, explain "a" and "b" and then sketch...
-
Your friend, Suzie Chang, has designed a new type of outdoor toy that helps children learn basic concepts such as colors, numbers, and shapes. Suzie's product will target two groups: day care centers...
-
Simple Interest Compound Interest Formula Sheet A = Po(1+rt) r PN = Po(1 + 1) Nk k final balance - starting principal starting principal Nk d((1+)-1 -1) Annual Percentage APY = Yield Savings Annuity...
-
What kind of fund reports its operating results in a statement of revenues, expenses, and changes in net position? Explain.
-
What is the time complexity of the following algorithm: m=a i=1 while (i
-
What is workforce planning, and why is it important in HR management?
-
Darcy's law states that v=ki. This simple law is generally valid for seepage in soils of particle size up to coarse sands only, why is this so? [4 marks] A natural residual soil has the grain size...
-
Locate the centroid y of the channel's cross-sectional area. Note: your solution must include drawing showing the numbering segment and the tabulated area of each segment and its respective centroid....
-
Identify Thank You mission, strategy and core competencies. Identify strategy changes that have taken place at Thank You since its founding in 2008. Your answer must in text references and must be...
-
Ann hires a nanny to watch her two children while she works at a local hospital. She pays the 19-year-old nanny $125 per week for 48 weeks during the current year. a. What is the employer's portion...
-
Greg died on July 1, 2012, and left Lea, his wife, a $50,000 life insurance policy which she elects to receive at $5,000 per year plus interest for 10 years. In the current year, Lea receives $6,200....
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
The file ApplianceShipments.csv contains the series of quarterly shipments (in million dollars) of US household appliances between 1985 and 1989 (data courtesy of Ken Black). a. Create a...
-
Canadian Manufacturing Workers Workhours. The time plot in Figure 17.9 describes the average annual number of weekly hours spent by Canadian manufacturing workers (data are available in...
-
Souvenir Sales. The file SouvenirSales.csv contains monthly sales for a souvenir shop at a beach resort town in Queensland, Australia, between 1995 and 2001. [Source: Hyndman and Yang (2018).] Back...
Study smarter with the SolutionInn App