Skip to content

Runestone Issue: Problem Solving 3rd edition section 5.8 code does not match text content #1149

@nyustern-guh3

Description

@nyustern-guh3

Please check the current issues
Confirming that I searched for an existing bug of this nature specific to section 5.8 of Problem Solving, 3rd edition and found none

What Page were you on
https://runestone.academy/ns/books/published/pythonds3/SortSearch/TheSelectionSort.html

Describe the bug
Section 5.8 on Selection Sort text content, images and quiz focus on the selection sort algorithm sorting "largest values" to the end of the list. But the code example shows the opposite - it shows the algorithm sorting the small value to the front.

Below my username is a revised algorithm that matches the intent of the surrounding content adapted from the code shown on the page.

A Screenshot is worth a thousand words
n/a - not an on-page bug, a content bug

Javascript Errors
n/a - not an on-page bug, a content bug

What is your username
guthrix

If you do not take the time to fill in this template we will treat this as very low priority.

suggested replacement code for section 5.8

def selection_sort(a_list):
for i in range(len(a_list)):
mx_idx = 0
for j in range(len(a_list) - i):
if a_list[j] > a_list[mx_idx]:
mx_idx = j
if mx_idx != len(a_list) - i - 1:
a_list.insert(len(a_list) - i - 1,a_list.pop(mx_idx))

a_list = [54, 26, 93, 17, 77, 31, 44, 55, 20]
selection_sort(a_list)
print(a_list)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions