by thomasahle · 12y ago · 0 comments
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.
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.
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.