Eli5: explain data structure from computer science to a non technical person.

744 views

How do I explain what is data structure to someone who has never programmed before?

In: 15

17 Answers

Anonymous 0 Comments

Information can be organized in a number of ways, some of which give some pretty wicked benefits such as faster time to search.
For example, if you list your contact by name alphabetically on your phone, you can scroll to the beginning of the letter and quickly find the full name rather than searching every contact one by one.

The purposeful way computer programs store the information (data) is generally referred to as data structure.

Some useful data structures if you want to know more:

* Array (or Vector) pack information in a contiguous sequence next to each other, allowing computer to access any piece in any order randomly.
* HashMap (or Dictionary) uses fancy math to let you associate a piece of info (called key) with another (called value), such that you can find the value with a key as fast as you can.
* Linked list: Like Array but the information is not stored physically next to each other, so each piece needs to include the hint of where to find the next piece (or the previous one). This exists because you sometimes don’t have enough space for a continuous sequence to store the data, and so you need to just splinter them around. (and other benefits)
* Graph & Tree: Linked list but each piece of data can point to many other pieces, not just 1. Extremely powerful for many, many different problems.

Anonymous 0 Comments

Data structures are different ways to organize information, that are useful for different things. Usually they have two parts: a description of how the data is laid out, and a description of the actions you’re allowed to take on that collection of data. The way software is built, it’s usually to make a sort of logical “box” that you can _only_ interact with through those fixed actions. That’s really important, because it lets whoever maintains that box fix things, change things, and do all kinds of maintenance without everyone who uses the box needing to know about it – so long as that “contract” of what the actions are and what happens is followed, all its users get the same behavior. You’ll sometimes hear the word “API,” which is short for “application programming interface,” which is the name for that contract.

One simple example of a data structure is a list, also called an “array.” You can see how many items are in a list, look up any element of the list by position, change any element of the list by position, extend the list with new items, or shorten the list. This is useful for all sorts of things, so it’s one of the most basic data structures.

Another example of a data structure is a queue. A queue is useful for things like keeping track of a TODO list, but has many other uses as well. Its organization of data is like a list, but it allows far fewer actions. You can look at the list like any other list, but you’re only allowed to change it in two ways: add something to the queue (“get in the back of the line”), or remove (and get the value of) the item at the head of the queue. The rule is “first in, first out,” so part of the definition of that second action is that if you add A then add B, when you “dequeue” items you’ll get out A, then B, always in that order.

The restricted set of actions let everyone rely on the queue behaving like a queue of people in a shop. You know that so long as you’re dequeueing, everyone will ultimately get served, and things like that. If people were allowed to “break the API boundary” and modify the underlying list using actions _not_ allowed by a queue, then none of the users could predict anything!

(This is one part of why, when someone tries to be “clever” and fix a problem by breaking those rules, more experienced engineers will usually smack them upside the head. There are exceptions but you need a lot of experience to understand the when, the why, and the how to do that safely.)

There are lots of other data structures – records, linked lists, double-ended queues, priority queues, stacks, heaps, atomic words, and many more. Each is one of the basic tools used to build software.

Anonymous 0 Comments

Data structures are 2 things. Imagine the following.

There is a lot of cookie dough. That’s all the memory a computer has.

The cutter/mould you use to make shapes. That’s a class. It gives your memory structure.

Now that you have this cutter, you can make cookies out of the dough (memory). These individual cookies are called objects.

You need to make different types of shapes based on what you want to do.

Data structures is just a fancy shmancy word for designing the cutters and making cookies out it.

Anonymous 0 Comments

Imagine clothes as being like data. We have dressers for storing clean clothes that need to be folded and we have closets for storing clean clothes that need to be hung up. We also have laundry hampers to store dirty clothes that need to be washed. The way you put clothes into them, the way they’re stored and the way you get the clothes out can all vary, but all three are just containers for storing clothes.

Similarly, data structures are just containers for storing information. And just like our containers for clothes, there’s many different kinds of data structures that provide different ways of putting the data in, storing it or taking it back out, depending on your needs.

Anonymous 0 Comments

Computers are machines that use electricity to represent information. At its most basic, this information is just numbers.

Computer storage/memory therefore is just a big bucket of numbers. Numbers, text, images, audio, programs/instructions, all this data is just numbers. Without anything to give them context, all you have is a bunch of random-looking numbers.

Data structure is the way we give structure and meaning to those numbers so they can be used in the most efficient way for the task at hand.

Anonymous 0 Comments

Some data structures are named after real-world things.

A ‘stack’ is a metaphor for a real-world stack of items. Imagine a stack of pages. You can only access the top page. Notable, the first item to be placed in the stack is at the bottom, meaning it is always the furthest away from you. Also, the latest page to be left on the stack is on top for you to see.

A ‘queue’ is a metaphor for a real-world queue, where whatever was added to the queue first will get looked at first, and whatever was added last will be looked at last.

In computer science, we make these things extremely strict. Like with a real-world stack of papers, if you wanted to sneak a peak at the middle page, you could. Or with a real-world queue, someone might barge in and skip to the head of the line. In computer science, we instead pretend that these rules are never broken. The stack is only ever accessed at the top of it, both to add and remove data, and we can only ever add to the back of a queue and take from its front.

Making sure that things follow these rules can be helpful for some programs.

You might think you should just let everything be accessible at all times for the sake of convenience, but this can get confusing (or unsecure), and sometimes knowing for sure that something follows these rules is helpful for working out how to reat the data that comes in that way.

In computer science, we use data structures like this to help us. We also sometimes invent new data structures that don’t have a real-world metaphor, but do have some digital properties we like.

Anonymous 0 Comments

A data structure is simply a way to shape something to make it easy doing one certain thing with it.

Say you decide to build a wooden chair: you order the pieces online.

During transportation, minimizing space is required, so it’s likely that the pieces will be placed very tight together.

Once you begin building, you need easy access to the next piece in sequence, so you might spread the pieces around a bit.

After finishing, the chair will need to support the weight of a person, which has been achieved by setting the pieces the right way.

In each stage, the pieces were structured to give an advantage on the current task. As you can imagine, they represent the data being structured as necessary.