Described using stack instead of recursion to reduce

Assignment Help Basic Computer Science
Reference no: EM133220399

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: EM133220399

Questions Cloud

Effective corporate compliance program : Describe the seven conditions of an effective Corporate Compliance Program. What consequences occur if these conditions are not met?
Discuss why is it important to live by code of ethics : Discuss why is it important to live by a code of ethics. Describe an experience where you have seen technology used for good.
Develop questionaries for getting information : Develop questionaries' for getting information about all user stories and based on that make a list of all user's list and their requirements.
Professional development plan : In this assignment students will prepare their own Professional Development Plan.
Described using stack instead of recursion to reduce : Consider the effect of replacing this with statement. Described using a stack instead of recursion to reduce the number of function calls made.
Consider timed process with input event : Consider a timed process with an input event x and two output events y and z. Whenever the process receives an input event on the channel x,
Think of situation in which using plan like innovation : Think of a situation in which using a plan like an innovation plan to justify taking an action would have impacted some choices you made?
Cloud-based architecture and artificial intelligence : You have learned about a number of cross-platform technology concepts pertaining to virtualization, cloud-based architecture, artificial intelligence,
Information technology practitioner : Why are softskills important to your success as an information technology practitioner? What degree are you working toward? Did you change your major?

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