Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. BubbleSort( a1,... , an, array of integers) 1. Fori from 1 to n-1 2. For i from 1 to n-i jaj+1 then Interchange aj

image text in transcribed

1. BubbleSort( a1,... , an, array of integers) 1. Fori from 1 to n-1 2. For i from 1 to n-i jaj+1 then Interchange aj and aj+1 4. RevisedBubbleSort( a1,... , an, array of integers) 1 For i from 1 to n 1 2. done = true For j from 1 to n - i f aj > aj+1 then Interchange aj and aj done = false 5. 6. 7. 8. If done = true then rea (a) (2 points) How many comparisons does BubbleSort make on an array of size n that is already sorted from smallest to largest? (b) (2 points) How many comparisons does BubbleSort make on an array of size n that is sorted from largest to smallest? (c) (2 points) What are the big-Theta classes for the runtimes of the best case and worst cases of BubbleSort? (h) (2 points) List all possible arrays containing the numbers 1, 2, 3, 4, and 5 for which RevisedBub- bleSort will terminate with a value of 2-2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions