#1. Python program to implement linear search. #CODE def linear_Search(list1, n, key): for i in range(0, n): if (list1[i] == key): return i return -1 list1 = [1 ,3, 5, 4, 7, 9] key = int(input("Enter Element :")) n = len(list1) res = linear_Search(list1, n, key) if(res == -1): print("Element not found") else: print("Element found at index: ", res) #2. Python program to implement bubble sort. #CODE def bubble_sort(list1): 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] list1[j+1] = temp return list1 list1 = [5, 3, 8, 6, 7, 2] print("The unsorted list is: ", list1) # Calling the bubble sort function print("The sorted list is: ", bubble_sort(list1)) #3. Python program to implement binary search without recursion. def binary_searchiter(arr, n): low = 0 high = len(arr) - 1 mid = 0 while low <= high: mid = (high + low) // 2 if arr[mid] < n: low = mid + 1 elif arr[mid] > n: high = mid - 1 else: return mid return -1 arr = [4, 7, 9, 16, 20, 25] n = 7 r = binary_searchiter(arr, n) if r != -1: print("Element found at index", str(r)) else: print("Element is not present in array") #4. Python program to implement selection sort. #CODE def selectionSort(array): n = len(array) for i in range(n): minimum = i for j in range(i+1, n): if (array[j] < array[minimum]): minimum = j # Swap the minimum element with the first element of the unsorted part. temp = array[i] array[i] = array[minimum] array[minimum] = temp return array array = [13, 4, 9, 5, 3, 16, 12] print(selectionSort(array))