Write an algorithm to sort an elements using Bubble Sort Algorithm.

Algorithm for bubble sort steps:
Step 1 : START
Step 2 : Input N
Step 3 : for I← 0 to N -1
Step 4 : Read ( A [ I ] )
( end of for loop )
Step 5 : for I← 1 to N -1
Step 6 : for J ← 0 to N –I - 1
Step 7 : If (A[ J ] > A [ J +1] )
Temp ← A [ J ]

A [ J ] ← A [ J + 1 ]
A [ J +1 ] ← Temp
[ end of if ]
[ end of J loop ]
[ end of I loop ]
Step 8 : for J ← 0 to N -1
Print A [ J ]
Step 9 : Stop.


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: