Monthly Archives: January 2012

Using the Built-in Sort and Search Functions in C++

Being able to implement your own versions of quicksort (as well as other sorts that might be suitable for the occasion) and binary search algorithms is important (you can check my own implementations here). However, when you are participating in programming contests and challenges the last thing you want to worry about is whether or […]

CodeSprint 2 Problem: Permutations

This problem appeared on the Code Sprint 2 competition by (check out my review here). Given n, print a permutation(p) of (0,1,2…n-1). From the permutation p, you can create n-1 (x,y) coordinates, where x and y are consecutive pairs in the permutation. You are also given the n x n square matrix V. For […]

CodeSprint 2 Problem: Picking Cards

This problem appeared on the Code Sprint 2 competition by (check out my review here). There are N cards on the table and each has a number between 0 and N. Let us denote the number on the ith card by ci. You want to pick up all the cards. The ith card can […]

Make Sure to Participate on the Next Code Sprint

This weekend I took part on Code Sprint 2, a programming competition organized by the folks at The whole contest was very well organized. What I liked was the fact that you could follow a live leaderboard with the rankings of all participants, and the problems were well structured and explained. They were pretty […]

Do You Need to Pay for MySQL On a Closed Source Project?

Although MySQL is open source, the software is not actually free. If you visit MySQL’s website you’ll notice they charge for it. But since it’s open source shouldn’t you be able to use it without paying? I was curious about this topic, and I found an interesting answer on StackOverflow. The original question was: Is […]

Generating Permutations in C++

Suppose you have the following set: {0,1,2}. How do you generate all the possible permutations of such set? One possible approach is to use recursion. First we need to break the problem into smaller sub-problems. This could be done by splitting the set into two parts. We keep the right side fixed, and then find […]