Click here to Skip to main content
15,886,069 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
If you gonna improve your skills in algoritm in relation to software programmering, is it recommended to review counterpart's source code than doing your own hobby project? What is your experience about it?

Thanks!
Posted

Do your own.

Looking at code doesn't tell you why decisions were made, what alternatives were considered, or why they were rejected.
"Doing" is a better way of learning - it encourages the growth of skills instead of just blindly repeating existing code and hoping it's the best way to do it.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Apr-15 12:20pm    
Good points. A 5, but there is more to it; please see Solution 3. And 4 :-).
—SA
The word "algorithm" derives from the name of Muḥammad ibn Mūsā al-Khwārizmī, a great 9th. Century (western common era calendar) Persian scholar/mathematician; his work, translated into Latin 300 years later, scrambled his name in combination with the Greek word for "number:" "arithmos."

In any case, in computer science, today, "algorithm" refers to a systematic method of solving some problem such as ordering a data set, calculating prime numbers, etc. An algorithm, in contrast to a "recipe," must be unambiguous, and its pre-conditions (such as data type) must be rigorously defined. imho, an algorithm is not the same as a "design pattern" which I view as an "implementation strategy."

Most computer science students do study algorithms in a special course(s), since they can be focused on in a systematic way. The classic books on Algorithms by Donald Knuth, and the more modern works by Sedgewick and Wayne, and the MIT book from Cormen, Leiserson, Rivest and Stein, are often used as college textbooks. Most college textbooks will have code examples in some form of pseudo-code, or other computer language, not ... to my knowledge ... C#. I have yet to see a good book on Algorithms using C#, but I admit I haven't looked in the last two years to see what's out there.

You might find this site helpful for an overview: [^].

And, Project Euler, the on-line educational site, is a great resource to go and study algorithms by analyzing and coding solutions to problems that do require "algorithmic abstraction: [^].
 
Share this answer
 
In addition to Solution 1:

Note that your question mentioned "algorithm skills", which should be understood not as the ability to apply algorithms, but create algorithms for solving problems. Solution 2 suggests the idea I agree with: you cannot learn the process of creation of the algorithms if you don't create them yourself. This is no different from any other field of activity. Also, Solution 1 explains very well why learning of some code may be not so useful. I'll also add: knowledge taken from just reading something tends to be illusionary: you receive an impression that you can easily do the same. You need to destroy this illusion.

But is it enough? Apparently not. If your activity is fully independent, its result may be not very successful, sometimes failing and sometimes of pure quality. No wonder, if the authors of most the best algorithms uses the experience of your colleagues, all the collected experience in the humankind, and you did not. Besides, you need to learn theory. Creation of algorithms is a very complex art and science at the same time, it has its own secrets and laws.

So, my advise will be different from "do you own". My advice is: "start with doing your own" and "finish your work with your own". I guess the last advise is clear: this is because your particular problem may have its own peculiarities you need to take into account, instead of non-critically applying something already existing.

But why starting with your own, if I already told you that your work could be not very successful. This is because your possible failures are very important! Only after ramming with a hard problem you can deeply understand the solutions of other people. The better your own solution, the better you can understand others, but even if you failed, it can help you a lot in your understanding. And also, don't forget: you always have a chance to create some world-new method. Never miss this opportunity.

—SA
 
Share this answer
 
I want to tell you one interesting story told by my friends.

He wanted to criticize one inferior way of thinking which he, ridiculously enough, attributed to one particular school. This way of "engineering thinking" included, as a part of it, taking special proud of "the skills of reading technical literature" (a trivial thing, in my opinion and opinion of my friend). And here the story goes…

This engineer was given a problem of writing a median filter. This filter is often used and have a remarkable features of noise reduction without softening edges too much. As you can see from the suggested pseudo-code, sorting is involved: http://en.wikipedia.org/wiki/Median_filter.

The filter has certain width parameter N. N elements are taken on input, sorted, and middle element from the sequence of N is passed to output. Then one element is added to this set of N, which is sorted again and so on.

This person speculated "logically": "Aha, the filter… Where is my book on algorithms? Here… Now, sorting algorithms… here is the list… let's see… this one is called "quick sort". After all, do we need slow sort? So, let's take quick sort."

And he took it from the book, and implemented it, and the sorting worked, and the filter ultimately worked. So, in effect, the median filter algorithm was ready, too. Is it good or not?

But my friend sayd: "Fool, you are fool. You did not need this general-purpose sorting. You needed to place one element in an already sorted sequence."

Are you getting the idea?

—SA
 
Share this answer
 
Comments
deelll 13-Apr-15 17:27pm    
1." Are you getting the idea?"
I believe that I understand of what you are trying to inform me.

It is about to learn your art of doing your own algorithm instead of using a existing algorithm in order t


2.
"You needed to place one element in an already sorted sequence."

I don't understand.
Sergey Alexandrovich Kryukov 13-Apr-15 18:30pm    
It's not about "doing your own algorithm", and not about using existing one. Both ways have their places. It's about using your own head. See also my April 1st article:
Some Programming Approaches to "Neuro-Linguistic Programming"
.

Why one element, not general sorting? Because the step of the filter is one sample, but its definition. You sort first N at the very beginning, but then each iteration is to move one sample to output and place one sample from output. When you remove the sample from a sorted sequence of N, remaining N−1 samples remain sorted. And then you need to add one more...

—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900