Modification actually improves running time

Assignment Help Basic Computer Science
Reference no: EM133220414

1. The Bubble Sort implementation has the following inner for loop: for (int j=n-1; j>i; j--) Consider the effect of replacing this with the following statement: for (int j=n-1; j>0; j--) Would the new implementation work correctly? Would the change affect the asymptotic complexity of the algorithm? How would the change affect the running time of the algorithm?

2. When implementing Insertion Sort, a binary search could be used to locate the position within the first i - 1 elements of the array into which element i should be inserted. How would this affect the number of comparisons required? How would using such a binary search affect the asymptotic running time for Insertion Sort?

3. Figure 7.5 shows the best-case number of swaps for Selection Sort as Θ(n). This is because the algorithm does not check to see if the ith record is already in the ith position; that is, it might perform unnecessary swaps.

a. (pseudo-code only) Modify the algorithm so that it does not make unnecessary swaps.

b. What is your prediction regarding whether this modification actually improves the running time

4. Recall that a sorting algorithm is said to be stable if the original ordering for duplicate keys is preserved. Of the sorting algorithms Insertion Sort, Bubble Sort, Selection Sort, Shellsort, Mergesort, Quicksort, Heapsort, Binsort, and Radix Sort, which of these are stable, and which are not? For each one, describe either why it is or is not stable. If a minor change to the implementation would make it stable, describe the change.

5. The discussion of Quicksort in Section 7.5 described using a stack instead of recursion to reduce the number of function calls made.

a. How deep can the stack get in the worst case?

b. Quicksort makes two recursive calls. The algorithm could be changed to make these two calls in a specific order. In what order should the two calls be made, and how does this affect how deep the stack can become?

Reference no: EM133220414

Questions Cloud

Describe common application development security faults : Explain the concepts of default deny, need-to-know, and least privilege. Describe the most common application development security faults.
Information technology practitioner : Why are softskills important to your success as an information technology practitioner? What improvement do you recommend for the course?
Analyze the potential implications : Sort and review the various directories within the Mac OS X image. Analyze the potential implications of these findings for the company and for a legal case.
The system analysis and design project on banking system : The project requires students to perform three phases requirements analysis, system and database design, and a project plan.
Modification actually improves running time : What is your prediction regarding whether this modification actually improves the running time. How deep can the stack get in the worst case?
Greedy method scheduling to minimize lateness : In Greedy Method scheduling to minimize lateness, can a schedule of jobs that contains some idle time be still optimal? Explain.
Progress in accomplishing your educational goals : Why are softskills important to your success as an information technology practitioner? What is your progress in accomplishing your educational goals?
Cross-platform technologies in private and professional life : Are you more aware of the impact that cross-platform technologies has on your daily life? Cross-platform technologies in private and professional life?
Consider distributed ?le system : Consider a distributed ?le system that uses per-user name spaces. Can names from such name spaces be used to share resources between two different users?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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