What are Data Structures and its examples
In this blog, we are going to learn about data structures and its examples.
- Data Structures are a method of representing of logical relationships between individual data elements related to the solution of a given problem.
- A data structure is a structured set of variables associated with one another in different ways, co-operatively defining the components in the system and capable of being operated upon in the program.
Data structures are the basis of the programming tools. The choice of data structures should provide the following:
- The data structure should satisfactorily represent the relationship between the data elements.
- The data structure should be easy so that the programmer can easily process the data.
- Linear: The values are arranged in a linear fashion. E.g. Arrays, Linked Lists, Stacks, Queues etc.
- Non-Linear: The values are not arranged in an order. E.g. Tree, Graph, Table etc.
- Homogeneous: Here all the values stored are of same type e.g. arrays
- Non- Homogeneous: Here all the values stored are of different type e.g. structures and classes.
- Dynamic: A dynamic data structure is one that can grow or shrink as needed to contain the data you want stored. That is, you can allocate new storage when it’s needed and discard that storage when you’re done with it. E.g. pointers, or references
- Static: They’re essentially fixed-size and often use much space E.g. Array.
Data Structures are processed by using certain operations.
- Traversing: Accessing each record exactly once so that certain items in the record may be processed.
- Searching: Finding the location of the record with a given key value, or finding the location of all the records that satisfy one or more conditions.
- Inserting: Adding a new record to the structure.
- Deleting: Removing a record from the structure.
- Sorting: Arranging the records in some logical order (Alphabetical or numerical order).
- Merging: Combining the records in two different sorted files into a single sorted file.