Group B

Q5: Implement Greedy search algorithm for any of the following applications: Selection Sort, Minimum Spanning Tree, Single-Source Shortest Path Problem, Job Scheduling Problem, Prim's MST, Kruskal's MST, or Dijkstra's Algorithm.

Greedy Search Algorithm Implementations

Solution and implementation for Q5 from Artificial Intelligence Laboratory (ai).

5_selection_sort.py Download
def selection_sort(a):
    for i in range(len(a)):
        min_idx = i
        for j in range(i+1, len(a)):
            if a[j] < a[min_idx]:
                min_idx = j
        a[i], a[min_idx] = a[min_idx], a[i]
    return a

arr = [64, 25, 12, 22, 11]
print(selection_sort(arr))

Other Questions in Artificial Intelligence Laboratory

See All Available Questions
Download