Learning Algorithms

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 3819 Views - Last Post: 25 February 2013 - 04:34 PM

#1 TwoOfDiamonds  Icon User is offline

  • D.I.C Regular

Reputation: 54
  • View blog
  • Posts: 272
  • Joined: 27-July 12

Learning Algorithms

Posted 20 February 2013 - 01:05 PM

Hey guys ! ^_^

I'll keep it as short as possible :

1.Do you learn some new algorithms from time to time or do you look for something that fits for your new task and learn them when you need them ?

2.If you want to learn and get used to some algorithms , would you rather use languages such as C/C++ or higher level ones like Python ?

Thanks in advance ! ^_^

Is This A Good Question/Topic? 0
  • +

Replies To: Learning Algorithms

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10573
  • View blog
  • Posts: 39,150
  • Joined: 27-December 08

Re: Learning Algorithms

Posted 20 February 2013 - 01:40 PM

Algorithms are language agnostic. If you want implementation practice, use whichever language you feel most comfortable with. At it's core, an algorithm is just a finite sequence of steps that produces a specific result. So question 1 is basically asking the same thing twice.

As a computer scientist and software engineer, you should be comfortable implementing algorithms from clear descriptions and pseudo-code, as well as problem solving yourself.

I feel like my answer might be a little vague and abstract, but I'm not exactly sure where you're going here. I'll be happy to clarify or expand on something if you want me to. :)
Was This Post Helpful? 3
  • +
  • -

#3 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5529
  • View blog
  • Posts: 11,843
  • Joined: 02-June 10

Re: Learning Algorithms

Posted 20 February 2013 - 01:44 PM

What do you think an 'algorythm' is?
Because its just the logic behind how you get work done.
What kind of algorithms are you having to learn?
The algorythm for filling up my Truck is:

Truck.GasDoor.Open();
Truck.GasCap.Remove();
pump.nozzle.Remove();
pump.nozzle.Insert(myTruck);
pump.SelectFuel(diesel);
If (pump.HasActivationButton) pushButton();
if (pump.HasLever) raiseLever();
while (!Overflowing && !PrePaidAmountExceeded) 
{
   SqueezeHandle();
}
pump.nozzel.Return();
Truck.Gascap.Return();
Truck.Gasdoor.Close();



It may not be the same in all programming areas, but there aren't really that many 'algorythms' to learn in my area. The workflow is odd and I have to work out my own logic for getting the job done.
Was This Post Helpful? 0
  • +
  • -

#4 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7765
  • View blog
  • Posts: 13,131
  • Joined: 19-March 11

Re: Learning Algorithms

Posted 20 February 2013 - 02:03 PM

I would tend to say that Java or C are good choices for studying algorithms, simply because they leave more room for you to work. In python, it's harder to get down to the basics, since the language really doesn't want you to think at low levels. This makes it a great programming language but not a great learning language.
Also, the classic college-level text on algorithms, Sedgewick's, is available in editions that target C and Java, so those languages have an advantage there. (Though I admit I prefer the C edition - the most recent edition is far more noisy than it needs to be)

That being said, the truths of algorithms are mathematical ones, not language-specific ones, so any language will do. If you write a quicksort correctly, it'll outperform an insertion sort no matter what language you write it in or what machine you run it on - that's the argument for studying algorithms generally and not "algorithms in C" or "algorithms in lisp".

