Skip to content
Home » What is a Data Structure in programming?

What is a Data Structure in programming?

What is a data structure? To answer this question, the best will be to use some trivial analogy. Tissues in packages are stacked on top of each other, books in libraries side by side. In addition (books), they are usually arranged according to some criteria, type, author, title, type of literature. Which makes it easier for us to reach the book we are interested in even without knowing the rest of the collection (other books). If we arranged books like tissues, then getting to a particular book could be problematic.

Searching and storing data in data structures

Not only searching but also storing books in this way could be not easy. Imagine such huge stacks of books, one on the top of each other in libraries. Such stacks would sooner or later start collapsing and making a mess. To get one from the middle or bottom of the pile, we’d have to fiddle with those above them. On the other hand, arranging tissues according to some excessive criteria, such as the precise weight of the tissue, would take a lot of time and would simply be pointless. We can also conclude that both of these ways of arranging / organizing objects have their own characteristics, advantages and disadvantages, and thus different applications.

Two types of basic data structures

Data structures can be divided into two categories, linear and non-linear. Linear data structures are those in which the elements are arranged sequentially. Like a stack, queue, or list. Each of these structures in details will be described in the following articles. For now, it is enough for you to know that their parameters and behavior reflect their names. The queue in programming mirrors the queue we know from shops, a stack, a stack of books on a desk, a list also has a similar shape to the ones we know for example from todo lists written by us onpaper.


Another type are non-linear data structures. Here, too, inspiration was drawn from real-world objects, graphs are an idea taken strictly from mathematics, and a tree is a data structure, which, as the name suggests, reflects trees.

programming meme about showing the tree (data structure)
source: https://i.redd.it/dqid22eqeq821.jpg

Data structures and algorithms in tandem

A domain strictly related to data structures is algorithms. Data structure points out how the data are organized/stored in computer memory. Data structures are important not only because they allow you to organize data, but also because they allow you to identify them in a structure, interrelate and involve specific algorithms.

Books stacked on stacks in the library is an example of an improperly selected data structure. If you want to find something in such a library, it will involve moving everything from place to place, wandering around and making a huge number of misses – this is an example of a not optimal algorithm. In programming it is exactly the same.

Inappropriate data structure and algorithm may not only be ineffective and slow. BTW about how we measure effectiveness / quality of the algorithm you can read more here. Getting back to the matter itself – they can also go beyond the capabilities of the machine on which the algorithm will be launched. Our program will fall out like a stack of books in our exsample library.

unorganized library with a mess of books in center
source: https://live.staticflickr.com/2861/11698524166_c0bf064195_b.jpg

Appropriate use of data structures and algorithms determines the efficiency and quality of the program. The way we arrange information in memory will determine how quickly and by what methods it will be possible to access it. Ultimately, it will affect, for example, how quickly the user will see what he expects on his screen.

Choosing the right structures and algorithms is a skill. A skill that comes with practice, time and experience, but largely comes from knowledge. Therefore, when discussing data structures and algorithms, I will try to cite as many real life examples as possible. So that you know where you can expect these types of concepts and when to use them.

Summary of what is a data structure in programming

Data structure is how we store data in a computer. The data structure we choose has an impact on how we will later access this data. Data structures go hand in hand with algorithms. The selection of an appropriate data structure determines how quickly we will be able to extract the data we are looking for later. Basic data structures are based on assumptions known to us from the real world, such as a queue, stack or tree.

PS of what is a data structure in programming

If you want to know what an algorithm is, you can read about it here.
If you are interested in how the performance of the algorithm is determined here.

Website | + posts

Senior Software Engineer with over 7 years of experience and entrepreneurial background. Most often, apart from delivering good quality code on time, responsible for introducing good practices, teaching programmers and building team bonds andestablishing communication on the line of development-management. Privately Kākāpō and Wombat enthusiast, traveler and retired acrobat.