Ask Question
27 June, 04:56

Write me some pseudocode for one pass of the Selection Sort algorithm through random values stored in an Unordered-List, or Linked-List, of values (rather than a standard "Python" List).

• How would you implement a swap using a Linked-List?

• What is the minimum number of variables required?

+3
Answers (1)
  1. 27 June, 05:23
    0
    Minimum of 6 variables is required

    Explanation:

    class LinkedList:

    def __init__ (self, v):

    self. data = v

    self. next = None

    def sortSelections (first):

    x = y = first

    while y. next:

    z = p = y. next

    while p:

    if y. data > p. dа ta:

    if y. next = = p:

    if y = = first:

    y. next = p. next

    p. next = y

    y, p = p, y

    z = p

    first = y

    p = p. next

    else:

    y. next = p. next

    p. next = y

    x. next = p

    y, p = p, y

    z = p

    p = p. next

    else:

    if y = = first:

    r = y. next

    y. next = p. next

    p. next = r

    z. next = y

    y, p = p, y

    z = p

    p = p. next

    first = y

    else:

    r = y. next

    y. next = p. next

    p. next = r

    z. next = y

    x. next = p

    y, p = p, y

    z = p

    p = p. next

    else:

    z = p

    p = p. next

    x = y

    y = y. next

    return first

    def display (first):

    while first:

    print (first. data, end = " ")

    first = first. next

    if __name__ = = "__main__":

    print ("Sorted List: ")

    first = LinkedList (53)

    first. next = LinkedList (14)

    first. next. next = LinkedList (2)

    first. next. next. next = LinkedList (9)

    first. next. next. next. next = LinkedList (92)

    first = sortSelections (first)

    display (first)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write me some pseudocode for one pass of the Selection Sort algorithm through random values stored in an Unordered-List, or Linked-List, of ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers