Ask Question
15 February, 13:18

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?

+5
Answers (1)
  1. 15 February, 16:57
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers