NEP -DAA -DESIGN AND ANALYSIS OF ALOGRITHM

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12

PART B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 PROGRAM B8 . . .

 
   
#1.Write a program to sort a list of N elements using Selection Sort Technique.

def selection_sort(array):  
    length = len(array)  
    for i in range(length-1):  
        minIndex = i  
          
        for j in range(i+1, length):  
            if array[j]< array[minIndex]:  
                minIndex = j  
                  
        array[i], array[minIndex] = array[minIndex], array[i]  
          
          
    return array   
   
array = [21,6,9,33,3]
print("The sorted array is: ", selection_sort(array))