Thanks to learn-java-tutorial for this array image! |
Certain data structures are more efficient at doing different things. For example, an array is very good at cycling through a list of things that you want to look through. For those of you that don't know what an array is, it's an arrangement of objects in rows an columns. Here is a youtube video explaining it, for those of you that are more visual learners. The most basic array would be a line of data, something one-dimensional like writing names down in a column. More complex arrays can be two-dimensional, something equivalent to writing names and numbers next to the names in a column, or even 3, 4, 5 dimensions. The only limit to the amount of dimensions an array can have is the power of your computer or integrated development environment. Another type of data structure is a binary tree, which is useful for searching through information that can be sorted by value. The tree consists of "nodes" and each node has a value and a reference to a left and right node. The left reference node will always be less than the node you're looking at and the right one will always be greater. This means that each level you go down the tree, you are cutting the searching time in half (assuming that the tree is balanced and both sides are filled).
In addition to arrays and binary trees, there are many other data structures, such as hash tables, graphs, and other types of trees. Each one has its benefits and drawbacks related to efficiency in runtime, storage size in bytes, adding/removing elements, searching, etc. Programmers must always think about which data structures would be best to use to accomplish certain tasks, and implement them efficiently. I hope you learned something from this post about data structures and if anyone has any questions or comments, please reply below!
No comments :
Post a Comment