Home > Computer Science > Why I Love Computer Science (and Algorithms)

Why I Love Computer Science (and Algorithms)

March 21st, 2009

I really like puzzles. Although I do enjoy board game puzzles, my favorite type of puzzles are ones that require extensive thinking and a clever and elegant solution. This is what really drew me to Computer Science. Applying data structures, algorithms, architecture, etc., and coming up with a high performing, elegant solution to a problem is challenging and exciting to me. Puzzles are also a reason I really like Philosophy.

On my algorithms midterm exam before Spring break, there was a question that I think represents why I truly enjoy studying Computer Science. Never in my life have I read a question on an exam and said to myself, “This question is awesome.” I am going to post a modified version of the question, and strongly encourage anyone to post their solution as a comment. I will post one possible solution on Friday.

A firm wants to determine the highest floor on its n-story building from which a device can fall with no impact on the device’s functionality. The firm has two identical gadgets that you can experiment with (each costs $1,000,000). You are allowed to break both gadgets,  but no extra gadgets will be provided. Design a brute force algorithm in the best efficiency class to solve this problem.

This is a very technical question, so in order to simplify it, do not worry about what “brute force” or “efficiency class” means if you have never taken an algorithms course. These are important concepts for solving this problem in a real life situation, but I do not want these topics to discourage discussion amongst non-CS readers. If you wish to leave a comment, simply write what you would do to solve this problem.

Example solution:

  1. Drop gadget on first floor
  2. If it breaks, gadget cannot be dropped from hight=current floor
  3. If it does not break, go to next floor and Repeat.

Example in pseudocode:

DidItBreak(n)
//where n is the number of floors
for currentFloor<-1 to n do
  if result of device drop = broken
    return currentFloor-1
  else
    currentFloor <- currentFloor + 1
  return -1

jonnale Computer Science

  1. March 23rd, 2009 at 08:13 | #1

    Jon, you told me how to do this, but it was too intense for my simple, design oriented mind :)

  1. April 24th, 2010 at 12:29 | #1