How to improve algorithm skills?

Started by
8 comments, last by andy_boy 18 years ago
Usually I get by, but still, do you have some tips how to improve one's skill in making algorithms? It took me about an hour to find a way to transform (clamp?) a position in a range to the corresponding position in another range. (range of pixels - slider, to some value range). This is the best I could do if it makes sense: ValuePosition = ValueRangeLength * (1 / PixelRangeLength) * (PixelPosition - PixelRangeBegin) + ValueRangeBegin; Basically, I feel I'm too slow in this although I do enjoy it somewhat. I suppose a part is talent, but is it possible to improve my skill a bit and how? Thank you.
Advertisement
all you need is a simple ratio.
(SliderLength/MaxValue) * value + offset

this will give you the value scaled to the slider.

Ah, this isn't what you wanted. I start with an equation, and solve for it. Try to have as few floating point operations as possible. Sometimes this is as simple as reorganising an equation. Other times you have to do some wicked assembly optomisation. Go look for the equation for carmack's reverse and inverse. They will blow your mind.
Quote:Original post by KaptainKomunist
all you need is a simple ratio.
(SliderLength/MaxValue) * value + offset

this will give you the value scaled to the slider.

Ah, this isn't what you wanted. I start with an equation, and solve for it. Try to have as few floating point operations as possible. Sometimes this is as simple as reorganising an equation. Other times you have to do some wicked assembly optomisation. Go look for the equation for carmack's reverse and inverse. They will blow your mind.


You are still right: ( ValueLength / SliderLength ) * SliderOffset + ValueOffset [smile]

So basically I could focus on solving equations? Thanks.

I'm getting reasonably nice things done lately, but my code still sucks too much at a higher level to justify the effort of assembler optimizations.
Take some courses in mathematics and physics. That will increase your algorithmic and problem skills dramatically.
I would go so far as to say that what is required to up your algorithin skill is practing and learning about algorithim design. Read on it and try to plan and then implement your own algorithims.

The problem solving methods of math and physics do not quite lend themselves well to programming because they are two different domains. There exists similarities but that is all they are, similarities. You must practice programming as well. With math there is generally a destination you wish to reach and theres is a vague idea of how to get there and you have a fair number of items to help get there. These items also allow you to construct more complex combinations to hasten your approach to your destination. In physics there is a puzzle that you are trying to put together and you make guesses at its original shape and use prior knowledge and tools to help do this.

In programming there is a general destination like math (indeed, you could say it takes place in the same landscape as your math travels) but there is not as much freedom and there are limits as to how you may operate everywhere. There is also a strong requirement of order in how you take your steps and plan. Heuristics and implications are not allowed, everything must be spelled out in a correct manner. Simply doing math will not prepare you for this. You must also program. In fact, you may find that programming helps to gather your thoughts and better grasp the internal details of some math while also inversely, math may help in better grasping a general external overview.

Desining a program is an engineering problem with strong aspects of planning,designing and foresight. Learning about programming, its structures and math simply increases the tools in your arsenal allowing you to approach desing problems from more angles and thus act more flexibly.
algoritim skills come with experience.

I really recommend you to try programming challanges at ACM : http://acm.uva.es/

this site offer tons of programming challanges mostly related to optimization and algoritims. there are very hard challanges there and will advance you to the next level.

this may seems like a waste of time but it will affect you brain pretty fast :)

give it a try,
Nuno1


@Daerax: Well, you certainly put things into place, thanks.

@Nuno1: bookmarked, I'll try some of these.

Thanks for the replies, it has motivated me to hear this skill can be improved.
Some universities have classes devoted to algorithms. Case in point, my Data Structures and Algorithms class. To study for our final, my prof told us to just "practice solving problems." It's really vague, but if you like to program in your free time, I'm sure you can find problems to improve upon.

Things you learn in an algorithms class really are great -- you learn all about big-O notation and how to apply it to programs that you create.

HTH
Deep Blue Wave - Brian's Dev Blog.
Quote:Original post by BTownTKD
Some universities have classes devoted to algorithms.

I'd be scared if there are any that don't have those classes. At least, if they claim to teach comp. science...
There is a book called Algorthmics. I believe the most recent edition was 2004. I recommend it since it focuses on algorithms as the core of computer science. Check it out.

This topic is closed to new replies.

Advertisement