egonSchiele / grokking_algorithms

Code for the book Grokking Algorithms (https://amzn.to/29rVyHf)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typo in python selection sort

whatisnormal opened this issue · comments

Hi,
Current
if arr[i] < smallest: smallest_index = I

should be

if arr[i] < smallest: smallest_index = i smallest = arr[i]

@B3Y0ND3R I couldn't find capital I in 01_selection_sort.py

Hi @ramitmittal , the capital I was a typo sorry.
We should have the "bold" line also can you please confirm? Otherwise "smallest" will always be the initial value arr[0]

if arr[i] < smallest:
smallest_index = i
smallest = arr[i]

I verified the error.
smallest = arr[i]
needs to be added.
I have submitted a pull request after correcting.

solved in accepted pull request #72 , please close this issue