<p>What are the most common problems that can be solved with both these data structures?</p>

<p>It would be good for me to have also recommendations on books that:</p>

<ul>
<li>Implement the structures</li>
<li>Implement and explain the reasoning of the algorithms that use them</li>
</ul>

[{'answer_id': 2996, 'author': 'Patrick', 'author_id': 429, 'author_profile': 'https://Stackoverflow.com/users/429', 'pm_score': 1, 'selected': False, 'text': '<p>There\'s a course for such things at my university: <a href="http://www.cs.washington.edu/education/courses/326/" rel="nofollow noreferrer">CSE 326</a>. I didn\'t think the book was too useful, but the projects are fun and teach you a fair bit about implementing some of the simpler structures. </p>\n\n<p>As for examples, one of the most common problems (by number of people using it) that\'s solved with trees is that of cell phone text entry. You can use trees, not necessarily binary, to represent the space of possible words that can come out of any given list of numbers that a user punches in very quickly. </p>\n'}, {'answer_id': 2999, 'author': 'Steve Willard', 'author_id': 402, 'author_profile': 'https://Stackoverflow.com/users/402', 'pm_score': 5, 'selected': True, 'text': '<p>The first thing I think about when I read this question is: <em>what types of things use graphs/trees?</em> and then I think backwards to how I could use them.</p>\n\n<p>For example, take two common uses of a tree:</p>\n\n<ul>\n<li>The DOM</li>\n<li>File systems</li>\n</ul>\n\n<p>The DOM, and XML for that matter, resemble tree structures. <br>\n<img src="https://i.stack.imgur.com/bk5RY.gif" alt="alt text"></p>\n\n<p>It makes sense, too. <strong>It makes sense because of how this data needs to be arranged</strong>. A file system, too. On a UNIX system there\'s a root node, and branching down below. When you mount a new device, you\'re attaching it onto the tree.</p>\n\n<p>You should also be asking yourself: does the data fall into this type of structure? Create data structures that make sense to the problem and the rest will follow.</p>\n\n<p>As far as being easier, I think thats relative. Are you good with recursive functions to traverse a tree/graph? What if you need to balance the tree?</p>\n\n<p>Think about a program that solves a word search puzzle. You could map out all the letters of the word search into a graph and check surrounding nodes to see if that string is matching any of the words. But couldn\'t you just do the same with with a single array? All you really need to do is move an index to check letters to the left and right, and by the width to check above and below letters. Solving this problem with a graph isn\'t difficult, but it can create a lot of extra work and difficulty if you\'re not comfortable with using them - of course that shouldn\'t discourage you from doing it, especially if you are learning about them.</p>\n\n<p>I hope that helps you think about these structures. As for a book recommendation, I\'d have to go with <strong><a href="https://rads.stackoverflow.com/amzn/click/com/0262032937" rel="noreferrer" rel="nofollow noreferrer">Introduction to Algorithms</a></strong>. </p>\n'}, {'answer_id': 6087, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p><a href="https://rads.stackoverflow.com/amzn/click/com/0201361213" rel="nofollow noreferrer" rel="nofollow noreferrer">Algorithms for Java: Part 5</a>  by Robert Sedgewick is all about graph algorithms and datastructures. This would be a good first book to work through if you want to implement some graph algorithms.</p>\n'}, {'answer_id': 6104, 'author': 'Coincoin', 'author_id': 42, 'author_profile': 'https://Stackoverflow.com/users/42', 'pm_score': 1, 'selected': False, 'text': '<p>Scene graphs for drawing graphics in games and multimedia applications heavily use  trees and graphs. Nodes represents objects to be rendered, transformations, controls, groups, ...</p>\n\n<p>Scene graphs usually have multiple layers and attributes which mean that you can draw only some node of a graph (attributes) in a specified order (layers). Depending on the kind of scene graph you have it can have two parralel structures: declarations and instantiation. Th</p>\n'}, {'answer_id': 9235, 'author': 'David Joyner', 'author_id': 1146, 'author_profile': 'https://Stackoverflow.com/users/1146', 'pm_score': 2, 'selected': False, 'text': '<p><a href="https://rads.stackoverflow.com/amzn/click/com/0387948600" rel="nofollow noreferrer" rel="nofollow noreferrer">The Algorithm Design Manual</a> contains some interesting case studies with creative use of graphs.  Despite its name, the book is very readable and even entertaining at times.</p>\n'}, {'answer_id': 29226, 'author': 'Ryan Cox', 'author_id': 620, 'author_profile': 'https://Stackoverflow.com/users/620', 'pm_score': 1, 'selected': False, 'text': '<p>@DavidJoiner / all:</p>\n\n<p>FWIW: A new version of the <a href="https://rads.stackoverflow.com/amzn/click/com/1848000693" rel="nofollow noreferrer" rel="nofollow noreferrer">Algorithm Design Manual</a> is due out any day now.</p>\n\n<p>The entire course that he Prof Skiena developed this book for is also available on the web:</p>\n\n<p><a href="http://www.cs.sunysb.edu/~algorith/video-lectures/2007-1.html" rel="nofollow noreferrer">http://www.cs.sunysb.edu/~algorith/video-lectures/2007-1.html</a></p>\n'}, {'answer_id': 31607, 'author': 'Tim Williscroft', 'author_id': 2789, 'author_profile': 'https://Stackoverflow.com/users/2789', 'pm_score': 2, 'selected': False, 'text': '<p>Circuit diagrams.</p>\n\n<p>Compilation  (Directed Acyclic graphs)</p>\n\n<p>Maps. Very compact as graphs.</p>\n\n<p>Network flow problems.</p>\n\n<p>Decision <em>trees</em> for expert systems (sic)</p>\n\n<p>Fishbone diagrams for fault finding, process improvment, safety analysis.  For bonus points, implement your error recovery code as objects that <em>are</em> the fishbone diagram.  </p>\n'}, {'answer_id': 626219, 'author': 'Jason Baker', 'author_id': 2147, 'author_profile': 'https://Stackoverflow.com/users/2147', 'pm_score': 1, 'selected': False, 'text': '<p>Trees are used a lot more in functional programming languages because of their recursive nature.</p>\n\n<p>Also, graphs and trees are a good way to model a lot of AI problems.</p>\n'}, {'answer_id': 626327, 'author': 'Brian Postow', 'author_id': 53491, 'author_profile': 'https://Stackoverflow.com/users/53491', 'pm_score': 2, 'selected': False, 'text': "<p>Just about every problem can be re-written in terms of graph theory. I'm not kidding, look at any book on NP complete problems, there are some pretty wacky problems that get turned into graph theory because we have good tools for working with graphs...</p>\n"}, {'answer_id': 3157195, 'author': 'Kylotan', 'author_id': 28875, 'author_profile': 'https://Stackoverflow.com/users/28875', 'pm_score': 1, 'selected': False, 'text': '<p>Games often use graphs to facilitate finding paths across the game world. The graph representation of the world can have algorithms such as breadth-first search or A* in order to find a route across it.</p>\n\n<p>They also often use trees to represent entities within the world. If you have thousands of entities and need to find one at a certain position then iterating linearly through a list can be inefficient, especially if you need to do it often. Therefore the area can be subdivided into a tree to allow it to be searched more quickly. Just as a linear space can be efficiently searched with a binary search (and thus divided into a binary tree), 2D space can be divided into a <a href="http://en.wikipedia.org/wiki/Quadtree" rel="nofollow noreferrer">quadtree</a> and 3D space into an <a href="http://en.wikipedia.org/wiki/Octree" rel="nofollow noreferrer">octree</a>.</p>\n'}]
['https://Stackoverflow.com/questions/2988', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/861/']