Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why does the inside loop change size? If we had it run from 1 up to the length of the array, we would get the

Why does the inside loop change size? If we had it run from 1 up to the length of the array, we would get the same values. Why is this? What does the change accomplish?
image text in transcribed
image text in transcribed
lab05.m X readfile.mx + El function [] = lab05 (fileName) 1 Command Wind w N 3 4 5 ON temps data dayi day2 day3 array1 array2 array3 1:24; readmatrix (fileName); data (1,:); data (2,:); data (3,:); bubbleSort (day1); bubbleSort (day2); bubbleSort (day3); 7 8- 1 9 10 12 13 14 15 16 - 17 - figure subplot (2,1,1); plot(temps, day, 'r-'); hold on plot (temps, day2,'g-'); hold on plot (temps, day3, 'b-'); title(['Temps (not bubble sorted)'); xlabel('Hour'); ylabel('Degrees'); legend ('Day 1', 'Day 2', 'Day 3'); hold off 18 19 20 21 22 - 23 24 lab05.mx readfile.mx+ 15 Command Wind 16 17 hold on plot (temps, day2, '9-'); hold on plot(temps, day3, '-'); title('Temps (not bubble sorted)'); xlabel('Hour'); ylabel('Degrees'); legend ("Day 1', 'Day 2', 'Day 3'); hold off . 18 19- 20- 21 22 23- 24 25 26 27- 28 - 29- 30 - 31- 32 33 - 34 - subplot (2,1,2); plot (temps, array, 'r-'); hold on plot (temps, array2,'-'); hold on plot (temps, array3, 'b-'); title(['Temps (bubble sorted)']); xlabel('Hour'); ylabel('Degrees'); legend ('Day 1', 'Day 2', 'Day 3'); hold of 35 - end 36- 37 38 - 39 40 41 - 42- 43- 44 45 46 47 48 El function (array] - bubbleSort (array) for indexOuter - 1: length(array) - 1 for indexInner - 1: length(array) - IndexOuter if array(indexInner) > array(indexInner + 1) array - swap (array, indexInner); end end end end 50 51 52 53 El function Carray nwap (array, i) templar array(); array(1) array(i + 1); array(i+1)= tempVary end

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

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions