Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Learning efficient algorithms

Up until now I've mostly concentrated on how to properly design code, make it as readable as possible and as maintainable as possible. So I alway chose to learn about the higher level details of programming, such as class interactions, API design, etc.

Algorithms I never really found particularly interesting. As a result, even though I can come up with a good design for my programs, and even if I can come up with a solution to a given problem it rarely is the most efficient.

Is there a particular way of thinking about problems that helps you come up with an as efficient solution as possible, or is it simple a matter of practice and/or memorizing?

Also, what online resources can you recommend that teach you various efficient algorithms for different problems?

like image 513
Paul Manta Avatar asked Mar 12 '11 14:03

Paul Manta


People also ask

What is the best learning algorithm?

Decision Tree Decision Tree algorithm in machine learning is one of the most popular algorithm in use today; this is a supervised learning algorithm that is used for classifying problems. It works well in classifying both categorical and continuous dependent variables.

What is a learning algorithm?

A learning algorithm is a method used to process data to extract patterns appropriate for application in a new situation. In particular, the goal is to adapt a system to a specific input-output transformation task.


2 Answers

Data dominates. If you design your program around the right abstract data structures (ADTs), you often get a clean design, the algorithms follow quite naturally and when performance is lacking, you should be able to "plug in" more efficient ones.

A strong background in maths and logic helps here, as it allows you to visualize your program at a high level as the interaction between functions, sets, graphs, sequences, etc. You then decide whether the sets need to be ordered (balanced BST, O(lg n) operations) or not (hash tables, O(1) operations), what operations need to supported on sequences (vector-like or list-like), etc.

If you want to learn some algorithms, get a good book such as Cormen et al. and try to implement the main data structures:

  • binary search trees
  • generic binary search trees (that work on more than just int or strings)
  • hash tables
  • priority queues/heaps
  • dynamic arrays
like image 151
Fred Foo Avatar answered Sep 19 '22 05:09

Fred Foo


Introduction To Algorithms is a great book to get you thinking about efficiency of different algorithms/data structures.

The authors of the book also teach an algorithms course on MIT . You can find most lectures here

like image 38
SpotsWood Avatar answered Sep 20 '22 05:09

SpotsWood