DATA STRUCTURE
Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about rendering data elements in terms of some relationship, for better organization and storage. For example, we have data player’s name “Sachin” and age 40. Here “Sachin” is of String data type and 40 is of integer data type.
We can organize this data as a record like Players record. Now we can collect and store players records in a file or database as a data structure. For example: “Irfan” 31, “Sami” 32, “Bhuvi” 35
In simple language, Data Structures are structures programmed to store ordered data, so that various operations can be performed on it easily.
BASIC TYPES OF DATA STRUCTURE:
Anything that can store data can be called as a data structure, hence Integer, Float, Boolean, Char, varchar etc., all are data structures. They are known as Primitive Data Structures.
Then we also have some complex Data Structures, which are used to store large and connected data. Some example of Abstract Data Structure are:
- Linked list
- Tree
- Graph
- Stack, Queue etc.
All these data structures allow us to perform different operations on data. We select these data structures based on which type of operation is required.
There are numerous types of data structures, generally built upon simpler primitive data types:
- ARRAY DATA STRUCTURE: An array(also called list) is a number of elements in a specific order, typically all of the same type. Elements are accessed using an integer index to specify which element is required (although the elements may be of almost any type). Typical implementations allocate contiguous memory words for the elements of arrays (but this is not always a necessity). Arrays may be fixed-length or resizable.
- RECORD DATA STRUCTURE: A recordis an aggregate data structure. A record is a value that contains other values, typically in fixed number and sequence and typically indexed by names. The elements of records are usually called fields or members.
- GRAPH DATA STRUCTURE: A graphand a tree are linked abstract data structures composed of nodes. Each node contains a value and one or more pointers to other nodes arranged in a hierarchy. Graphs can be used to represent networks, while variants of trees can be used for sorting and searching, having their nodes arranged in some relative order based on their values.
- CLASS DATA STRUCTURE: A classis a data structure that contains data fields, like a record, as well as various methods which operate on the contents of the record. In the context of object-oriented programming, records are known as plain old data structures to distinguish them from classes.
- A tagged union(also called variant, variant record, discriminated union, or disjoint union) contains an additional field indicating its current type, for enhanced type safety.
- A setis an abstract data structure that can store specific values, in no particular order and with no duplicate values.