Simple insertion sort

Assignment Help Business Economics
Reference no: EM131950354

1. How many comparisons and interchanges (in terms of file size n) are performed by Simple insertion sort for the following files:

i) A sorted file

ii) A file that is sorted in reverse order (that is, from largest to smallest)

iii) A file in which x[0], x[2], x[4]... are the smallest elements in sorted order, and in which x[1], x[3], x[5]... are the largest elements in sorted order, e.g. [ 3 14 5 15 9 18 11 19 ].

2. How many comparisons and interchanges (in terms of file size n) are performed by Shell Sort using increments 2 and 1 for the following files:

i) A sorted file

ii) A file that is sorted in reverse order (that is, from largest to smallest)

iii) A file in which x[0], x[2], x[4]... are the smallest elements in sorted order, and in which x[1], x[3], x[5]... are the largest elements in sorted order, e.g. [ 3 14 5 15 9 18 11 19 ].

3. Determine which of the following sorts is most efficient. Consider if the data is small and simple or larger and more complex.

a) simple insertion sort

b) straight selection sort

c) bubble sort

4. Determine the number of comparisons (as a function of n and m) that are performed in merging two ordered files a and b of sizes n and m, respectively, by the merge method presented in the lecture, on each of the following sets of ordered files:

a. m=n and a[i] < b[i] < a[i+1], e.g. a=[ 6, 9, 12, 15, 29, 37] and b = [8, 10, 14, 25, 33, 45]

b. m=n and a[n] < b[1], e.g. a =[ 2, 5, 9] and b = [12, 14, 16]

a[i] refers the value in position i of file a, etc.

5. Determine the number of comparisons (as a function of n and m) that are performed in merging two ordered files a and b of sizes n and m, respectively, by the merge method presented in the lecture, on each of the following sets of ordered files:

a. m=n and a[n/2] < b[1] < b[m] < a[(n/2)+1],

e.g. a = [2, 5, 7, 55, 61, 72] and b =[9, 15, 17, 21, 29, 46]

b. m=1 and b[1] < a[1]

c. m=1 and a[n] < b[1]

a[i] refers the value in position i of file a, etc.

For questions 6 - 9, compare the efficiency of using sequential search on an ordered table of size n and an unordered table of the same size for the key key:

6. If no record with the key key is present

7. If one record with the key key is present and only one is sought.

8. If more than one record with the key key is present and it is desired to find only the first

9. If more than one record with the key key is present and it is desired to find them all.

Reference no: EM131950354

Questions Cloud

Enter annual equivalent cost as positive number for machine : Enter the Annual Equivalent Cost (AEC) as a POSITIVE number for the machine that should be selected.
What is meaning that many of the qualitative studies : In terms of data collection, what is meaning that many of the qualitative studies are characterized by an emerging design?
Why instructors give you so many written assignments : Have you ever wondered why instructors give you so many written assignments? The answer is because writing helps you develop in many ways.
What experience do you have with research : What degree are you pursuing, how far along are you, and what are your employment goals after graduation? What experience do you have with research?
Simple insertion sort : 1. How many comparisons and interchanges (in terms of file size n) are performed by Simple insertion sort for the following files:
Design a set of PID controllers to control Euler angles : Create a closed-loop simulation using MATLAB and Simulink as shown in Fig. 2. In these simulations: Design a set of PID controllers to control Euler angles
Write brief summary of your plan of presenting the evidence : Introduction: In the initial draft, include your topic, your claim that you plan to defend, and a brief summary of your plan of presenting the evidence.
Write a report of the development of sales in industria : STAT 6003: Statistics for Financial Decisions - Write a report of the development of sales in Industria, Nokaragua and the Federated Islands over the past 25
What is difference between alpha and beta risk : What is the difference between alpha and beta risk? Which one can be reduced through diversification?

Reviews

Write a Review

Business Economics Questions & Answers

  Economics assignment

This document contains various important questions and their appropriate answers in the subject field of Economics.

  Demand and supply curves

Economics is the study of the principles governing the allocation of scarce means among competing ends when the objective of the allocation is to maximize the attainment of the ends.

  Long-run perfectly competitive equilibrium for the firm

Evaluate Government intervene and correct this situation?(a) Explain the concept of a concentration ratio. A rise in the price of magarine Explain the impact of external costs and external benefits on resource allocation long-run perfectly c..

  Supply and demand diagrams

Explain each of the following using supply and demand diagrams,  With the use of a graph, explain how these two programs affect cigarette consumption and the price of cigarettes.

  Case study: fisher-price toys

The case study of the Fisher-Price Toys, Inc., a popular case in basic economics and management from the prestigious Harvard Business School.

  Draw the production possibility curve

Draw the production possibility curve and a. Define consumer surplus and producer surplus.

  Tax revenue

The Australian government administers two programs that affect the market for cigarettes

  Maximize total welfare

How many tickets to sell to maximize total welfare.

  Difference between the cv and the ev

The change in consumer surplus (?CS) is not "theoretically" justifiable like the CV and EV but it continues to be the most widely used measure of consumer welfare change. Explain how this can be reconciled

  Depict von neumann-morgenstern utility index u in a diagram

Depict the von Neumann-Morgenstern utility index u in a diagram

  What is the market solution

What is the market solution (market price and quantity) and What is the total surplus of the society under the market solution

  Calculate gross national product and net national product

Calculate gross national product and net national product

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd