tags:

views:

599

answers:

11

Hi,

I was thinking about ways to improve my ability to find algorithmic solutions to a problem.I have thought of solving math problems from various math sectors such as discrete mathematics or linear algebra.After "googling" a bit I have read an article that claimed the need of learning game programming in order to achieve this and it seems logical to me.

Do you have/had the same concerns as me or do you have any ideas on this?I am looking forward to hear them.

Thank you all, in advance.

P.S.1:I want to say that I already know about programming and how to program(although I am at amateur level:-) ) and I just want to improve at the specific issue, NOT to start learning it

P.S.2:I think that its a useful topic for future reference so I checked the community wiki box.

+14  A: 

Solve problems on a daily basis. Watch traffic lights and ask yourself, "How can these be synced to optimize the flow of traffic? Or to optimize the flow of pedestrians? What is the best solution for both?". Look at elevators and ask yourself "Why should these elevators use different rules than the elevators in that other building I visited yesterday? How is it actually implemented? How can it be improved?".

Try to see a problem everywhere, even if it is solved already. Reflect on the solution. Ask yourself why your own superior solution probably isn't as good as the one you can see - what are you missing?

And so on. Every day. All of the time.

The idea is that almost everything can be viewed as an algorithm (a goal that has some kind of meaning to somebody, and a method with which to achieve it). Try to have that in mind next time you watch a gameshow on TV, or when you read the news coverage of the latest bank robbery. Ask yourself "What is the goal?", "Whose goal is it?" and "What is the method?".

It can easily be mistaken for critical thinking but is more about questioning your own solutions, rather than the solutions you try to understand and improve.

Ludvig A Norin
+1 - If you do this right it becomes automatic, much to the annoyance of your friends and loved ones. =)
Erik Forbes
I like this solution very much.
deeb
@Erik: Kind of like working at an injection molding company, and then realizing that *nobody else at the table* is interested in the ejector pins on the plastic fork.
David Thornley
This is a fantastic answer: I've done this for a long time, and it has really helped me.
DivineWolfwood
+1  A: 

Learning about game programming will probably lead you to good algorithms for game programming, but not necessarily to better algorithms in general.

It's a good start, but I think that the best way to learn and apply algorithmic knowledge is

  1. Learn about good algorithms that currently exist for your area of interest
  2. Expand your knowledge by viewing other areas; for example, what kinds of algorithms are required when working on genetic analysis? What's the best approach for determining run-off potential as it relates to flooding?
  3. Read about problems in other domains and attempt to use the algorithms that you're familiar with to see if they fit. If they don't try to break the problem down and see if you can come up with your own algorithm.
Michael Todd
+6  A: 

Polya's "How To Solve It" is a great book for thinking about how to solve mathematical problems and do proofs, and I'd recommend it for anyone who does problem solving.

But! It doesn't really address the excitement that happens when the real world provides input to your system, via channel noise, user wackiness, other programs grabbing resources, etc. For that it is worth looking at algorithms that get applied to real-world input (obligatory and deserved nod to Knuth's collection), and systems which are fairly robust in the face of same (TCP, kernel internals). Part of coming up with good algorithmic solutions is to know what already exists.

And alongside reading all that, of course practice practice practice.

ctd
hey, practice is good! I posted a similar answer at the same time. They say great minds think alike, right? (you know, so do mediocre ones ^_^ )
weiji
+5  A: 

The saying "practice makes perfect" definitely applies. I'm tutoring a friend of mine in programming, and I remind him that "if you don't know how to ride a bike, you could read every book about it but it doesn't mean you'll be better than Lance Armstrong tomorrow - you have to practice".

In your case, how about trying the problems in Project Euler? http://projecteuler.net

There are a ton of problems there, and for each one you could practice at developing an algorithm. Once you get a good-enough implementation, you can access other people's solutions (for a particular problem) and see how others have done it. Don't think of it as math problems, but rather as problems in creating algorithms for solving math problems.

