4 ms·
Ask YC: Data structure or Algorithm selection for a problem?
data structure or algorithm which one is more important in solving a problem
and how selection of both is important in solving a problem
- cperciva 19y agoTo quote Hofstadter: Mu. Particular algorithms operate on particular data structures; a binary search on a sorted list makes sense, while a binary search on an unsorted list is meaningless. It doesn't make any sense to have one of "a good algorithm" or "a good data structure" without the other.
- yearsinrock 19y agoI think this reply perfectly answers my question.
- aristus 19y agoMooooo..... :) I usually visualize the data structure that exists, or that I want, and work "backwards" from there. But whichever direction you use, always always remember that the idea is to make the design simpler and more clear.
- boucher 19y agoWell, no, not always, always. Use the data structure that makes the design more efficient. Clarity might be nice, but an O(n) solution is not acceptable when a reasonable O(log n) or O(1) solution exists.
- flashgordon 19y agoI didnt think that choice was orthogonal?
- bayareaguy 19y agoI suggest you read "Algorithms + Data Structures = Programs" by Niklaus Wirth. http://tinyurl.com/yw7tgo http://tinyurl.com/yw7tgo
- z0ltanz0ltan 19y agoAt all the above maniacs ... I think what yearsinrock meant was "Data Structure and Algorithm" selection for a specific problem...
- cperciva 19y agoThat was my first thought based on the thread title, but it doesn't quite fit with the text "data structure or algorithm which one is more important in solving a problem" which follows.
- boucher 19y agoGood introductory text: Cormen/Leiserson/Rivest/Stein: Introduction to Algorithms (2nd edition) http://www.amazon.com/Introduction-Algorithms-Thomas-H-Cormen/dp/0262032937/ref=pd_bbs_2?ie=UTF8&s=books&qid=1198139015&sr=1-2 http://www.amazon.com/Introduction-Algorithms-Thomas-H-Corme... Good advanced text: Jon Kleinberg/Eva Tardos: Algorithm Design http://www.amazon.com/Algorithm-Design-Jon-Kleinberg/dp/0321295358/ref=pd_bbs_2?ie=UTF8&s=books&qid=1198138989&sr=8-2 http://www.amazon.com/Algorithm-Design-Jon-Kleinberg/dp/0321...