Data Structure

In this topic, you will learn about, Data Structure.

What is Data Structure?

Data: Data refers to a value or set of values. These values represent some observations from an experiment, some figures collected during some surveys such as census, exit polls, etc, or marks obtained by students in examinations.

Information: Information is a processed data. Data is just a collection of values(raw data) from which no conclusion can be drawn. Data is not useful for decision making but the information is useful for decision making.

Data type: A data type is a collection of values and a set of operations that act on those values so the two aspects are important when we define data type:-

  1. Set of values.
  2. A set of operations.

We may consider a basic data type- integer, on which mathematical, as well as logical operations, are allowed. On integer data type addition, subtraction, multiplication, division, and remainder division is possible. But on float data type remainder division is not possible.

Primitive data type: Primitive data type is a data type that is predefined in a language. The primitive data type is also known as the built-in data type. C language has three built-in data types known as an integer, real, and character.

Abstract data type: An abstract data type (ADT) is a mathematical model for data types where a data type is defined by its behavior from the point of view of a user of the data, specifically in terms of possible values, possible operations on data of this type, and the behavior of these operations. Formally, an ADT may be defined as a “class of objects whose logical behavior is defined by a set of values and a set of operations”

Data structure:

An organized collection of data is called a data structure. It involves the set of operations possible on that particular data structure. So it can be said that:-

Data Structure = Organised data + Set of allowed operations

In other words, Data Structure is a logical model of a particular organization of data. Data structures are used in almost every program or software system. Some common examples of data structures are arrays, linked lists, queues, stacks, trees, and graphs. Data structures are widely applied in the following areas:

  • Compiler design
  • Operating system design
  • Statistical analysis package
  • DBMS
  • Numerical analysis
  • Simulation
  • Artificial intelligence
  • Graphics

Types of data structure:

Data Structure can be categorized on the basis of:

  1. Physical representation: As far as a physical representation of a data structure is concerned it may be categorised into two types:
    1. Linear data structure: Elements of a linear data structure forms a sequence. Ex- Arrays, linked list, stack, queue, etc.
    2. Non-linear data structure: The structure whose elements do not form a sequence is called a nonlinear data structure. Tree, graph are examples of non-linear data structures.
  2. Types of elements: As far as types of elements of a data structure are concerned it can be categorised into two types:
    1. Homogeneous data structure: It is a structure in which elements/data are of the same type. An array is a homogeneous data structure.
    2. Non-homogeneous data structure:- In a non-homogeneous data structure elements are not of the same type. Records are a common example of a non-homogeneous data structure.
  3. Memory allocation: As far as memory allocation of a data structure is concerned it can be classified into two categories:
    1. Static data structure: It can’t expand or shrink during the execution of the program. Its associated memory location is fixed at compile time.
    2. Dynamic data structure: These are ones that can expand or shrink as required during the execution of the program. The associated memory location of a dynamic data structure can change if it is reallocated. Ex- Linked List.

Common operations on data structure:

  1. Creation: Creation means initializing a data structure and inserting elements /nodes at the beginning and provide it to the user for other operations.
  2. Traversal: Accessing each element/node exactly once in order to process it is called traversal. This operation is also known as visiting the nodes/elements.
  3. Searching: Finding the location of a given element in a data structure is called searching.
  4. Insertion: Adding a new element/node to the data structure is called insertion.
  5. Deletion: Removing an element/node from a data structure is called a deletion.
  6. Sorting: Arranging elements in some logical order is called sorting. This logical order may be ascending or descending order in the case of the numeric data type. In the case of the alphabet, it may be in dictionary order.
  7. Merging/Concatenation: Combining elements of two similar data structures is called merging or concatenation.

Also Read: Top 10 best books to learn C Programming

Comment below if you have queries related to the above topic, Data Structure.