202: Graphs vs. Trees vs. Hierarchies: Compared.
Take Up Code - Un pódcast de Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes
Categorías:
Before exploring HTML and CSS further, you’re going to need to understand graphs, trees, and hierarchies. These concepts apply throughout programming and are not limited to just HTML and CSS. But as I was trying to figure out what topic to explain next to you, I realized that you’re going to need to understand these topics in order to master HTML and CSS. You’ll be glad you took the time to understand these when you encounter them again in your code. All trees are actually graphs. But not all graphs can be called trees. There are four special conditions that a graph must follow in order to be considered a tree: There can be no cycles in a tree. Every vertex represents a node that is the root of a subtree. . Every two nodes in a tree are connected by exactly one path. . A tree is fully connected and has exactly one less edge or connection than nodes. So how do hierarchies fit into all this? A hierarchy is a tree with a couple extra properties: The first is inheritance either up or down the hierarchy. The second property of hierarchies is that they consider roles. Make sure to listen to the full episode for more details and examples and subscribe to the podcast so you’ll get future episodes automatically. You can also read the full transcript below. Transcript These concepts apply throughout programming and are not limited to just HTML and CSS. But as I was trying to figure out what topic to explain next to you, I realized that you’re going to need to understand these topics in order to master HTML and CSS. You’ll be glad you took the time to understand these when you encounter them again in your code. Let’s get started. There’s a lot to cover and as I was brainstorming, my notes quickly filled up several pages. This episode will be an introduction focused mainly on comparing graphs with trees, and then with hierarchies. I’ll go into more details in future episodes. I always like to learn new topics by comparing and contrasting them together and with what I already know. You might also benefit from this. Our brains work by associating things together. We think of something and that brings up other thoughts of things similar in some way. This makes it easier to remember something if there’s many different ways to get to whatever it is you’re trying to remember. So whenever you want to learn something new, it’s always a good idea to link it into your thoughts in many different ways. Thinking about how something relates to things you already know either through similarities or through differences is a great way to improve how fast you can learn something. It’ll also improve your ability to remember it later. That’s why I like to give you examples of things you can relate to when explaining new concepts. You might forget some of the details and that’s okay. You can always look those up later when needed. Having a firm grasp of the basic concepts is important though to help guide you as you refresh yourself on the details. The topics today are actually very related to everything I’ve just said. That’s probably why I went off on that sidetrack. Whenever I think of how things are related, I think of how our memories work on relations. And graphs, trees, and hierarchies are all about relations. A graph is the most general way to relate things. A good example is a map of world countries in Europe or of the states in a map of the United States. Think of how the countries are positioned so they touch one another. In order to go from one country to another, you can either go straight there or you can take a winding path through many countries. You might even pass through a particular country many times on your journey. And with modern airline travel, you can even go from one country to another even if they don’t share a border. Each country in this example is called a vertex in a graph. The connections between countries either di