Given an Integer N and a list arr. Sort the array using bubble sort algorithm.
Example 1:
Input: 
N = 5
arr[] = {4, 1, 3, 9, 7}
Output: 
1 3 4 7 9
Example 2:
Input:
N = 10 
arr[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
Output: 
1 2 3 4 5 6 7 8 9 10
Your Task: 
You don't have to read input or print anything. Your task is to complete the function bubblesort() which takes the array and it's size as input and sorts the array using bubble sort algorithm.
Expected Time Complexity: O(N^2).
Expected Auxiliary Space: O(1).
Constraints:
1 <= N <= 10^{3}
1 <= arr[i] <= 10^{3}

Difficulty: EASY
Tags: Sorting
Skill types: Sorting
Expected Time Complexity: O(N^2).
Expected Auxiliary Space: O(1).

Starter code:
#User function Template for python3



class Solution:

    #Function to sort the array using bubble sort algorithm.

    def bubbleSort(self,arr, n):

        # code here

Solutions:
class Solution:

	def bubbleSort(self, arr, n):
		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])


class Solution:

	def bubbleSort(self, arr, n):
		for i in range(n - 1, 0, -1):
			didswap = 0
			for j in range(i):
				if arr[j] > arr[j + 1]:
					temp = arr[j]
					arr[j] = arr[j + 1]
					arr[j + 1] = temp
					didswap = 1
			if didswap == 0:
				return arr
		return arr


class Solution:

	def bubbleSort(self, arr, n):
		for i in range(n - 1):
			swapped = False
			for j in range(n - i - 1):
				if arr[j + 1] < arr[j]:
					(arr[j + 1], arr[j]) = (arr[j], arr[j + 1])
					swapped = True
			if swapped == False:
				return


class Solution:

	def bubbleSort(self, arr, n):

		def rec(arr, l, r):
			if l == r:
				return
			rec(arr, l + 1, r)
			i = l
			while i < r and arr[i] > arr[i + 1]:
				(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
				i += 1
			return
		rec(arr, 0, n - 1)


class Solution:

	def bubbleSort(self, arr, n):
		for i in range(n - 1, 0, -1):
			didswap = 0
			for j in range(0, i):
				if arr[j] > arr[j + 1]:
					(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
					didswap = 1
			if didswap == 0:
				break


class Solution:

	def bubbleSort(self, arr, n):
		for i in range(len(arr)):
			for j in range(len(arr) - 1):
				if arr[j] > arr[j + 1]:
					temp = arr[j]
					arr[j] = arr[j + 1]
					arr[j + 1] = temp
		return arr


class Solution:

	def bubbleSort(self, arr, n):
		for i in range(n, -1, -1):
			count = 0
			for j in range(0, i - 1):
				if arr[j] > arr[j + 1]:
					(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
					count += 1
			if count == 0:
				break
		return arr


class Solution:

	def bubbleSort(self, arr, n):
		arr.sort()


class Solution:

	def recursiveBubbleSort(self, arr, n):
		if n == 1:
			return
		for i in range(n - 1):
			if arr[i] > arr[i + 1]:
				(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
		self.recursiveBubbleSort(arr, n - 1)

	def bubbleSort(self, arr, n):
		self.recursiveBubbleSort(arr, n)


class Solution:

	def bubbleSort(self, arr, n):
		k = arr.sort()
		return k


class Solution:

	def bubbleSort(self, arr, n):

		def rec_bSort(n):
			if n == 1:
				return
			for i in range(0, n - 1):
				if arr[i + 1] < arr[i]:
					(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
			rec_bSort(n - 1)
		rec_bSort(n)


class Solution:

	def bubbleSort(self, arr, n):
		for i in range(n):
			j = 0
			while j < n - i - 1:
				if arr[j] > arr[j + 1]:
					(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
					j = j + 1
				else:
					j = j + 1


class Solution:

	def bubbleSort(self, arr, n):
		sorted = True
		for i in range(n):
			swapped = False
			for j in range(0, n - i - 1):
				if arr[j] > arr[j + 1]:
					(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
					swapped = True
					sorted = False
			if swapped == False:
				break
			if sorted == True:
				self.bubbleSort(arr, n)


class Solution:

	def bubbleSort(self, arr, n):
		is_swap = False
		for i in range(n - 1):
			if arr[i] > arr[i + 1]:
				temp = arr[i]
				arr[i] = arr[i + 1]
				arr[i + 1] = temp
				is_swap = True
		if is_swap:
			self.bubbleSort(arr, n - 1)


class Solution:

	def bubbleSort(self, arr, n):
		sorted = False
		while not sorted:
			sorted = True
			for i in range(0, n - 1):
				if arr[i] > arr[i + 1]:
					sorted = False
					(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
		return arr


class Solution:

	def bubbleSort(self, arr, n):
		for i in range(n - 1, 0, -1):
			is_swap = False
			for j in range(i):
				if arr[j] > arr[j + 1]:
					temp = arr[j]
					arr[j] = arr[j + 1]
					arr[j + 1] = temp
					is_swap = True
			if not is_swap:
				break


class Solution:

	def bubbleSort(self, l, n):
		for i in range(n - 1):
			f = 0
			for j in range(n - i - 1):
				if l[j] > l[j + 1]:
					(l[j], l[j + 1]) = (l[j + 1], l[j])
					f = 1
			if f == 0:
				break


class Solution:

	def bubbleSort(self, a, n):
		for i in range(n):
			for j in range(n - i - 1):
				if a[j] > a[j + 1]:
					(a[j], a[j + 1]) = (a[j + 1], a[j])
		return a


class Solution:

	def bubbleSort(self, arr, n):
		a = arr.sort()
		return a