Computer Science, asked by shinghajmer83, 2 months ago

write a python program to implement the bubble sort for a list of integers​

Answers

Answered by XxSrishtiRajputxX
0

Answer:

❍ Let assume as the age of son six years before be x respectively.

Then, Mother's age is x².

And,

Present age of son be (x + 6)

Present age of Mother's be (x² + 6).

— After three years, their ages;

Son's age is (x + 3 + 6) = (x + 9)

Mother's age is (x² + 3 + 6) = (x² + 9).

⠀⠀⠀⠀⠀⠀━━━━━━━━━━━━━━━━━━⠀⠀⠀⠀⠀⠀

\qquad\quad{\underline{ \underline{ \purple{\bigstar\:\frak{According \: to \: the \: Given \: Question :}}}}}

★AccordingtotheGivenQuestion:

Three years hence, the mother's age will be thrice the age of her son.

Mother's age = 3(son's age)

Therefore,

\begin{gathered}:\implies\sf x^2 + 9 = 3(x + 9) \\\\\\:\implies\sf x^2 + 9 = 3x + 27 \\\\\\:\implies\sf x^2 - 3x + 9 - 27 = 0 \\\\\\:\implies\sf x^2 - 3x - 18 = 0 \\\\\\:\implies\sf x^2 - 6x + 3x - 18 = 0 \\\\\\:\implies\sf x(x - 6) + 3(x - 6) = 0 \\\\\\:\implies\sf (x - 6) \; or \; (x + 3) = 0 \\\\\\:\implies{\underline{\boxed{\frak{\purple{x = 6\;or\;-3}}}}}\;\bigstar\end{gathered}

:⟹x

2

+9=3(x+9)

:⟹x

2

+9=3x+27

:⟹x

2

−3x+9−27=0

:⟹x

2

−3x−18=0

:⟹x

2

−6x+3x−18=0

:⟹x(x−6)+3(x−6)=0

:⟹(x−6)or(x+3)=0

:⟹

x=6or−3

⠀⠀

By ignoring –ve value(-3). Because, Age can't be negative. Taking Positive value of, x = 6.

Hence,

Present age of Son is, (x + 6) = (6 + 6) = 12 years.

Present age of Mother is, (x ² + 6) = (6² + 6) = (36 + 6) = 42 years.

⠀⠀

\therefore{\underline{\sf{Hence, \; present\; ages\:of\;son\; and\;mother\:are\;\frak{12\;\&\;42\;years.}}}}∴

Hence,presentagesofsonandmotherare12&42years.

Answered by 9392368008damini
0

Program

# Creating a bubble sort function.

def bubble_sort(list1):

# Outer loop for traverse the entire list.

for i in range(0,len(list1)-1):

for j in range(len(list1)-1):

if(list1[j]>list1[j+1]):

temp = list1[j]

list1[j] = list1[j+1]

Similar questions