You are on page 1of 75

Bubble Sort Algorithm

i i+1

8 10 3 6 5 1 9 7 2 4

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 1
Bubble Sort Algorithm

i i+1

8 10 3 6 5 1 9 7 2 4

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 2
Bubble Sort Algorithm

i i+1

8 3 10 6 5 1 9 7 2 4

Swapped i-th and (i + 1)-th element

10/28/18 3
Bubble Sort Algorithm

i i+1

8 3 10 6 5 1 9 7 2 4

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 4
Bubble Sort Algorithm

i i+1

8 3 6 10 5 1 9 7 2 4

Swapped i-th and (i + 1)-th element

10/28/18 5
Bubble Sort Algorithm

i i+1

8 3 6 10 5 1 9 7 2 4

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 6
Bubble Sort Algorithm

i i+1

8 3 6 5 10 1 9 7 2 4

Swapped i-th and (i + 1)-th element

10/28/18 7
Bubble Sort Algorithm

i i+1

8 3 6 5 10 1 9 7 2 4

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 8
Bubble Sort Algorithm

i i+1

8 3 6 5 1 10 9 7 2 4

Swapped i-th and (i + 1)-th element

10/28/18 9
Bubble Sort Algorithm

i i+1

8 3 6 5 1 10 9 7 2 4

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 10
Bubble Sort Algorithm

i i+1

8 3 6 5 1 9 10 7 2 4

Swapped i-th and (i + 1)-th element

10/28/18 11
Bubble Sort Algorithm

i i+1

8 3 6 5 1 9 10 7 2 4

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 12
Bubble Sort Algorithm

i i+1

8 3 6 5 1 9 7 10 2 4

Swapped i-th and (i + 1)-th element

10/28/18 13
Bubble Sort Algorithm

i i+1

8 3 6 5 1 9 7 10 2 4

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 14
Bubble Sort Algorithm

i i+1

8 3 6 5 1 9 7 2 10 4

Swapped i-th and (i + 1)-th element

10/28/18 15
Bubble Sort Algorithm

i i+1

8 3 6 5 1 9 7 2 10 4

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 16
Bubble Sort Algorithm

i i+1

8 3 6 5 1 9 7 2 4 10

Swapped i-th and (i + 1)-th element

10/28/18 17
Bubble Sort Algorithm

i i+1

8 3 6 5 1 9 7 2 4 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 18
Bubble Sort Algorithm

i i+1

3 8 6 5 1 9 7 2 4 10

Swapped i-th and (i + 1)-th element

10/28/18 19
Bubble Sort Algorithm

i i+1

3 8 6 5 1 9 7 2 4 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 20
Bubble Sort Algorithm

i i+1

3 6 8 5 1 9 7 2 4 10

Swapped i-th and (i + 1)-th element

10/28/18 21
Bubble Sort Algorithm

i i+1

3 6 8 5 1 9 7 2 4 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 22
Bubble Sort Algorithm

i i+1

3 6 5 8 1 9 7 2 4 10

Swapped i-th and (i + 1)-th element

10/28/18 23
Bubble Sort Algorithm

i i+1

3 6 5 8 1 9 7 2 4 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 24
Bubble Sort Algorithm

i i+1

3 6 5 1 8 9 7 2 4 10

Swapped i-th and (i + 1)-th element

10/28/18 25
Bubble Sort Algorithm

i i+1

3 6 5 1 8 9 7 2 4 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 26
Bubble Sort Algorithm

i i+1

3 6 5 1 8 9 7 2 4 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 27
Bubble Sort Algorithm

i i+1

3 6 5 1 8 7 9 2 4 10

Swapped i-th and (i + 1)-th element

10/28/18 28
Bubble Sort Algorithm

i i+1

3 6 5 1 8 7 9 2 4 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 29
Bubble Sort Algorithm

i i+1

3 6 5 1 8 7 2 9 4 10

Swapped i-th and (i + 1)-th element

10/28/18 30
Bubble Sort Algorithm

i i+1

3 6 5 1 8 7 2 9 4 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 31
Bubble Sort Algorithm

i i+1

3 6 5 1 8 7 2 4 9 10

Swapped i-th and (i + 1)-th element

10/28/18 32
Bubble Sort Algorithm

i i+1

3 6 5 1 8 7 2 4 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 33
Bubble Sort Algorithm

i i+1

3 6 5 1 8 7 2 4 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 34
Bubble Sort Algorithm

i i+1

3 5 6 1 8 7 2 4 9 10

Swapped i-th and (i + 1)-th element

10/28/18 35
Bubble Sort Algorithm

i i+1

3 5 6 1 8 7 2 4 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 36
Bubble Sort Algorithm

i i+1

3 5 1 6 8 7 2 4 9 10

Swapped i-th and (i + 1)-th element

10/28/18 37
Bubble Sort Algorithm

i i+1

3 5 1 6 8 7 2 4 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 38
Bubble Sort Algorithm

i i+1

3 5 1 6 8 7 2 4 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 39
Bubble Sort Algorithm

i i+1

3 5 1 6 7 8 2 4 9 10

Swapped i-th and (i + 1)-th element

10/28/18 40
Bubble Sort Algorithm

i i+1

3 5 1 6 7 8 2 4 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 41
Bubble Sort Algorithm

i i+1

3 5 1 6 7 2 8 4 9 10

Swapped i-th and (i + 1)-th element

10/28/18 42
Bubble Sort Algorithm

i i+1

3 5 1 6 7 2 8 4 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 43
Bubble Sort Algorithm

i i+1

3 5 1 6 7 2 4 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 44
Bubble Sort Algorithm

i i+1

3 5 1 6 7 2 4 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 45
Bubble Sort Algorithm

i i+1

3 5 1 6 7 2 4 8 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 46
Bubble Sort Algorithm

i i+1

3 1 5 6 7 2 4 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 47
Bubble Sort Algorithm

i i+1

3 1 5 6 7 2 4 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 48
Bubble Sort Algorithm

i i+1

3 1 5 6 7 2 4 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 49
Bubble Sort Algorithm

i i+1

3 1 5 6 7 2 4 8 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 50
Bubble Sort Algorithm

i i+1

3 1 5 6 2 7 4 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 51
Bubble Sort Algorithm

i i+1

3 1 5 6 2 7 4 8 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 52
Bubble Sort Algorithm

i i+1

3 1 5 6 2 4 7 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 53
Bubble Sort Algorithm

i i+1

3 1 5 6 2 4 7 8 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 54
Bubble Sort Algorithm

i i+1

1 3 5 6 2 4 7 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 55
Bubble Sort Algorithm

i i+1

1 3 5 6 2 4 7 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 56
Bubble Sort Algorithm

i i+1

1 3 5 6 2 4 7 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 57
Bubble Sort Algorithm

i i+1

1 3 5 6 2 4 7 8 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 58
Bubble Sort Algorithm

i i+1

1 3 5 2 6 4 7 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 59
Bubble Sort Algorithm

i i+1

1 3 5 2 6 4 7 8 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 60
Bubble Sort Algorithm

i i+1

1 3 5 2 4 6 7 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 61
Bubble Sort Algorithm

i i+1

1 3 5 2 4 6 7 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 62
Bubble Sort Algorithm

i i+1

1 3 5 2 4 6 7 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 63
Bubble Sort Algorithm

i i+1

1 3 5 2 4 6 7 8 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 64
Bubble Sort Algorithm

i i+1

1 3 2 5 4 6 7 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 65
Bubble Sort Algorithm

i i+1

1 3 2 5 4 6 7 8 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 66
Bubble Sort Algorithm

i i+1

1 3 2 4 5 6 7 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 67
Bubble Sort Algorithm

i i+1

1 3 2 4 5 6 7 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 68
Bubble Sort Algorithm

i i+1

1 3 2 4 5 6 7 8 9 10

Comparing i-th and (i + 1)-th element. i-th element is greater than (i +


1)-th. Need Swap.

10/28/18 69
Bubble Sort Algorithm

i i+1

1 2 3 4 5 6 7 8 9 10

Swapped i-th and (i + 1)-th element

10/28/18 70
Bubble Sort Algorithm

i i+1

1 2 3 4 5 6 7 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 71
Bubble Sort Algorithm

i i+1

1 2 3 4 5 6 7 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 72
Bubble Sort Algorithm

i i+1

1 2 3 4 5 6 7 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 73
Bubble Sort Algorithm

i i+1

1 2 3 4 5 6 7 8 9 10

Comparing i-th and (i + 1)-th element. No Swap required

10/28/18 74
Bubble Sort Algorithm

1 2 3 4 5 6 7 8 9 10

10/28/18 75

You might also like