r/Python • • Aug 11 '15

Do I need to know algortithms?

As the title says, do I need to learn basic sorting & other algorithms to be able to get a job? Are they hard to learn? Does they make a difference in performance?

Also, when I'll need to use some special algo?

0 Upvotes

10 comments sorted by

13

u/Benderbboson Aug 11 '15

Yes

1

u/MorrisCasper λ Aug 11 '15

I'm not OP, but why would I have to learn algorithms like these? Couldn't I just use the built-in sort function?

1

u/[deleted] Aug 11 '15

The link you gave is the implementation of the algo in python, not the algo itself. The algos are described in the wikipedia links.

You have to learn them, to demonstrate your skill of learning algos.

If you can demonstrate that on some other way, then you do not need them. Until you will, then you will look it up on the net.

The algos for sorting are ideal for teaching-demonstration purposes. The problem is easy to grasp, no domain or any specialized knowledge required. The result is easy to measure. The speed, memory usage, stability and implementation specific differences can be huge. It is easy to demonstrate wtfs.

7

u/syntaxvorlon Aug 11 '15

Mostly it's a matter of knowing how to use what algorithm when, and how to identify algorithms that are being employed by programs that others are using. A lot of the time you'll find that you can't solve everything with standard library routines and you may have to branch out into third party routines, write your own or you may be entering a situation where a number of programmers have been writing custom libraries for whatever piece of proprietary software.

When you run into a situation where your only recourse is to write your own code to fix a problem, then you want to be able to pull from a toolbox and know you're not using three wrenches to do the job of a single screwdriver.

5

u/[deleted] Aug 11 '15 edited Aug 11 '15

do I need to learn basic sorting & other algorithms

Choosing the appropriate sorting algo is not the most common task in programming, but...

If you are programming you will be using algorithms. If you don't know them, you will eventually reinvent the wheel....

Even the most basic regular file parsing task can cause - if using a wrong approach - serious performance bottlenecks.

Sorting algos are learned because these can teach the importance and process of choosing (and designing) of an algo.

to be able to get a job?

To get a job, you have to be smart and get things done. If you get a sorting task and try to solve it as a 6 year old (smart) kid, you do not appear to be smart.

Are they hard to learn?

As hard as learning anything mathematically abstract. Is linear algebra hard?

Does they make a difference in performance?

Yes.

Also, when I'll need to use some special algo?

That is part of learning the algo.

1

u/logophage Aug 11 '15

Knowing some basic sorting algorithms doesn't hurt. However, you will almost never need to know the details of a sort. If you're using databases, for example, understanding indexing and how to design a good query is far more important.

1

u/inspired2apathy Aug 11 '15

understanding indexing and how to design a good query

To understand that, though, you need to understand the costs of lookups, insertion and deletion in a DB index, which is closely related to various sorting algorithms.

2

u/logophage Aug 11 '15

I disagree. You use that to help you. However, indexing is not the same as sorting.