The next data structure we’ll be talking about is a tree. Like their real life counterparts, trees as a data structure have a root, some branches, some leaves, etc. In programming, a tree is basically just an extension of a linked list. Recall that an element or node in a linked list stores its value and a pointer to the next value. With a node in a tree, we store the value of a node and the next values for its children. A tree must also be completely connected, if we start at the first node, we can reach every element in the tree. There will also be no cycles, going down a tree can’t bring us back up.
So far, we have talked about data structures that use numerical indices to find values in an array. What if we want more freedom in how we look up a value. Consider the Oxford dictionary, if we wanted to find the definition (value) for a certain word (key), we would just look up the word.
Dictionaries are structured as maps. The main idea behind a map is that we can look something up by its key and find whatever is stored by its value. This key-value structure lends itself to many uses that an index based array could not. In Python, the dictionary data-structure is a map.
In computer science, we use algorithms to accomplish various tasks. An algorithm is just a series of steps that results in a desired outcome. For example, driving to work can be broken down into an algorithm: turn on car, back out, turn left, turn right, stop when arrived, etc.
Being able to create and apply algorithms allows us to write good programs. By good, we mean that it both solves the problem and does so efficiently. Almost every problem can be solved by “try every possible solution”, but this is rarely practical for application. Instead, we seek to get the right answer with the least amount of work.
This post will explore some of the most frequently used algorithms in computer science. Understanding the concepts behind them will lay the foundation for building even more complex algorithms.
A collection can be thought of as a group of things. For example, you could have a collection of toys, books, stuff in your room, etc. Collections don’t have a particular order and the types of things they contain can vary. For example, if you reorder a collection of books, it’s still a collection of books. If you ask for book number three, it doesn’t really mean anything.
This lack of structure reduces the usefulness of collections in the context of programming. To get around this, data structures have been developed that take collections and logical rules to them. This post will explore some of the most common list-based collections.
The story of the 2016 election centers around the unconventional, unprecedented rise of Donald J. Trump. Last night, with no elected office experience, a grab-bag of policy ideas that reflected neither party’s establishment, and a complete disregard for political correctness, Donald Trump attracted some 59 million votes and was named president-elect of the United States of America.
This has left many on the left in a state of panic and disillusionment. They feel that the election of Donald Trump marks the end of tolerance, diversity, and progressive ideals in America. On top of that, with the republicans winning both houses congress and multiple Supreme Court nominations in the balance, they feel that this might also mark the end of Democratic Party influence in government. This is probably an overreaction.
This document contains an independent analysis of Monsanto Co. (NYSE: MON). Information on my investment philosophy can be found here.