This is part 4 of an ongoing series detailing my journey from total noob to hobbyist coder. I share my thoughts as I learn the basics of programming. You can find the rest of the series here.
My StackCodes curriculum relies on FreeCodeCamp for lessons. I felt at least partly at home during the HTML and CSS lessons, having spent over a decade in the world of digital media. I’ve worked with TypePad, WordPress, Chorus, and several homebrew systems. When I was working at The Verge, we had regular discussions with the team making product tweaks to the software.
When you’re going through the HTML and CSS, each lesson explains what the purpose of your code would be in a real-world application, and shows you how your code changes the website in real time, right in the browser. That all changes when you get to Javascript. I’ll give you an example. When you get to arrays in the FreeCodeCamp curriculum doesn’t explain how this data structure fits into the history of computer programming or how you might use it in a real world application today. You’re learning by rote in a vacuum.
I was able to breeze through these array lessons without stumbling over any character errors, but I doubt I would retain the information very well, because I don’t have a clue what I’m building or why. When the course shifts to functions, there is no explanation of how that might be related to arrays.
As it turns out, this is a common experience. As noted in a 2017 academic paper on the topic, “In the field of computing, data structures is a fundamental course that lays a critical foundation for the rest of the curriculum and is a solid basis for industry projects. A sound understanding of data structures, hence is indispensable for any student aiming to pursue a career in this field.” Ok, it’s important, but, “Data structures course is perceived to be a difficult subject for students, particularly the ones in high school because it is difficult for them to visualize how the data structures are structured and analyze its properties; hence they do not get the required motivation to pursue it in the way it should be.”

