Draw the recursion tree for bubblesort

Assignment Help Computer Engineering
Reference no: EM133482114

Question:Shown below is the code for the bubble sort consisting of two recursive methods that replace the two nested loops that would be used in its iterative counterpart:

void bubbleSort(int array[]) { sort(array, 0);

} void sort(int[] array, int i) {

if (i < array.length - 1) { bubble(array, i, array.length - 1); sort(array, i + 1);

}

}

void bubble(int[] array, int i, int j) { if (j <= i)

return;

if (array[j] < array[j - 1]) { int temp = array[j];

array[j] = array[j - 1]; array[j - 1] = temp;

}

bubble(array, i, j - 1);

}

Question 1. Draw the recursion tree for bubbleSort when it is called for an array of length 4 with data that represents the worst case. Show the activations of bubbleSort, sort and bubble in the tree. Explain how the recursion tree would be different in the best case.

Question 2. Refer back to the recursion tree you provided in the previous problem. Determine a formula that counts the numbers of nodes in that tree. What is Big-O for execution time? Determine a formula that expresses the height of the tree. What is the Big-O for memory?

Reference no: EM133482114

Questions Cloud

Describe how the estimated variability in selling prices : Describe how the estimated variability in selling prices varies as the mean selling price varies from 100 thousand to 500 thousand dollars
Define business profiles, processes and modeling : Define business profiles, processes, and modeling. Explain the difference between vertical and horizontal systems packages.
What are some examples of form validation we would want : What are some examples of form validation we would want to do solely on the server? When might we do it only on the client?
Develop a strategy for backing up the company : What do you need to consider while deciding the best specifications for processor, memory, and disk space
Draw the recursion tree for bubblesort : List the capabilities that any data and information processor, whether organic, mechanical, electrical, or optical, must have
Discuss key concepts as they may relate to your chosen case : Discuss key concepts as they may relate to your chosen case. Apply facts from your case to support conclusions on the applicability of concepts.
Calculate the accounts receivable turnover : Calculate the accounts receivable turnover and the average collection period ratio for The Coca-Cola Company for the most current year presented.
Why is governance difficult in cyberspace : Why is governance difficult in cyberspace? Share an example and explain your response
Explain how the functions in your program are designed : Can you explain how the functions in your program are designed to improve modularity, code organization and reusability.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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