C Language Complete Notes
DSA Complete Notes
Software Engineering
Software Architecture
Operating System
Big Data
Data Mining and Warehousing
TOC
Ada
CPP
DBMS

Topics

  • 1. Data Structure
  • 2. Objectives of Data Structure
  • 3. types of data structures
  • 4. Operations on Data Structure
  • 5. Array
  • 6. Types of Arrays
  • 7. Memory Representation of Array
  • 8. Address Calculation in One-Dimensional Array
  • 9. What is a Two-Dimensional Array? (With Simple Explanation & Example)
  • 10. Representation of 2D Array in Memory (Row Major & Column Major Order)
  • 11. Address Calculation in 2D Array (Row Major Order)
  • 12. Basic Operations in Array (Traversal, Insertion, Deletion)

Topic Ends from here

1. Data Structure

Data Structure = Data + Structure

Data Structure means organizing data in such a way that it becomes easy to store, access, and process.

If data is properly structured, it becomes easier to search, update, and manage.

Example: 

Problem (Messy Wardrobe)

  • Clothes are scattered everywhere.

  • It becomes difficult to find things.

  • It takes more time.

Solution (Organized Wardrobe)

  • Clothes are arranged properly.

  • Shirts in one place, pants in another place.

  • Things become easy to find.

Similarly, in computers we organize data in memory so that it can be processed easily and efficiently. This organized way is called Data Structure.

Definition:
A mathematical or logical model of a particular organization of data in memory is called a Data Structure.

Data Structure provides the knowledge of how data should be organized in memory so that programs become efficient and less complex.

2. Objectives of Data Structure

There are mainly two objectives of Data Structure:

1. To Identify Mathematical Model

To identify and create a useful mathematical model and operations for solving a problem.

2. Representation and Implementation

To determine the representation of the model and implement the operations to solve the problem.

Data:

Anything that gives information is called Data.

Examples

  • 2G, 3G, 4G Internet data pack

  • Gmail messages

  • Files

  • Audio

  • Video

  • Student name

  • Student roll number


Structure

The representation or arrangement of data is called Structure.

Examples

  • Array

  • List

  • Graph


Data Structure

Formula:

Data Structure = Data + Structure

Definition:
Data Structure is a way to store and organize data so that it can be used efficiently.

3. types of data structures

1. Primitive Data Structure :-

• The data structure that are directly operated upon by machine level instructions are known as Primitive Data Structure.

Ex :- Integer, Float, Character, Boolean

• They have different representation on different computers.

• Integer takes:
 → 2 Bytes in 16-bit computer
 → 4 Bytes in 32-bit computer

Example:
Integer → 1, 2
Character → A

2. Non-Primitive Data Structure :-

• The data structure that are not directly operated upon by machine level instructions are known as Non-Primitive Data Structure.

Types of Non-Primitive Data Structure

(a) Linear Data Structure :-

Data elements are arranged in a sequential order.

Ex :- Array, Stack, Queue, Linked List

(b) Non-Linear Data Structure :-

Data elements are not arranged in a sequential order.

Ex :- Tree, Graph

Linear Data Structure :-

• The data structure which shows the relationship of adjacency between elements is known as Linear Data Structure.

• In this, each element has a predecessor and a successor.

Example:
Roll No. 1 → Roll No. 2 → Roll No. 3

• Elements are stored in sequential manner.

Ex :- Array, Stack, Queue, Linked List

Non-Linear Data Structure :-

• The data structure which does not show the relationship of adjacency between elements is known as Non-Linear Data Structure.

• In this, each element does not have a single predecessor and successor.

Example:
                      Roll No. 1
                         /      \  
          Roll No. 2     Roll No. 3      

• Elements are stored in non-sequential manner.

Ex :- Tree, Graph
                                                                                                                                         
                                                                                                                                      

4. Operations on Data Structure

• The data which is stored in a data structure is processed by a set of operations.

1) Creation :-

• Creating a new data structure.

2) Insertion :-

• Adding a new data element into the data structure.

3) Deletion :-

• Removing a data element from the data structure.

4) Traversing :-

• Visiting each data element once in the data structure.

5) Sorting :-

• Arranging data in increasing or decreasing order.

6) Searching :-

• Finding the location of a data element in the data structure.

7) Merging :-

• Combining the data of two different sorted files into a single sorted file.

5. Array

Array :-

• An array can be defined as a collection of homogeneous (similar type) elements.

• Array elements are always stored in consecutive memory locations.

• Array can store multiple values which can be referenced by a single name.

Example :-

int A[30];

• Here A is the array name which can hold 30 integers.

Terminology of Array :-

1) Size :-

• The number of elements in an array is called the size / length / dimension of the array.

2) Type :-

• It represents the kind of data stored in array.

Ex :-
Integer array, Character array

3) Base Address :-

• The starting address of memory location where the first element of array is located is called base address.

4) Index / Subscript :-

• All elements in an array can be represented using subscript (index).

Ex :-
A[0], A[1], A[i]

DSA Complete Notes | CSE Notes | CSENOTES