News for hackers. Stuff that matters.
Re:Sorting in Python by thomasahle on Wednesday June 11, 2014 @03:06PM (#7879819)
"In Python exchange can be done in two simultaneous assignments"

Good, but then why does all your code say

    temp = alist[i]
    alist[i] = alist[j]
    alist[j] = temp
And not

    alist[i], alist[j] = alist[j], alist[i]
It's confusing when you are trying to understand an algorithm, and the descriptions don't match the code.

On the more general lines it seems like a quite pleasant book.

Re:Sorting in Python by bnmnetp on Wednesday June 11, 2014 @03:17PM (#7879888)
Good point. Although we do introduce the long way first.

The reason we don't use a,b = b,a in our code is that it isn't very portable to other languages. We wrote this book as a second semester textbook. So most students are not very good programmers and will be transitioning to something like Java or C++ in the next semester.

Further, for most of the sorting algorithms we have exercises where we suggest that users modify the code themselves to use simultaneous assignment.

Re:Sorting in Python by javafoo on Wednesday June 11, 2014 @04:07PM (#7880134)
Crawling your book, i stumble over several codes that use flags instead of "return" to exit, by example, you use two flags for searching on an ordered list.

These kind of codes are not great for beginners because they tend to think that setting the flag is equivalent to exiting which is as you know an illusion.

Re:Sorting in Python by zatkin on Thursday June 12, 2014 @11:24AM (#7883911)
If possible, what's the equivalent using bitwise operations?
Re:Sorting in Python by chhantyal on Wednesday June 11, 2014 @02:44PM (#7879678)
I highly recommend this book to any intermediate Python programmer. This is the book that made me not to get scared whenever there comes thing called algorithms.

Very well written, beginner friendly and great examples to demonstrate algos in action.

Thanks a ton to author for this gem :)

Re:Sorting in Python by dhissami on Wednesday June 11, 2014 @03:05PM (#7879815)
I agree. This book taught me stacks, queues, deques, trees, and graphs. I was already exposed to searching/sorting and recursion from other resources, including John Zelle's "Python Programming: An Introduction to Computer Science" (2nd edition), which I recommend to any beginning Python programmer as a prelude to this one. It's perfect for self-teaching. Contact the publisher (same one, actually) for exercise answers and work through them all. I even emailed the author for a clarification and he responded with a thorough answer. Overall, a great learning experience that took my programming knowledge and skills to the next level.
Re:Sorting in Python by jonhmchan on Wednesday June 11, 2014 @01:30PM (#7879216)
This book is how I picked up algorithms and data structures having never gone through a formal computer science program. Glad to see it's still being worked on.
Re:Sorting in Python by bnmnetp on Wednesday June 11, 2014 @02:16PM (#7879505)
Thanks, I enjoy working on all aspects of this project. For anyone interested in helping us out you can find us on github.com/bnmnetp/runestone. I would love to have more contributors.
Re:Sorting in Python by jonhmchan on Wednesday June 11, 2014 @04:21PM (#7880204)
Oh I absolutely will. I've featured it heavily on Bento and its entire algorithms and data structures section is basically links to chapters in this book.
Re:Sorting in Python by codegeek on Wednesday June 11, 2014 @03:37PM (#7879997)
wow, I never knew about this. Love interactive learning materials like this. My daughter is going to be using this to learn Python and I will start with the turtle interactive program.

This is the way to learn things. Interactive, break things, try things and see how it actually works. Just donated to the cause and bookmarked the repo. Hope to contribute in future.

Re:Sorting in Python by nirkalimi on Wednesday June 11, 2014 @06:45PM (#7880882)
Thanks for this! I spent a good amount of time learning from this just now. This is especially helpful to those self taught hackers who haven't really thought about/formally been introduced to these sorting techniques. I especially like all the interactive learning material. I hope for more!
Re:Sorting in Python by rnnr on Wednesday June 11, 2014 @05:23PM (#7880511)
You could also insert Timsort in the end, which is what python uses and a fabulous algorithm by Tim Peters.
Re:Sorting in Python by mathattack on Wednesday June 11, 2014 @06:22PM (#7880775)
Call me uneducated, but I always thought that since it featured so heavily in Python, it was named after this Tim. a https://www.youtube.com/watch?v=QDAeJ7eLGGg
Re:Sorting in Python by rnnr on Wednesday June 11, 2014 @09:19PM (#7881345)
no, this Tim would have been disastrous for the data!
Re:Sorting in Python by bnmnetp on Thursday June 12, 2014 @08:39AM (#7883016)
Great idea. In other parts of the book we discuss how Python implements lists and other data structures, so that would fit in nicely with that theme.
Re:Sorting in Python by thehme on Friday June 13, 2014 @11:51AM (#7889416)
I am glad I found this post and will be checking it out. Thanks.