# Urgent help needed!!!

Watch
Announcements
#1
The algorithm below is a sorting algorithm.

•   Array indexing starts at 0.

•   Line numbers are included but are not part of the algorithm.

1  arr ← [4, 1, 6]

5    i ← 0

6    WHILE i < 2

7      IF arr[i+1] < arr[i] THEN

8        t ← arr[i]

9        arr[i] ← arr[i+1]

10        arr[i+1] ← t

12      ENDIF

13      i ← i + 1

14    ENDWHILE

15  ENDWHILE

Question 1: List all the values that variable ‘i’ will be if the algorithm above is run
Question 2: Perform a bubble sort on the list of numbers you created above. Show each time you make a swap on a new line.

0
4 months ago
#2
First of all don't panic and hey this is a test so no cheating Rammiya. Jk
Basically the list for i is 0,1,2,0,1,2(Some long working out)Since you have to do a bubble sort the working out is 0,1,2,0,1,20,1,0,2,1,20,1,0,1,2,2 1st pass0,0,1,1,2,2 2nd pass0,0,1,1,2,2 3rd pass
From liflesshype
Last edited by Liflesshype; 4 months ago
0
4 months ago
#3
(Original post by Liflesshype)
First of all don't panic and hey this is a test so no cheating Rammiya. Jk
Basically the list for i is 0,1,2,0,1,2(Some long working out)Since you have to do a bubble sort the working out is 0,1,2,0,1,20,1,0,2,1,20,1,0,1,2,2 1st pass0,0,1,1,2,2 2nd pass0,0,1,1,2,2 3rd pass
From Andrea
0
4 months ago
#4
you lot should shush imho
0
4 months ago
#5
ayo these kids lying that other guy adhiran, so u prob know who I am and this is a test so don't cheat, red yellow green
Last edited by lifelesshype; 4 months ago
0
X

new posts
Back
to top
Latest
My Feed

### Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

### See more of what you like onThe Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

### Poll

Join the discussion

Yes (97)
27.71%
No (253)
72.29%