Data Structure

A data structure is a particular way of organizing data for particular types of operation. It is like a blueprint that shows how data is connected and organized.

To understand this better, we'll create a data structure of our own.

Suppose we are a part of a club that focuses on competitive programming. We want to store the names of our members in our computer. The best programmer in our team creates a data structure keeping in mind some of the requirements. Since we have a low turnover rate, we do not have to update the data structure often and as a result, we can afford to store it in a contiguous block of memory. We need to be able to access the data structure quickly and efficiently. So, he assigns each entry a unique index number. Through this number we can access the name of the member. To remove any confusion, we can only store the names of the members in the data structure. This means only strings are allowed.

The data structure that satisfies all the preceding requirements already exists. It is called an array. We'll learn more about arrays in the next sections.

In a computer, 'data' is ultimately represented as a sequence of zeros and ones (bits), but this representation is too low level for the human beings operating that computer to discern. Hence, we have data structures that are closer to the way humans can understand and visualize the structure of this data. This is because it is humans who have to develop and maintain the software systems - computers merely run them.

Operations on Data Structures

Data structures need to have certain operations that help us to modify or access the content. These operations include:

  1. Traversal: This involves accessing each element of an array in a sequential order, either from start to end or vice versa.
  2. Insertion: This is the process of adding a new element to an array. The new element can be inserted at the beginning, end, or any other position within the array, depending on the application. Existing elements may shift to accommodate the new element.
  3. Deletion: This operation involves removing an existing element from an array. Similar to insertion, an element can be deleted from any position within the array, and existing elements may shift to fill the gap.
  4. Search: This process involves finding a specific element within an array by comparing the target element with each element in the array until a match is found.
  5. Sorting: This operation involves arranging elements in a specific order.