If advanced algorithms and data structures are never used in industry, then why learn them?

转载 2014年05月06日 11:03:44

Here is one question from Quora. Just record it here...

I and people I know have never used any advanced algorithms or data structures in industry and some of us have 20 years of experience in industry. How do you motivate yourself to learn advanced algorithms and data structures or, for that matter, go for Programming contests?

A) The way I see it, it is not algorithms that I need in everyday life, but the ability to quickly analyze the problem and find a solution. If you can solve a TopCoder problem in 2 minutes, or several difficult ones on ACM under 5h then chances are that you will be able to understand mumbling of the product owner and create a good technical specification with nice architecture and neatly implement it, meanwhile explaining flaws of the original functional specification to the product owner in a comprehensive, basic way. I believe that these 10 years of programming competitions was what made a difference between being a programmer and being an architect.

Also, I think that understanding how a B-tree is implemented can help you understand performance issues with your SQL query. This is just an example of situations where you do not implement an algorithm or a data structure in a project, but still benefit from understanding why and how something works. I would say that knowledge about compression algorithms, randomized algorithms etc also helped me more than once at work.

Also, if you know how to implement a cool data structure or an algorithm using C++ STL primitives, chances are you will be able to reproduce it using Redis + LUA, or at least know what you could hypothetically do using them. I found that knowing lower and upper bounds, helps you (as an architect) make decisions. For example if you know, that "it could run in O(n) but we would need 2 months to build and test it" and "it could run in O(nlgn) using a simple MySQL" then you know exactly what to do. In a sense it is like "approximation algorithms" but the main resource are people, and maintainability, and your adversary is the OPT algorithm you learned at university.

B) This is like a football player asking "Why lift weights when a football weighs less than a pound?" The point is to train yourself to the point where the algorithms problems you actually run into are all trivial, and you can devote your mental resources to building good systems instead of trying to remember how quicksort works.

C) First, you need to know how algorithms and data structures work when choosing which one to use from an API. You want to store key/value pairs in a data structure? You know you can use a Hash Map which gives you O(1) for insertion/seek/delete. Oh, but then you realize you need to iterate the values in certain order. Do you know how a Hash Map works? How does it grow? How does the algorithm decide the order of the elements? Or is it completely random? So you use a Binary Tree, and you may end with an unbalanced implementation that is even slower than using just an array of tuples and iterating it. Maybe a Red Black Tree is a better option, it's balanced so it gives you O(log N) for insertion/seek/delete and you can iterate it by the natural ordering of the key. But how are you going to make an informed choice without knowing how does each algorithm and data structure works?

Second, if you are speaking about sorting algorithms and the like, yes, you may never get to implement one in real life as most APIs come with a heavily optimized implementation of basic algorithms. But try to implement text prediction without knowing how a Trie works, or solving any path/distance/proximity/networking problem without even basic Graph and BFS/DFS knowledge.

Yes: you can make a living developing CRUD applications without any knowledge of advanced algorithms and data structures, just like I could have a 56k modem at home and say I'm 'connected' to the internet. But that only speaks about the limitations with which I chose to live; it does not mean that anything beyond those limitations is useless.



下载电子书Problem Solving with Algorithms and Data Structures using Python

哥哥的拥有欲望很强烈,看到书就想下载,手里痒痒就拿网络爬虫来练手。 1、下面是源代码,刚下载两页就老提示断网: Exit with code 1 due to network error: Hos...
  • kaihuangzheng0050
  • kaihuangzheng0050
  • 2017年04月13日 17:33
  • 983

基于Problem Solving with Algorithms and Data Structures using Python的学习记录(5)——Searching

5.1.目标 能够解释和实现顺序查找和二分查找。 能够解释和实现选择排序,冒泡排序,归并排序,快速排序,插入排序和 shell 排序。 理解哈希作为搜索技术的思想。 引入映射抽象数据类型。 使用哈希实...
  • HeatDeath
  • HeatDeath
  • 2017年03月30日 13:39
  • 727

Problem Solving with algorithms and data structures using Python 翻译计划

作为学习python中读得最完整的一本书,而市面上确实没有中文版,用python讲数据结构和算法的书,所以打算逐步翻过来。 主要目的是实现一次精读。用一段英文一段中文的方式。插图只好复制过来...
  • ppabcde
  • ppabcde
  • 2014年03月14日 10:36
  • 3822


  • Cloud_Strife_1985
  • Cloud_Strife_1985
  • 2017年04月20日 20:15
  • 492

Java 9 Data Structures and Algorithms.pdf

Java 9 Data Structures and Algorithms.pdf https://www.packtpub.com/application-development/java-9-...
  • Cloud_Strife_1985
  • Cloud_Strife_1985
  • 2017年07月16日 09:48
  • 554

Python Cookbook 学习笔记 第一章Data Structures and Algorithms

今天学习完了一部分Cookbook书上的内容,做一个笔记。 一、问题:如何将一个N个元素的元组或者序列拆解成为N个变量。 解决:对于任何 iterable的对象,例如元组、列表、文件...
  • xiaoka1993
  • xiaoka1993
  • 2016年05月15日 20:57
  • 284

Data Structures and Algorithms with Object-Oriented Design Patterns (1)

Array       Sort it using Quick Sort or Heap SortLinked List       Sort it using Merge SortDoubly Li...
  • allenwu3
  • allenwu3
  • 2007年08月16日 16:03
  • 386

基于Problem Solving with Algorithms and Data Structures using Python的学习记录(4)——Recursion

4.1.目标本章的目标如下: 要理解可能难以解决的复杂问题有一个简单的递归解决方案。 学习如何递归地写出程序。 理解和应用递归的三个定律。 将递归理解为一种迭代形式。 实现问题的递归公式化。 了解计算...
  • HeatDeath
  • HeatDeath
  • 2017年03月29日 14:10
  • 539

基于Problem Solving with Algorithms and Data Structures using Python的学习记录(3)——Basic Data Structures

3.1.目标● 了解抽象数据类型:栈 stack、队列 queue、双端队列 deque 和列表 list; ● 用 Python 列表数据结构,来实现 stack/queue/deque 抽象数据...
  • HeatDeath
  • HeatDeath
  • 2017年03月29日 10:39
  • 608

Data Structures and Algorithms with Object-Oriented Design Patterns (5)

Graph and Graph Algorithms       Basic Concepts      Directed Graph (Digraph) and Undirected Graph  ...
  • allenwu3
  • allenwu3
  • 2007年08月18日 17:38
  • 552
您举报文章:If advanced algorithms and data structures are never used in industry, then why learn them?