学习效率的算法 [英] Learning efficient algorithms

查看:104
本文介绍了学习效率的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到现在为止,我大部分集中在如何正确地设计code,使其尽可能地易读并作为维护越好。所以我送花儿给人选择了学习编程的更高级别的细节,例如类的交互,API设计等。

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?

推荐答案

数据主导。如果你设计你的程序围绕正确的抽象数据结构(ADT的),你经常会得到一个干净的设计,算法遵循很自然地,当性能不足,你应该能够插入更高效的。

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.

在数学和逻辑的强大的背景帮助在这里,因为它允许你在一个较高的水平,功能,集图,序列之间的相互作用,以可视化你的程序,等等,那么你决定是否设置需要订购(平衡BST,O(LG N)操作),否(哈希表,O(1)操作),操作都需要什么支持序列(矢量状或列表等),等等。

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.

如果您想了解一些算法,得到一本好书,如Cormen等。并努力实现主要的数据结构:

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

  • 在二叉搜索树
  • 在通用二叉搜索树
  • (上不仅仅是 INT 或字符串的工作)
  • 在哈希表
  • 在优先级队列/堆
  • 动态数组
  • binary search trees
  • generic binary search trees (that work on more than just int or strings)
  • hash tables
  • priority queues/heaps
  • dynamic arrays

这篇关于学习效率的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