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

Other questions on the subject: Business

image
Business, 21.06.2019 23:30, ally0817
Which term refers to the cost that motivates an economic decision
Answers: 1
image
Business, 22.06.2019 01:20, 15krystall
Cindy recently played in a softball game in which she misplayed a ground ball for an error. later, in the same game, she made a great catch on a very difficult play. according to the self-serving bias, she would attribute her error to and her good catch to her
Answers: 1
image
Business, 22.06.2019 07:50, ShawnSaviro4918
In december of 2004, the company you own entered into a 20-year contract with a grain supplier for daily deliveries of grain to its hot dog bun manufacturing facility. the contract called for "10,000 pounds of grain" to be delivered to the facility at the price of $100,000 per day. until february 2017, the supplier provided processed grain which could easily be used in your manufacturing process. however, no longer wanting to absorb the cost of having the grain processed, the supplier began delivering whole grain. the supplier is arguing that the contract does not specify the type of grain that would be supplied and that it has not breached the contract. your company is arguing that the supplier has an onsite processing plant and processed grain was implicit to the terms of the contract. over the remaining term of the contract, reshipping and having the grain processed would cost your company approximately $10,000,000, opposed to a cost of around $1,000,000 to the supplier. after speaking with in-house counsel, it was estimated that litigation would cost the company several million dollars and last for years. weighing the costs of litigation, along with possible ambiguity in the contract, what are three options you could take to resolve the dispute? which would be the best option for your business and why?
Answers: 2
image
Business, 22.06.2019 10:30, khenalilovespandas
Marketing1. suppose the average price for a new disposable cell phone is $20, and the total market potential for that product is $4 million. topco, inc. has a planned market share of 10 percent. how many phones does topco have the potential to sell in this market? 20,0002. use the data from question 3 to calculate topco, inc.'s planned market share in dollars. $400,0003. atlantic car rental charges $29.95 per day to rent a mid-size automobile. pacific car rental, atlantic's main competitor, just reduced prices on all its car rentals. in response, atlantic reduced its prices by 5 percent. now how much does it cost to rent a mid-size automobile from atlantic? $28.45
Answers: 1
You know the right answer?
Stable and unstable sorting 5 points; individual-only sorting algorithms can be applied to records...

Questions in other subjects:

Konu
French, 04.10.2019 20:30