Algorithmic Thinking: A Problem-Based Introduction Homepage for the book Algorithmic Thinking: A Problem-Based Introduction

Eliminating the gets Function

Hi everyone, gets is an unsafe C function that reads from standard input. It’s unsafe because once you call gets, you have no control over how much stuff gets reads. If someone provides too much input, gets keeps reading and reading, clobbering whatever happens to get in its way. In the Algorithmic Thinking book, I used the C gets function a f... Read more

Solving a Segment Tree Problem, World of World of Warcraft: The Conclusion

Hi everyone, Last week, we started solving a segment tree problem from the 2010 Canadian Computing Olympiad (CCO). To get up to speed: Refresh yourself on Chapter 7 of the Algorithmic Thinking book. That’s all the segment tree material we’ll need. Check out Last week’s post. Last week, I presented some initial code for solving this thin... Read more

Solving a Segment Tree Problem, World of World of Warcraft

Hi everyone, We haven’t done a segment tree problem on here yet. Not cool… let’s do one! Brush up on the segment tree material in Chapter 7 of the Algorithmic Thinking book, and let’s do this. We’re going to get things started in this post, and then follow-up with the remaining details in the next post. Between the two posts is a great time for... Read more

Solving an AtCoder Problem, Picking Goods

Hi everyone, I recently discovered another competitive programming website called AtCoder. At least once a month they run the AtCoder Beginner Contest (ABC). I recommend taking a look at these contests. You’ll find a mix of challenge levels involving material assumed by my Algorithmic Thinking book, material taught in the book, and even some m... Read more

Chapter 3, Ways to Pass, Revisited

Hi everyone, Just a quick post here to add an alternate solution for a problem in the book. Remember that final example in Chapter 3 of Algorithmic Thinking, where we solved Ways to Pass? I provided a memoized solution there. (Be sure to take a look if the details are hazy.) I think it’s good practice to convert that to a dynamic programming s... Read more