My sentiments exactly. Luckily, a little research turned up some options for a more engaging approach to learning about arrays. When you start teaching about optimizing time complexity in order to defeat the Nazis, I’m sitting up and paying attention!
This Udemy course also helped. It uses the metaphor of a grocery store. You have an array of fruits. I can easily imagine how a computerized inventory system might go about tracking what produce was in stock based on bar codes entered by the cashier at the time of sale.
In the 2017 paper I linked above, the authors suggest that music might be a useful tool for teaching students about data structures.
“Muse can be considered as a practical application of this approach that teaches the operations on arrays and linked lists through music. There is a mapping between the musical notes and their corresponding tones (SouthCalMusic), (Do Re Mi Isn’t Just Child’s Play: How Solfege Training Can Improve Your Ear). This mapping is exploited for explaining the concepts of arrays and linked lists as shown in Table 1. The implication of this mapping is that different sequences of musical notes produce different tunes. Also, it is implicit that the various operations on arrays and linked lists of musical notes manipulate the sequence of notes differently. So, this difference in the sequences or the effect of the operations is brought out through different tunes. Hence, the similarity and the difference in the musical tunes is analogous to the difference in 803 arrays and linked lists.”
When I wrote my first column in this series, I said that I had an idealized vision of programming in my head, that it would change my brain In strange and unexpected ways. I’m still far from mastering even basic computers science, but I can feel my mind starting to discover new pathways, new frameworks and metaphors for thinking about life. From arranging musical notes to tracking fruit on a shelf, from allocating hours in my week to exercise versus family time, or organizing the editorial calendar here at Stack Overflow, arrays seem to be everywhere. Like the Fibonacci sequence, once you start to understand it, you start to see it everywhere in nature, a hidden layer of structure that was around you all the time.
—
Our 2020 Developer Survey is open. We want to hear from everyone who codes. Professional or hobbyist, Stack Overflow user or not, share your thoughts with us so we can get a picture of the world’s programmers.
—
31 Comments
Arrays, lists, and all that other stuff are just ways of dealing with things you do naturally.
A sentence is essentially an array of words and each word is it’s own element. Taken further, a word is an array of characters. Put these two ideas together, and you have a 2D array. Taken even further, a paragraph can be an element in an array, so a letter, email, etc. can be grouped into a 3D array. If you have a book, you can arrange the chapters into individual array elements for a 4D array, a series of books can be a 5D array, and all books or series of books by an author could be a 6D array, with a library being a 7D array. You wouldn’t normally do this, as there are better ways to organize and structure all this, but it’s about as simple as I can explain how data structures like arrays can be everywhere and how things can easily fit into “complex” structures.
Another 2D array is the table you have listing the attributes and comparisons between data structures and music. The list of classes you’ve taken is another example that can be put into a 1D array.
The more complex data structures are simply better ways to move around the grouping you’ve made. Sometimes an array or list isn’t a good data structure, so objects are used instead, which in turn can have complex data structures in them or be part of a larger complex data structure.
Once you realize how you can use a data structure, the concept becomes much simpler. Oftentimes, actually using them is more difficult than the concept itself. And be glad you don’t have to deal with pointers, of olden days of yore.
I did not read this whole reply….but the first sentence was of my own thinking too. Arrays, functions…they just be mathematical concepts anyway. Not knowing how they apply in the real world has little to do with programming
Sometimes I have find it so confusing too, but with constant practicing I get to know more about it
When I got stuck on arrays/functions in FCC, I went over to the Mozilla Developer Network to try and re-establish my foundation. MDN does a great job of breaking things down and explaining why you’re doing what you’re doing.
I can now return to the same spot in FCC with more confidence, so I‘ve got that going for me.
I still stuck at coding, unfortunately.
Every dev student I know using FCC hits the JavaScript wall. Good post! I do believe you meant JavaScript and not Java, tho. Hope you don’t get too many devs screaming about that 😀
He means Java. And he is correct.
Yes, Javascript, not Java. Thanks for catching that. Fixed it.
So the free course is in Java or javascript?
My suggestion from what I saw, (I apologize for not having read the full article) is not to do courses. Courses can have a lot of these issues where they teach you a concept without rhyme or reason. However, a better approach can be to decide ahead of time what your plan is, what you want to do, then get to work with the tools you understand. You will eventually hit a roadblock, and that will be queue to do some research. This cycle repeats until your project has finished, and you are far more knowledgeable than you were at the start. The project will be flawed. It won’t be perfect by any measure, but it was a learning opportunity. Eventually you will start to apply your knowledge to a task that is set before you, rather than of your own design. By this point, you should be quite experienced, and know how to approach a problem in a good manor. This is a more practical approach than courses, and I believe it works more efficiently. I am open to dispute on this.
I am open to learning about this stuff through projects or games. Any you would suggest?
It is really the science of computation. That a “computer” does it is just a tool actioning a mathematical design.
One of Alan Turing’s great breakthroughs was the ability to compute complicated instructions in non sequential order with his Turing machine, thus leading to the broader application of modern https://en.wikipedia.org/wiki/Automata_theory (this is a DEEP rabbit hole).
The real world application of a concept or solution can be tricky to teach or learn from another.
The data structures issue is more of a tool to remember. If I gave you a hammer when you had never seen a nail and didn’t tell you what to do with it then you may be confused or not want it taking up space in your toolbox…..but what happens in your brain when you see a nail for the first time? The hope is that your brain makes the connection between hammer and nail on its own.
Data structures solve so many problems that its not practical to list all currently known problems solved by them. Even if it was practical you may sub-consciously limit the application of the solution to only the problems you know about.
The intuition to link problems and solutions makes a good programmer. The ability to devise new solutions to known and new problems has potential to make a more efficient programmer
Yes, this has been something I’ve discussed with Sara Chipps, my coding coach. Imagine you ask a group of 4 year olds how to make a peanut butter and jelly sandwich. You have bread, two jar, a knife, etc. It seems simple at first to say, just spread the peanut butter and jelly on the bread. But what if the teacher the simply rubs the unopened jars on the bread. You need to open the them first. What about spreading. You might do peanut butter on one side and jelly on the other. leaving you a single slice that is impossible to eat without getting messy.
We internalize so many structures and steps, it’s easy to forget what you don’t know until you start from square one, like I am these days with programming.
One of my CS professors (this was at RPI a quarter-century ago) made the same point, but using knowledge that nearly all of us share, and (more importantly) not a single one of us was INSTRUCTED on: Walking.
You CAN explain how to make a sandwich to someone — you’ll get there eventually. (At least as long as you define a stopping point where some basic concepts can be considered pre-defined, like how objects are manipulated in physical space. Otherwise it’s turtles all the way down.)
But, try telling someone how to *walk*. Explain the actions involved in crossing the room on your own two feet. It’s a hellishly complicated process, really. And it’s one that, as often as we perform the actions involved, we never really conceptualize HOW. We just… do it. When you start trying to describe how it works in concrete terms, there’s a reasonable danger you’ll end up confusing yourself into the conclusion that walking is impossible because there’s no way it could ever possibly work. (Hopefully, your brain will ignore this and continue being able to walk despite not knowing how.)
Yet we learned how to do it, somehow — and at an age when we hadn’t yet formed a *concept* of “learning”. We weren’t taught academically with books or lessons, we learned it by observed example and repeated experimentation. Which is probably the only way we ever could.
Yes, this has been something I’ve discussed with Sara Chipps, my coding coach. Imagine you ask a group of 4 year olds how to make a peanut butter and jelly sandwich. You have bread, two jar, a knife, etc. It seems simple at first to say, just spread the peanut butter and jelly on the bread. But what if the teacher the simply rubs the unopened jars on the bread. You need to open the them first. What about spreading. You might do peanut butter on one side and jelly on the other. leaving you a single slice that is impossible to eat without getting messy.
We internalize so many structures and steps, it’s easy to forget what you don’t know until you start from square one, like I am these days with programming.
I have tried to teach data structures to several people and it is not easy. Linked lists aside, just getting them to understand the concept of an “object” and an “array” is difficult enough.
If I tell someone coming from a non-coding background that three lemons sitting on a table could be represented in code as an array of three lemons, the usual response is a glazed face and expressionless stare. To non-coders, three lemons sitting on a table is just that – three lemons on an actual table – and nothing more.
I would make the argument that people who struggle with this often need an application example where you take the scenario and put it directly into the program. Three lemons sitting on the table in your application is different than three lemons sitting on a real-life table. If you then explain that the three lemons sitting on your table in your program are represented by an array, then it makes sense to them.
When I was in school back in the early 2000’s our data structures class started us off with linked lists, but the pre-requisite was a C++ course where pointers were taught and used extensively. I don’t think you can really teach what a linked list is unless you explain the concept of how one list item can refer to another. I wouldn’t really include that in any introduction to data structures. Arrays and objects are probably enough. Then you move to something like List.
Yeah, it does feel like I somehow missed some fundamental concepts I could have used before arriving at this portion of the curriculum.
I lucked out in my own education – I started by creating scripts on my TI-82 graphing calculator in their version of Basic, and at one point I wanted to write my own version of Blackjack, complete with a single-shuffled deck (or multiple decks) – which means that once a card is dealt, it can’t come back until you reshuffle the deck.
I ran into a wall because I was used to storing each thing I wanted in a single-lettered variable which gave me around 26 cards, and nothing else to play the rest of the game with. They had higher order concepts like (I can’t remember now) lists? but I didn’t know anything beyond what I had figured out myself, and the internet wasn’t then what it is now. I had to think up all the potential solutions that might allow me to do what I wanted, and then see if I could figure out how to accomplish that thing with the tools I had. As I recall, I eventually figured out how to simulate a 52 card deck using a binary value in 13 variables. It took minutes to generate an entire deck. I never made it to the actual game.
Once I actually started my comp sci courses and learning about data structures, it was like, oh, that’s how you do that stuff.
Ha, well props to you for finding an unusual solution on your own!
Is this article part of an effort to be more welcoming to beginners? I’m surprised to find an account of the first steps of learning how to program on an SO blog and feel I wasted my time reading it. (It may have some merits on the computer science educators exchange; the discussion seemed to move in that direction.)
Yes, this is part of our effort to make sure all people – from experienced programmers to complete beginners – feel welcome on Stack Overflow. If it’s not interesting to you, feel free to skip future editions 🙂
To be honest, it isn’t welcoming to experienced programmers, but that hasn’t been something Stack Overflow has cared about ever since it started incorporating people who have no experience programming. 😀 THANKS BEN
In terms of the blog, there’s only one for all of Stack Exchange. You’re right that this is more about comp sci education, but that blog doesn’t exist, so it all goes here.
Or perhaps they really are pivoting Stack Overflow to something new. If so, they’re being worryingly opaque about it. But opacity seems to be SO’s modus operandi these days anyway.
TRiG.
I’ve always thought the easiest metaphor to grasp is comparing an array to a Rolodex. It almost needs no further explanation, besides that rather than just cards of contact information it’s a Rolodex that can hold anything.
Comments’ form keeps popping in while I scroll down reading the comments section. It’s like the 8th time now and I feel like breaking something. Please fix it. I’m using ~latest Chrome on Android.
I noticed the same thing. I found that as I was scrolling I was touching the reply section of the card. Notice that the reply section/button cover the entire width of the card anchored at the bottom.
Data structures are an important concept because they frame how you think about solving problems.
Initially, you learn that you can save information in the form of variables. You learn that you can assign a value of a given type to a variable you name, and then you can reference that value by calling upon the name you assigned the value to. You learn that you can update the value by reassigning the named variable to a new value.
But then you hit a wall. You want many values. Too many to name in a reasonable amount of time. You might extend the idea of saving a single value at a time, to saving a list of values, all of the same type. This is your first data structure, and it is usually called an array. You determine how this structure should function as to be more useful to you than assigning each value individually. You should be able to access a given value by its position in the array, or its index. You should be able to add elements and remove elements. E.t.c e.t.c.
You may find that you can come up with different ways to create a list of values. You may want a list that contains no repeats. An example would be to model the idea of a mathematical set, where there are only unique values. You may decide that the order that the elements were added is the same as the order the elements can be accessed, or you may decide that the first item you access from the list is the last item that was added to the list. For example, in Microsoft Word, when you undo some typing you did, it doesn’t undo the first thing you typed, it undoes the most recent thing you typed. So the data structure that was implemented to store the typing actions you take in a Microsoft word session should give the most recently added item when you ask for the next item, instead of the first item you added. We are still dealing with a list of values, but their type and the way that they are accessed define different data structures, and when you think about solving a problem, like the problem of allowing a user to undo some actions they took in your application, you naturally will refer to your choice of data structures. Thus problem-solving in computer programming often amounts to choosing the right data structures to represent your problem.
Now let’s talk about the issue of dimensionality. Simply put, the number of dimensions a data structure has, is the number of indices required to access an element in that data structure. All of the data structures mentioned so far are accessed by a single index, and we can imagine the elements of these data structures standing in a line. But what if you wanted to model the positions of a chessboard? You could store each element in the chessboard grid (8 by 8, so 64 elements) in a linear list, but how would you traverse this list? Where are the top left of the board and the bottom right of the board on this list? It would be more intuitive to have a data structure that actually models the situation. In this case, we want a data structure where you access the elements by giving a row number and a column number. Since we are accessing elements using two values, we are using a 2-dimensional array. Of course, most data structures will have a 2dimension, 3dimensional, and so on the variant. This is what is meant by the dimension of a data structure, no more, and no less.
You may go on to continue your study of computer programming and so encounter problems that do not easily conform to a grid of values or a list of values. Since your toolbox of data structures defines your toolbox for problem-solving, you will need to introduce new data structures to solve new problems. These problems could include representing towns as a data structure. You could say that each town is a node, and the roads between the towns are the edges, and together you have a complex structure with several nodes connected by edges. You should not be able to traverse this data structure without using the edges, so it models the situation well. You would call this type of data structure a graph.
I could go on, but I hope this gave you some insight into the importance of data structures, their connection to problem-solving in the computer program, and the reason there are so many different types of data structures that matter.
Thanks for the in-depth response 🙂
This is where it helps to have started at the bottom rather than with high level stuff.
An array is just an abstract representation of the way data is stored in the computer. Every byte has an address. Once you have that, arrays and linked lists and related things are just blindingly obvious.
High level languages are great for getting things done – if you understand the things you are doing already.
They aren’t so great at teaching you how things work at a low level where you can see the interconnections between similar things.
Assembler is difficult to work in, but you see the “worm’s eye view” of how it all fits together. Once you see the basis, the higher level stuff is a lot clearer.
It just occurred to me to wonder if people who find arrays confusing are also confused by the house numbers in street addresses.
That’s all it really is. An array is a street with numbered houses.
A stack is a collection of data elements stored in a linear row and can only be accessed at one location, that is, in the top stack position. . example in daily life is a pile of dishes in a restaurant that piles added at the very top and if you take it from the top too