A Brief Intro to Data Structures

Data Structures are pretty important in programming, as they allow one to organize information that they have. There are 4 basic types that I’ll cover here, complete with shoddy diagrams!

Array 1. Array
An array is easiest to think of as a table; pieces of data are contained within the table in a specific order, and each is assigned an integer that can be used to refer to that specific piece. This makes using the data very easy, as one can just type in the integer to reference the data needed. Arrays made in JavaScript are fixed length; in order for it to record more data, a whole new array must be made.

2. Stack
Stack Stacks have a vital acronym that can be used to explain their function very easily: FILO. This stands for First In Last Out. Why is that significant? In a stack, new data that is added is “pushed” on top of the old data. So you push Apple into a stack, then Cat, then Bee, then Duck. If you want to reorder this stack, you would have to “pop” Duck off the stack first in order to then pop off Bee. And to pop Apple, the data on top would have to be popped first. Hence the saying: First In Last Out.

Queue 3. Queue
Queues also have an acronym that can be used to describe them, and the concept is much more familiar to most. FIFO (First In First Out) applies to many things, such as print queues or download queues. As one might expect, the name gives it away; they are both examples of the data structure queue. For queues and stacks, the same terminology is used to reference adding data (push) and removing data (pop).


4. Binary Tree
Binary TreeBinary Trees consist of data referred to as parents and children; children can also be parents and have children, however, the maximum number of children any parent can have is two. In a binary tree, the original parent is called the root of the data structure, while the children who are not parents as well are called leaves. The parent and successive children of a binary tree are called nodes, and these nodes can link to one another along pathways from parent to child. The nodes contain data which is organized in a way for the succession of pathways to make some sense (unlike the example).

4 thoughts on “A Brief Intro to Data Structures

  1. also note that arrays don’t just have to contain integers, they can contain structs, strings, objects, pointers, etc.

    Integers are just one example, which is probably the easiest

    good work!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s