0% found this document useful (0 votes)
18 views20 pages

CSE225 Lecture01 Introduction To DS

Uploaded by

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

CSE225 Lecture01 Introduction To DS

Uploaded by

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

CSE225: Data Structure and

Algorithms

Introduction to Data Structure


and Algorithms

1
Data
 Data can be defined as a representation of facts and concepts by
values.
 Data is collection of raw facts.

Data is represented with the help of characters such as alphabets (A-


Z, a-z), digits (0-9) or special characters (+,-,/,*,<,>,= etc.)

2
Introduction to Data
Structures
 One of the most fundamental courses in Computer
Science

 Good knowledge of Data Structures is a must to


design and develop efficient software system

 We deal with data all the time and how we store,


organize and group our data together matters
Algorithm

 An Algorithm is a well defined list of steps to


solve a problem.
 Data structure is the logical or mathematical
relationship of individual elements of data.

 Algorithm + Data Structure= Program

4
So, what is a data
structure?
 A data structure is a way to store and organize data in a
computer so that it can be used efficiently.

What are data structures?


There are many definitions available.
• A data structure is an aggregation of data components that together
constitute a meaningful whole.
• A data structure is a way of arranging data in a computer's memory or
other disk storage.
• A data structure is a collection of data, organized so that items can be
stored and retrieved by some fixed techniques.
Why Data Structures?
 Ultimate goal -- to write efficient programs. In order to
do that, one needs to organize the data in such a way
that it can be accessed and manipulated efficiently.

 They are essential ingredients in creating fast and


powerful algorithms.

 They make code cleaner and easier to understand.

6
How do we study data
structures?
 When we study data structures, we
study them in two ways:

Logical models (we look at an abstract
view of them or ADT)

Implementations of the ADT
Classification of Data Structure
 Two broad categories of data structure are :
 Primitive Data Structure

 Non-Primitive Data Structure

8
Primitive Data Structure

 They are basic structures and directly operated


upon by the machine instructions.

 Integer, Floating-point number, Character


constants, string constants, pointers etc,

9
Non-Primitive Data Structure

 These are derived from the primitive data


structures.
 Example: Array, Lists, Stack, Queue, Tree,
Graph

10
Difference between
them

A primitive data structure is generally a


basic structure that is usually built into the
language, such as an integer, a float.

 A non-primitive data structure is built out of


primitive data structures linked together in
meaningful ways, such as a linked-list, binary
search tree, AVL Tree, graph etc.

11
Classification of Data Structure
Data structure

Primitive DS Non-Primitive DS

Integer Float Character Pointer

12
Classification of Data Structure
Non-Primitive DS

Linear List Non-Linear List

Array Queue Graph Trees

Linked List Stack


13
Types of Data

Characterstic Description

In Linear data structures, the data items are arranged in a linear


Linear
sequence. Example: Array

In Non-Linear data structures, the data items are not in sequence.


Non-Linear
Example: Tree, Graph

In homogeneous data structures, all the elements are of same type.


Homogeneous
Example: Array

Non- In Non-Homogeneous data structure, the elements may or may not be of


Homogeneous the same type. Example: Structures
Static data structures are those whose sizes and structures associated
Static
memory locations are fixed, at compile time. Example: Array

Dynamic structures are those which expand or shrink depending upon the
Dynamic program need and its execution. Also, their associated memory locations
changes. Example: Linked List created using pointers 14
OPERATIONS

 Data appearing in Data Structure are


processed by means of certain operation

 Particular DS one chooses for a given


situation depends largely on the frequency
with which specific operations are performed

15
MAJOR OPERATION
 Traversing: Accessing each record exactly once so that certain
items in the record may be processed [ Also known as Visiting
the record]
 Searching: Finding the location of the record with a given key
value, or finding the locations of all record which satisfy
one or more conditions
 Inserting : Adding a new record to the structure
 Deleting : Removing a record from the structure
 Sorting: Arranging a list in some logical order.
 Merging: Combing two list in a single list.

16
Abstract Data Type

 Abstract Data Types (ADT's) are a model used to understand the


design of a data structure. Abstract mean an implementation-
independent view of the data structure.

 Every programming language has a different implementation


strategy for example; a C data structure is implemented using
structures while a C++ data structure is implemented using objects
and classes.

 ADTs specify the type of data stored and the operations that
support the data
17
E.g. Operations of
Stack ADT
• Stack −
• isFull(), This is used to check whether stack is full or not
• isEmpty(), This is used to check whether stack is empty or
not
• push(x), This is used to push x into the stack
• pop(), This is used to delete one element from top of the
stack
• peek(), This is used to get the top most element of the stack
• size(), this function is used to get number of elements
present into the stack

18
ADT and Data
Structures
 ADT is a high-level description: the logical picture of the data
and the operations that manipulate them while data structure is
concrete that is it is a collection of data elements and the
operations that store and retrieve individual elements.

 An abstract data type is implementation independent, whereas a


data structure is implementation dependent. A data structure is
how we implement the data in an abstract data type whose
values have component parts. The operations on an abstract data
type are translated into algorithms on the data structure .

19
Abstract Data Type

 There can be different ways to


implement an ADT, for example,
the List ADT can be implemented
using arrays, or singly linked list or
doubly linked list. Similarly, stack
ADT and Queue ADT can be
implemented using arrays or linked
lists.
20

You might also like