0% found this document useful (0 votes)
26 views16 pages

Introduction To Data Structures: CS 202 Minor

Introduction to DATA STRUCTURES

Uploaded by

Aditya Chauhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views16 pages

Introduction To Data Structures: CS 202 Minor

Introduction to DATA STRUCTURES

Uploaded by

Aditya Chauhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

INTRODUCTION TO

DATA STRUCTURES

CS 202 Minor

1
Good Programs
There are a number of facets to good programs: they must
 run correctly

 run efficiently

 be easy to read and understand

 be easy to debug and

 be easy to modify.

2
Data Structures - Introduction
• Most fundamental and built-in concept in
computer Science.
• Good knowledge of data structure is a must to
design and develop efficient software
systems.
• A data structure is way to store and organize
data in computer, so that it can be used
efficiently.
3
Data Structures - Introduction
• The choice of data structure can make the
difference between a program running in a
few seconds or requiring many days.
• A data structure requires a certain amount of
space for each data item it stores, a certain
amount of time to perform a single basic
operation, and a certain amount of
programming effort.
4
When we study the DS we will be studying the following things
1.Logical view
2.Operations
3.Cost of operations
4.Implementation
5
Linear Data Structures

Array

Linked list

Queue
Stack

6
Non-Linear Data Structures
A

B C

D E F G

H I

Tree Graph

7
Lists
•A list is a finite, ordered sequence of data items.

•Two standard approach to implement list - Arrays, Linked list

•Arrays – static data structure

•Linked list – dynamic data structure

8
ARRAYS
An array is a finite, ordered and collection of homogeneous data
elements.
int A[100]

Size : Number of elements in an array.

Type : data type

Base : base address

Index : subscript used to refer array elements

Range of Index : Indices change from lower bound LB to and upper


bound UB 9
Arrays

10
1 D - Arrays

Indexing formula
Address 𝑨 𝒊 = 𝐁 + (𝐢 − 𝐋𝐁) × 𝒘
B = Base address
w = Storage Size of one element stored in the array (in byte)
i = Subscript of element whose address is to be found
LB = Lower limit / Lower Bound of subscript, if not specified
assume 0 (zero)
11
Given the base address of an array B[1300…..1900] as 1020 and
size of each element is 2 bytes in the memory. Find the address
of B[1700].

Solution:
The given values are: B = 1020, L B= 1300, W = 2, i = 1700
Address of A [ I ] = B + W * ( i – LB)
= 1020 + 2 * (1700 – 1300)
= 1020 + 2 * 400
= 1020 + 800
= 1820

12
Operations on Arrays
❖Traversing
❖Sorting
❖Searching
❖Insertion
❖Deletion

13
Two dimensional Arrays

Memory Representation

1.Row-major form
2.Column major form

14
15
The address of a location in Row Major System is calculated using the following
formula:
Address of A [ I ][ J ] = B + w * [ N * ( I – Lr ) + ( J – Lc ) ]
Address of A [ I ][ J ] Column Major Wise = B + w * [( I – Lr ) + M * ( J – Lc )]
B = Base address
I = Row subscript of element whose address is to be found
J = Column subscript of element whose address is to be found
W = Storage Size of one element stored in the array (in byte)
Lr = Lower limit of row/start row index of matrix, if not given assume 0 (zero)
Lc = Lower limit of column/start column index of matrix, if not given assume 0 (zero)
M = Number of row of the given matrix
N = Number of column of the given matrix

16

You might also like