View PosttlhIn`toq, on 20 February 2013 - 03:44 PM, said:

It may not be the same in all programming areas, but there aren't really that many 'algorythms' to learn in my area. The workflow is odd and I have to work out my own logic for getting the job done.



I have to say, I'm spending a lot of time these days cleaning up after a guy who has no conception of algorithmic complexity. Flattening out loops and loops and loops, trying to get responsiveness closer to a reasonable level. It's definitely a good idea to spend a semester or two thinking about what computers spend their time on.
Was This Post Helpful? 3
  • +
  • -

#5 NecroWinter  Icon User is offline

  • D.I.C Regular

Reputation: 36
  • View blog
  • Posts: 320
  • Joined: 21-October 11

Re: Learning Algorithms

Posted 20 February 2013 - 06:43 PM

View Postjon.kiparsky, on 20 February 2013 - 02:03 PM, said:

I have to say, I'm spending a lot of time these days cleaning up after a guy who has no conception of algorithmic complexity. Flattening out loops and loops and loops, trying to get responsiveness closer to a reasonable level. It's definitely a good idea to spend a semester or two thinking about what computers spend their time on.

This.

I've had to deal with really terrible code before, and when I see two nested for loops when its not necessary I just cringe...
Was This Post Helpful? 0
  • +
  • -

#6 TwoOfDiamonds  Icon User is offline

  • D.I.C Regular

Reputation: 54
  • View blog
  • Posts: 272
  • Joined: 27-July 12

Re: Learning Algorithms

Posted 20 February 2013 - 10:02 PM

By my first question I actually meant :

For example, do you learn the whole "Introduction to Algorithms" book by heart or do you read it and know where to look when you need something ?

So it's more a question of Know vs Know where to look .

And I recently looked into Python and I was wondering if it's worthed to learn it (that's where my second question came from )
Was This Post Helpful? 0
  • +
  • -

#7 NecroWinter  Icon User is offline

  • D.I.C Regular

Reputation: 36
  • View blog
  • Posts: 320
  • Joined: 21-October 11

Re: Learning Algorithms

Posted 20 February 2013 - 10:12 PM

View PostTwoOfDiamonds, on 20 February 2013 - 10:02 PM, said:

By my first question I actually meant :

For example, do you learn the whole "Introduction to Algorithms" book by heart or do you read it and know where to look when you need something ?

So it's more a question of Know vs Know where to look .

And I recently looked into Python and I was wondering if it's worthed to learn it (that's where my second question came from )

I'm sure some people do that. Most people just learn a few tricks to be able to accomplish most practical goals such as telling the order of an algorithm. The kinds of people who have an entire algorithm book memorized are the kind of people who are very fascinated with mathematics. Just as a hunch, I would say most people get a general feel and then look stuff up when they need to, but this is just my experience. Hopefully that answered your question
Was This Post Helpful? 1
  • +
  • -

#8 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7765
  • View blog
  • Posts: 13,131
  • Joined: 19-March 11

Re: Learning Algorithms

Posted 20 February 2013 - 10:44 PM

I think it's a lot less useful to memorize algorithms than to learn how to reason about algorithms. If you understand running times and big-O notation, you're in good shape. In order to learn this, you're probably going to get familiar with a few algorithms, and there's certainly no harm in picking up a copy of The Art of Computer Programming and just working through the material there, but that is not necessary to be a good programmer. As NecroWinter says, that's mostly something you'll do if you really get into the math of it. The math is worth getting into, especially if you want to understand topics like cryptography, but to be a good programmer you really want to have a good set of intuitions about algorithms and how they work, not a headful of Floyd-Warshall and Graham Scan and whatnot.

(thinking about it, I have to say - if you want to be a better programmer than you are, of course, going through a copy of Sedgewick's Algorithms in C and working each and every one of the problems in it is not at all a bad idea. Even if you don't remember exactly how to implement a red-black tree, you'll have worked your brain on some really good hard problems)
Was This Post Helpful? 1
  • +
  • -

#9 TwoOfDiamonds  Icon User is offline

  • D.I.C Regular

Reputation: 54
  • View blog
  • Posts: 272
  • Joined: 27-July 12

Re: Learning Algorithms

Posted 20 February 2013 - 10:51 PM

Ok ... so Sedgewick's Algorithms in C is my next book :)

I'm a highschool student at the moment . Going to university next year ... and I always like to be one year ahead at least ... ^_^

Thanks for all your help !
Was This Post Helpful? 1
  • +
  • -

#10 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7765
  • View blog
  • Posts: 13,131
  • Joined: 19-March 11

Re: Learning Algorithms

Posted 20 February 2013 - 10:58 PM

I'm not the guy to tell you exactly what math you should prepare yourself with, but if you can work through the basics of discrete math and number theory you'll probably do yourself no harm at all. The guy to listen to on this is macosxnerd101 - he's got a lot more formal math training than I do. (which is to say, >0)
Was This Post Helpful? 1
  • +
  • -

#11 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 2005
  • View blog
  • Posts: 4,171
  • Joined: 11-December 07

Re: Learning Algorithms

Posted 21 February 2013 - 02:04 AM

Quote

1.Do you learn some new algorithms from time to time or do you look for something that fits for your new task and learn them when you need them ?


Both. I'm always looking out for new things to learn and am slowly making my way through Skienna's The Algorithm Design Manual. But my area of work often benefits from off-the-shelf algorithms (maybe slightly modified) that are more efficient than anything I would come up with myself. In these cases, I look them up as needed (often in Skienna).

Quote

2.If you want to learn and get used to some algorithms , would you rather use languages such as C/C++ or higher level ones like Python ?


I'd rather use a language I was already familiar with. It will let me concentrate on the details of the algorithms in question without getting distracted by details of unfamiliar syntax.
Was This Post Helpful? 0
  • +
  • -

#12 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10573
  • View blog
  • Posts: 39,150
  • Joined: 27-December 08

Re: Learning Algorithms

Posted 21 February 2013 - 08:41 AM

View PostTwoOfDiamonds, on 21 February 2013 - 12:51 AM, said:

Ok ... so Sedgewick's Algorithms in C is my next book :)/>

I'm a highschool student at the moment . Going to university next year ... and I always like to be one year ahead at least ... ^_^/>

Thanks for all your help !

I got a few PM's about a year ago asking how to get started with data structures and algorithms. If you're in high school, you might want to start with the topics outlined here, which are standard Data Structures I topics. The algorithms books suggested are more typical of a 3000 Data Structures II class or a 4000 Algorithm Analysis class. Those are good to know, but those come after you have the basics down. And really, you want a certain familiarity with proof writing, beyond what you get in high school Geometry.

View Postjon.kiparsky, on 21 February 2013 - 12:58 AM, said:

I'm not the guy to tell you exactly what math you should prepare yourself with, but if you can work through the basics of discrete math and number theory you'll probably do yourself no harm at all. The guy to listen to on this is macosxnerd101 - he's got a lot more formal math training than I do. (which is to say, >0)

At the high school level, Calc I-II and Statistics are really good preparation for college. Having Discrete Math and Number Theory under your belt are a plus. Some discrete classes omit Combinatorics and Graph Theory as well. Those are very important topics for any computer scientist. You'll pick up enough Set Theory along the way. And if you haven't already, brush up on your formal logic, and perhaps Boolean algebra proofs (ie., proving a number system is a Boolean algebra). I want to emphasize proof-writing again. You should be familiar with proof by induction and proof by contradiction, in addition to direct proof. Proof by contrapositive is nice to have as well, but not nearly as important as induction and proof by contradiction.
Was This Post Helpful? 1
  • +
  • -

#13 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7765
  • View blog
  • Posts: 13,131
  • Joined: 19-March 11

Re: Learning Algorithms

Posted 21 February 2013 - 08:47 AM

Quote

You should be familiar with proof by induction and proof by contradiction, in addition to direct proof. Proof by contrapositive is nice to have as well, but not nearly as important as induction and proof by contradiction.


Good call. Proof by induction might be the hardest to get your head around*, and it's very important, particularly for recursive algorithms. If you make a particular effort to have this in your bag, you might find this smooths your path.


*At least, it seemed weird and magical to me the first few times I encountered.
Was This Post Helpful? 0
  • +
  • -

#14 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10573
  • View blog
  • Posts: 39,150
  • Joined: 27-December 08

Re: Learning Algorithms

Posted 21 February 2013 - 09:02 AM

I actually have a tutorial on Induction. :)
Was This Post Helpful? 0
  • +
  • -

#15 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7765
  • View blog
  • Posts: 13,131
  • Joined: 19-March 11

Re: Learning Algorithms

Posted 21 February 2013 - 09:12 AM

Why am I not surprised?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2