# Data Structures - Introduction

Data Structures and Algorithms

Welcome to Data Structures tutorial series. We are going to learn about different data structures like array, linked list, queue, stack, tree, graph, etc.

## What is Data Structure?

In Computer Science, Data Structure is a way of Processing, Retrieving, Organising and Storing of data.

Data Structure is about a collection of data, the relationship that exists between the data values and the operations that can be performed on the data.

## What is an Abstract Data Type (ADT)?

An Abstract Data Type is a data type that defines what operations can be performed on the data and what results will be produced by those operations without specifying how data will be stored or manipulated. It allows us to focus on the behaviour of the data rather than on the implementation.

For example, a Stack is an ADT and we can perform operations like adding items and removing items in a Last-In-First-Out (LIFO) order. Similarly, a Queue is another ADT and it allows for the addition and removal of items in a First-In-First-Out (FIFO) order.

So, ADT tells us about what type of operations can be performed while data structure tells us how to perform the operations.

## Types of Data Structures

There are two types of Data structures - Primitive and Non-Primitive.

The Primitive data structure consists of numbers and charactes and involves data types that are provided by the programming languages like `integer`, `character`, `float`, `boolean`.

The Non-Primitive data structures are derieved from the Primitive data structures. They consists of a collection of data that can be homogeneous (same data type) or heterogeneous (different data type). Non-Primitive data structures are of two types - Linear and Non-Linear.

### Linear Data Structures

Linear data structures store data in a sequential order. Examples are Arrays, Stacks, Queues, Linked List etc.

### Non-Linear Data Structures

Non-Linear data structures store data in a non-sequential order. Examples are Tree and Graph.

Data structures can also be static and dynamic in terms of size. Static data structures have a fixed size and their size is set at compile time. Whereas, Dynamic data structures have a dynamic size and their size is allocated at run time.

``````Data Structure
|
|
+---- Primitive
|     |
|     +-- Character, Boolean, Integer, Float
|
|
+---- Non-Primitive
|
+-- Linear
|   |
|   +-- Array, Queue, Stack, Linked List
|
|
+-- Non-Linear
|
+-- Tree, Graph``````

## Common Operations

Following are the common operations that we perform on a data structure.

• Insertion - we insert a new value in the data structure.
• Updation - we update (i.e., replace) a value in the data structure.
• Deletion - we remove a value from the data structure.
• Sorting - we sort the values in the data structure in a particular order like ascending order or descending order.
• Searching - we search for a value in the data structure.