What’s a Data Structure?

Print anything with Printful



Data structures organize information in a computer’s memory, with different types being more efficient for different purposes. Arrays assign sequential memory addresses, linked lists allow for dynamic growth, trees sort nodes hierarchically, and hash tables determine memory addresses using an equation. All aim to reduce the number of instructions needed to access data.

A data structure is a computer science concept that refers to a particular method of gathering and organizing information. All data structures use information about where a given piece of data is located in a computer’s memory to access that data and relate it to other pieces of data.
Data structures establish one of many different types of relationships between individual pieces of information. Different data structure types are more efficient for different purposes, and the coding difficulty varies widely between data structure types.

Arrays are among the simplest data structures, but they are still very powerful tools for organizing information. In an array, elements are assigned sequential memory addresses, allowing the memory address of any element in the array to be determined very quickly using simple mathematical calculations, a key advantage. Arrays can be thought of as existing in any number of dimensions. A one-dimensional array could be conceptualized as a list, a two-dimensional array as a table, and a three-dimensional array as a cube of individual cells. Arrays of more than three dimensions can also exist.

Linked lists are another simple but very important type of data structure. In a linked list, each node consists of a variable containing both actual data and information that identifies the next item in the list. A linked list can therefore be traversed as long as the address of the first node is known. This type of data structure is versatile because it lends itself to dynamic growth, as new nodes can be easily assigned at any time. Adding a variable containing the position of the previous node in the list allows you to traverse this type of data structure in both directions.

Trees sort nodes hierarchically, starting with a root node and working down through multiple levels of nodes until all the necessary data has been entered into the tree. Typically, items within a tree are sorted in some way. Trees can implement sorting and can potentially provide much faster access to stored data because of this, as each branch takes away whole swathes of information from consideration that should be sorted in a linked list.

Hash tables are used to determine a memory address where a given piece of data should be stored by using an equation to transform that data into a memory address. They can be a very efficient structure for storing and retrieving data from an array.

All data structures are designed to reduce the number of instructions a computer has to execute to locate a particular piece of information. Different data types lend themselves to different types of data structures, but most modern programming languages ​​offer support for a wide variety of data structures or provide the tools for programmers to code their own data structures.




Protect your devices with Threat Protection by NordVPN


Skip to content