Computer Science, asked by funnymome455, 5 months ago

program to initialize the following five great king of india and display them as ascending order using bubble sort ​

Answers

Answered by valeriy69
2

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

def bubble_sort(arr):

n = len(arr)

for i in range(n):

for j in range(n - i - 1):

if arr[j] > arr[j + 1]:

arr[j], arr[j + 1] = arr[j + 1], arr[j]

return arr

kings = [

"Krishnadevaraya",

"Chandragupta",

"Samudragupta",

"Shivaji",

"Ajatasatru"

]

print(bubble_sort(kings))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Answered by Anonymous
1

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

def bubble_sort(arr):

n = len(arr)

for i in range(n):

for j in range(n - i - 1):

if arr[j] > arr[j + 1]:

arr[j], arr[j + 1] = arr[j + 1], arr[j]

return arr

kings = [

"Krishnadevaraya",

"Chandragupta",

"Samudragupta",

"Shivaji",

"Ajatasatru"

]

print(bubble_sort(kings))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions