Introduction – What is Data Structure?
Data Structure is a way to organize the data in the main memory. Here data may be from the collection of elements or the possible operation which are required to perform any operation. The data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.
In the most general sense, a data structure is any data representation and its associated operations. Even an integer or floating-point number stored on the computer can be viewed as a simple data structure. More commonly, people use the term “data structure” to mean an organization or structuring for a collection of data items. A sorted list of integers stored in an array is an example of such a structuring
A data structure is a special format for organizing and storing data. General data structure types include arrays, files, linked lists, stacks, queues, trees, graphs, and so on.
Basic Classification of Data Structure
Depending on the organization of the elements, data structures are classified into two types:
1) Linear data structures: Elements are accessed in sequential order but it is not compulsory to store all elements sequentially. Examples: Linked Lists, Stacks, and Queues.
2) Non–linear data structures: Elements of this data structure are stored/accessed in a non-linear order. Examples: Trees and graphs.
Why it is difficult to understand Data Structure
It has been found that students/professionals will struggle with understanding, choosing, and implementing data structures because of one or more of the following factors:
- They haven’t yet learned the fundamentals of programming and problem-solving.
- They attempt to learn data structures without also learning the algorithms that operate on them. Algorithms and data structures are closely tied together, and they should be studied and learned together.
- They don’t yet understand the concepts of dynamic memory management.
- They don’t yet understand how pointers (or other linking mechanisms) work.
- They might have had experience with canned data structures (e.g., C++ STL), but don’t yet understand how they are implemented or what the differences are between them.
- They read and watch, but don’t actually implement them themselves. Implementing them yourself is really the most effective way to learn.
To truly understand the data structures and algorithms, I recommend the following:
- Learn C thoroughly, including a solid foundation in dynamic memory management and pointers.
- Then and only then, work through Mastering Algorithms with C, walking through the C source code implementations, and implementing several of the key data structures and algorithms yourself.