Suppose you are given a list of n distinct elements. You are asked to sort this...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Suppose you are given a list of n distinct elements. You are asked to sort this list in descending order (from greatest to smallest) using Insertion Sort algorithm: The informal description of InsertionSort (n): Let pointer be the pointer which splits the list into two parts: everything on the left including the pointer will be sorted and everything on the right is unsorted. We start with pointer 1. Then we repeat the following steps until the pointer becomes n take the first element to the right of the pointer, find an appropriate position in the ordered part of the list where it can be inserted so that the ordered part remains ordered. The move the element to this position; increase pointer by 1. = (a) Based on the informal description of Insertion Sort (n) (see above) design a step-by- step algorithm which can easily be turned into a code. (You do not have to follow the official version of Insertion Sort.) (b) Find the running time of your algorithm. An elementary operation here is either a data move or a comparison. Suppose you are given a list of n distinct elements. You are asked to sort this list in descending order (from greatest to smallest) using Insertion Sort algorithm: The informal description of InsertionSort (n): Let pointer be the pointer which splits the list into two parts: everything on the left including the pointer will be sorted and everything on the right is unsorted. We start with pointer 1. Then we repeat the following steps until the pointer becomes n take the first element to the right of the pointer, find an appropriate position in the ordered part of the list where it can be inserted so that the ordered part remains ordered. The move the element to this position; increase pointer by 1. = (a) Based on the informal description of Insertion Sort (n) (see above) design a step-by- step algorithm which can easily be turned into a code. (You do not have to follow the official version of Insertion Sort.) (b) Find the running time of your algorithm. An elementary operation here is either a data move or a comparison.
Expert Answer:
Answer rating: 100% (QA)
a Algorithm for Insertion Sort 1 Start with pointer 1 2 Repeat the following steps until the pointer ... View the full answer
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these programming questions
-
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...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
1. How far can an economist contribute to this normative debate over the desirability of an excise tax? 2. What is the excess burden of a lump-sum tax? (For a clue, see Figure 12.14.)
-
What options can you use to withdraw money from a mutual fund?
-
For the following exercises, use the matrices below to perform the indicated operation if possible. If not possible, explain why the operation cannot be performed. Use a calculator to verify your...
-
The frequency distribution from Example 7 is shown below. Find the probability of randomly selecting a social networking site user who is not 23 to 35 years old. Data from Example 7 A company is...
-
Provide examples of (a) intrasender role conflict, (b) intersender role conflict, (c) interrole conflict, and (d) personrole conflict that you have experienced.
-
Find an example of a physical force from within the New Testament and discuss the example. Be sure to provide the scripture reference. Physical force means an event that occurred during biblical...
-
A probability plot of 66 yr of peak discharges for the Kentucky River near Salvisa, Kentucky, is shown in Fig. P3-19 (a) What probability distribution is being used? (b) What are the mean and...
-
Discuss how Spotify uses its corporate culture to create a competitive advantage. Provide examples supported by your analysis
-
Which of the following is an activity not usually associated with forensic accounting and fraud examination consulting and litigation support? 1. A. Assessing fraud risk associated with internal...
-
Washington Tennis & Education Foundation, Inc. (WTEF) is a nonprofit organization operating in the District of Columbia that provides athletic and academic programs for children from low-income...
-
Stone Brewing Co. is a San Diego brewer that has sold its beers for over two decades. Stone has maintained its trademark and brand from the beginning, registering the STONE mark in 1998. Stone has...
-
In a contract dispute between a US company and a Canadian company, the contract itself referred to provisions of the Uniform Commercial Code. Do these references alone preempt the contract from being...
-
Lynn Goldsmith is a photographer known for her photographs of famous musicians. In 1981, Goldsmith had a photography session with the singer Prince. Three years later, Vanity Fair obtained a license...
-
You have recently been appointed Category Manager for nuts and bolts at IndustryCo, a manufacturer with a large demand for bolts at its three (3) factories. You have surveyed the market and found...
-
A copper wire (density = 8.96 g/cm 3 ) has a diameter of 0.25 mm. If a sample of this copper wire has a mass of 22 g, how long is the wire?
-
An algorithm takes 0.5 ms for input size 100. How long will it take for input size 500 if the running time is the following (assume low-order terms are negligible): a. Linear b. O(N logN) c....
-
Merge the two leftist heaps in Figure 6.58. 11 (10 12 17 (18) 11 21 18 15 (31)
-
a. Show that if all nodes in a splay tree are accessed in sequential order, the resulting tree consists of a chain of left children. b. Show that if all nodes in a splay tree are accessed in...
-
Using a financial calculator, solve for the unknowns in each of the following situations. a. On June 1, 2024, Holly Golightly purchases lakefront property from her neighbor, George Peppard, and...
-
Sally W. Emanual, a teacher, had the following dividends and interest during 2022: Additional information pertaining to Sally Emanual includes The taxable portion of the pension is \($7,000.\) Sally...
-
Ed owns Oak Knoll Apartments. During the year, Fred, a tenant, moved to another state. Fred paid Ed \($1,000\) to cancel the two-year lease he had signed. Ed subsequently began renting the unit to...
Study smarter with the SolutionInn App