Mode Gelap

Recent in Fashion

Best Seller Books

Searching and Sorting(1819110002)

 Sort the given set of numbers using Selection Sort. The first line of the input contains the number of elements, the second line of the input contains the numbers to be sorted. In the output print the status of the array at the 4th iteration and the final sorted array in the given format

OUTPUT:

TC = 1(1 11 25 65 47) and TC = 2 (1 9 14 47 83 77 25)

Subscribe Our Newsletter

avatar
"By speaking behind my back, it means that you respect my existence enough not to act in front of my face."

Related Posts

1 Komentar

  1. a=[]
    n=int(input())
    for i in range(0,n):
    b=int(input())
    a.append(b)
    i = 0
    while i<len(a):
    #smallest element in the sublist
    smallest = min(a[i:])
    #index of smallest element
    index_of_smallest = a.index(smallest)
    #swapping
    a[i],a[index_of_smallest] = a[index_of_smallest],a[i]
    i=i+1
    if(i==3):
    print(" ".join(map(str,a)))
    print("Sorted Array")
    print(" ".join(map(str,a)))

    ReplyDelete

Article Top Ads

Parallax Ads

Article Center Ads

Article Bottom Ads