subject
Business, 19.11.2019 06:31 yuvallevy14

Stable and unstable sorting 5 points; individual-only sorting algorithms can be applied to records of data, where each record consists of multiple fields. in such contexts, the sorting algorithm orders the records according to one of the fields, and the value of that field is referred to as the key of the record. a sorting algorithm is stable if it preserves the order of elements with equal keys. for example, given the following array: {32, 12a, 4, 12b, 39, 19} where 12a and 12b represent records that both have a key of 12, a stable sorting algorithm would produce the following sorted array: {4, 120, 12b, 19, 32, 39} note that 12a comes before 12b, just as it did in the original, unsorted array. insertion sort is an example of a stable sorting algorithm. stability can be useful if you want to sort on the basis of two different fields-for example, if you want records sorted by last name and then, within a given last name, by first name. you could accomplish this in two steps: (1) use any sorting algorithm to sort the records by first name, and (2) use a stable sorting algorithm to sort the records by last name. because the second algorithm is stable, it would retain the order of records with the same last name, and thus those records would remain sorted by first name. by contrast, an unstable sorting algorithm may end up reversing the order of elements with equal keys. for example, given the same starting array shown above, an unstable sorting algorithm could produce either of the following arrays: {4, 120, 12b, 19, 32, 39} {4, 126, 12a, 19, 32, 39} selection sort is an example of an unstable sorting algorithm. construct an example of an input array containing two elements with equal keys whose order is reversed by selection sort. explain why selection sort would result in an unstable sorting algorithm while insertion sort would result in a stable sort on the exact same array.

ansver
Answers: 2

Another question on Business

question
Business, 22.06.2019 05:20
Social computing forces companies to deal with customers as opposed to
Answers: 2
question
Business, 22.06.2019 11:00
Down under products, ltd., of australia has budgeted sales of its popular boomerang for the next four months as follows: unit salesapril 74,000may 85,000june 114,000july 92,000the company is now in the process of preparing a production budget for the second quarter. past experience has shown that end-of-month inventory levels must equal 10% of the following month’s unit sales. the inventory at the end of march was 7,400 units.required: prepare a production budget by month and in total, for the second quarter.
Answers: 3
question
Business, 22.06.2019 11:30
Mark knopf is an auditor who has been asked to provide an audit and financial statement certification for a company that is going public on the new york stock exchange. knopf wants to know his personal liability if the company provides him with inaccurate or false information. which of the following sources of law will him answer that question? a. the city ordinances where the company headquarters is located. b. the state constitution of the state where the company is incorporated. c. code of federal regulations. d. all of the above
Answers: 1
question
Business, 22.06.2019 16:20
The assumptions of the production order quantity model are met in a situation where annual demand is 3650 units, setup cost is $50, holding cost is $12 per unit per year, the daily demand rate is 10 and the daily production rate is 100. the production order quantity for this problem is approximately:
Answers: 1
You know the right answer?
Stable and unstable sorting 5 points; individual-only sorting algorithms can be applied to records...
Questions
question
Mathematics, 27.01.2021 14:00
question
Mathematics, 27.01.2021 14:00
question
Biology, 27.01.2021 14:00
question
Mathematics, 27.01.2021 14:00
question
Mathematics, 27.01.2021 14:00
question
English, 27.01.2021 14:00
question
Mathematics, 27.01.2021 14:00
Questions on the website: 13722363