Answer:
The Algorithm for selection sort is given below:
1) If Linked list is empty then make the node as
head and return it.
2) If the value of the node to be inserted is smaller
than the value of the head node, then insert the node
at the start and make it head.
3) In a loop, find the appropriate node after
which the input node is to be inserted.
To find the appropriate node start from the head,
keep moving until you reach a node who's value is greater than
the input node. The node just before given node is the
appropriate .
4) Insert the node after the appropriate node
found in step 3
Swap can be implemented using LInked-List by multiple assignment as shown.
The minimum number of variables required is 2.
An example is given below
your_list = ["a", "b", "c", "d", "e"]
your_list[3], your_list[4] = your_list[4], your_list[3]
print(your_list)
OUTPUT
['a', 'b', 'd', 'c', 'e']