Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve my difficulty making algorithms? [closed]

Tags:

algorithm

First of all, sorry, but my English is not very good.

I'm at the third semester at a programming course and I can't "get it".

I passed previous exams because I've studied three times the amount my colleagues did. And, now in my Data Structures class when the professor asks us to make list algorithms ( for example ), my colleagues just start to write the code while me ( or would be "I"? ), even after seeing it done, can't understand.

I find it so hard it's painful. It takes me 1 hour to understand simple algorithms.

So the question is: can anyone recommend me books or something, that will help me think more like a programmer? I mean, "normal" people, after a given problem, seem to immediately make the picture in their head and star to write the code.

like image 760
StudioWorks Avatar asked Aug 29 '10 15:08

StudioWorks


People also ask

Are there problems that algorithms can't solve?

Undecidable Problems. These problems are the theoretically impossible to solve — by any algorithm. The halting problem is a decision problem (with a yes or no answer) that is undecidable. A computer cannot tell if it is in an infinite loop or it will at some point stop!


3 Answers

I think there are two ways to learn to write algorithms: 1. Try it yourself (and then review it with the "right" answer). Of course you should start with the simple ones. 2. Implement other's algorithms (to code). Going from algorithms to code and the other way around gives you a great "feeling" of how algorithms are created.

But the best advice I can give you (which you can use the two ways above to acquire) - try being very good at some algorithms. If you could remember, write and really understand even just a few basic algorithms - you're on the right way.

Anyways, I think learning algorithms is mainly practice and less "abstract knowledge", so get ready to get your hands dirty..

Best of luck!!

like image 107
Oren A Avatar answered Oct 29 '22 21:10

Oren A


you might want to take a philosophy class on intro to logic. it's exactly the same thing as you're doing with computers, but in a different context.

like image 32
atk Avatar answered Oct 29 '22 22:10

atk


I found that the most important skill for mastering data structures is to "visualize" them. If you have no clear picture of your data structure, everything stays fuzzy and vague. E.g. take a stack (single linked list). It may help to visualize it as a stack of plates or people in a polonaise (everyone has the hands on the shoulders of the person in front of him).

Or a double linked list: Imagine a row of people grabbing the belt of the left and right neighbor. Now you can imagine what you must do to remove one person: Its left neighbor needs to grab the belt of the right neighbor and the right neighbor the one of the left neighbor. Then you can "delete" that person (or the garbage collector does this for you in Java etc)

The second important skill is to understand recursion. You need always a base case, usually involving an empty list or empty node. When you follow the algorithm in the recursive method, check that it is correct, but don't follow recursive calls inside that method. That will drive you mad and lead to nothing. Just assume that recursive calls always "do the right thing". If your current method is correct and the base case as well, you are done. Once you understood this, you understand recursion.

like image 43
Landei Avatar answered Oct 29 '22 21:10

Landei