DSA: Introduction

Definitions

1. Data Structure: A mathematical or logical representation of data in memory is called data structure.
2. Algorithm: A step by step solution to any problem is called algorithm.


Introduction to Data Structure:

As we have gone through the definition of data structure "It is mathematical or logical representation of data in memory". 

Classification:

There are two type of Data Structures according to memory representation

1. Contiguous Data Structures:

Those data structures for which contiguous memory is allocated for its data. 
For Eg: Array, String, Stack(Array Implementation), Queue(Array Implementation), Tree( Array Implementation)

2. Non Contiguous Data Structures

Those data structures for which memory allocation is non contiguous for its data.
For Eg: Linked List, Queue, Stack, Tree, Graph(Linked List Implementation of all these), Hash Table etc.

Operations That can be performed on Data structures

Following operations can be performed on the data structures:

1. Insertion

A new element can be inserted in the data structure at specific position depending on data structure. For Example:
 a) In array we can insert element at starting index, last index, mid of array etc.
 b) In stack we can insert element at the top of stack.
 c) In normal Queue we can insert element at the rear of queue.
 d) In Linked List we can insert element at start, at end or at mid of List.

2. Deletion

An existing element can be removed/deleted from the data structures from specific position depending on data structure. For Example
 a) From array we can delete element from starting index, last index, mid of array etc.
 b) From stack we can delete element from the top of stack.
 c) From Queue we can delete element from the rear of queue.
 d)  From Linked list we can delete element from start, from end or from mid of List.

3. Traversing

Processing of each element of data structure is called traversing of data structure. All the elements of the data structure can be traversed in specific manner.

4. Mergeing

Two same data structures can be merged and resulted into a single data structure.

5. Sorting

Elements of the data structures can be sorted in specific manner. This is not applicable for all the data structures.




No comments:

Post a Comment