Imagine that you are in kindergarten again. After a long day, it's finally free time and you decide to play with blocks. You know exactly what I'm talking about: those wooden blocks in the corner of the classroom that you could build just about anything with. There are endless things to do with them if you use your imagination! Now, imagine that those blocks are pieces of information on a computer. Read below to understand what data, data structures, sorting algorithms, searching algorithms, and graph/tree algorithms mean in the context of a kindergartener playing with toy blocks!
Data: As mentioned above, each block in this situation represent a piece of data. In computer science terms, a piece of data can be anything from a number to a characteristic such as an item's color. Data is simply information that takes up space in the same way that a physical object like a block would.
Data Structures: A data structure is a way of organizing and storing data. Did you line up the blocks next to each other 1 by 1? This is an array. Did you pile the blocks directly on top of each other? This is a stack. Did you stack them in a 8-4-2-1 pyramid? This is a binary tree. There are countless different ways to store and manage data as well as many advantages and disadvantages to each.
Sorting Algorithms: Now, imagine that you would like to put a line of blocks into a specific order - let's say lighest to darkest. This is where sorting algorithms come into play. There are many different methods to sort this data into order from lighest to darkest and there are many advantages and disadvantages to each method.
Searching Algorithms: Now that the line of blocks is sorted as described above, you would like to find a particular dark red block that you put into the line. This is where searching algorithms come into play. There are a few different strategies to look for this dark red block and there are advantages and disadvantages to each strategy.
Graph/Tree Algorithms: What if we would like to search through some blocks but they're not in a straight line? Imagine that they are in the binary tree format described in the data structure section above. Graph/tree algorithms dictate specific paths to follow when exploring a tree or graph-like structure so that all blocks are visited in a consistent pattern.
Happy learning!