In university, I actually took a class in algorithm design and analysis, and there is definitely a lot of theory behind it. You may hear people talking about "big-O" complexity and stuff like that - there are quite a lot of different properties about algorithms themselves which can lead to greater understanding of what constitutes a "good" algorithm. You can study quite a bit in this regard as well for the long-term.

weiji
+3  A: 

You should check out Mathematics and Plausible Reasoning by G. Polya. It is a rare math book, which actually deals with the thought process involved in making mathematical discoveries. I think it is the same thought process that is involved in coming up with algorithms.

Dima
+2  A: 

Check some online judges, TopCoder (algorithm tutorials). Take some algorithms book (CLRS, Skiena) and do harder exercises. Practice much.

sdcvvc
+1  A: 

First of all, and most important: practice. Think of solutions to everything everytime. It doesn't have to be on your computer, programming. All algorithms will do great. Like this: when you used to trade cards, how did you compare your deck and your friend's to determine the best way for both of you to trade? How can you define how many trades can you do to do the maximum and yet don't get any repeated card?

Use problem databases and online judges like this site, http://uva.onlinejudge.org/index.php, that has hundreds of problems concerning general algorithms. And you don't need to be an expert programmer at all to solve any of them. What you need is a good ability with logic and math. There, you can find problems from the simplest ones to the most challenging. Most of them come from Programming Marathons.

You can, then, implement them in C, C++, Java or Pascal and submit them to the online judge. If you have a good algorithm, it will be accepted. Else, the judge will say your algorithm gave the wrong answer to the problem, or it took too long to solve.

Reading about algorithms helps, but don't waste too much time on it... Reading won't help as much as trying to solve the problems by yourself. Maybe you can read the problem, try to figure out a solution for yourself, compare with the solution proposed by the source and see what you missed. Don't try to memorize them. If you have the concept well learned, you can implement it anywhere. Understanding is the hardest part for most of them.

jpmelos
A: 

Read SICP / Structure and Interpretation of Computer Programs and work all the problems; then read The Art of Computer Programming (all volumes), working all the exercises as you go; then work through all the problems at Project Euler.

If you aren't damned good at algorithms after that, there is probably no hope for you. LOL!

P.S. SICP is available freely online, but you have to buy AoCP (get the international, not-for-release-in-north-america edition used for 30 USD). And I haven't done this yet myself (I'm trying when I have free time).

LES2
A: 

Ok, so to sum up the suggestions:

The most effective way to improve this ability is to solve problem as frequently as possible.Either real world problems(such as the elevators "algorithm" which is already suggested) or exercises from books like CLRS(great, I already own it :-)).But I didn't see comments about maths and I don't know what to suppose(if you agree or not).:-s

The links were great.I will definitely use them.I also think that it will be a good exercise to solve problems from national/international informatics contests or to read the way a mathematician proves a theorem.

Thank you all again.Feel free to suggest more, although I am already satisfied with the solutions mentioned.

DarkFire21
Plenty of math (some of it really, really hard) is covered in The Art of Computer Programming (mentioned above). There is also some math in SICP, though not as hard as the math in TAoCP.
LES2
A: 

I can recommend the book "Introductory Logic and Sets for Computer Scientists" by Nimal Nissanke (Addison Wesley). The focus is on set theory, predicate logic etc. Basically the maths of solving problems in code if you will. Good stuff and not too difficult to work through.

Good luck...Kevin

Kevin Horgan
So you think mathematic logic is the most relevant math sector to programming?
DarkFire21
A: 

A few more books worth reading (in no particular order):

  • Aha! Insight (Martin Gardner)
  • Any of the Programming Pearls books (Jon Bentley)
  • Concrete Mathematics (Graham, Knuth, and Patashnik)
  • A Mathematical Theory of Communication (Claude Shannon)

Of course, most of those are just samples -- other books and papers by the same authors are usually quite good as well (e.g. Shannon wrote a lot that's well worth reading, and far too few people give it the attention it deserves).

Jerry Coffin