DSOOP Class 01

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

DATA STRUCTURES AND OBJECT

ORIENTED PROGRAMMING
CS234
2
DATA STRUCTURES
 Date item refers to an single unit of values
 Meaningful or processed data

 The study of data structures includes


i) Logical or mathematical description of data
ii) Implementation of the structures on a computer
iii) Quantitative analysis w.r.t amount of memory and
time required for processing the data structures
time complexity
Space complexity

4
Algorithm is a finite set of instructions used to
accomplish a particular task
Characteristics of good algo:
 Input: Zero or more quantities
 Output: At least one quantity is produced
 Definiteness: Each instruction must be clear and
unambiguous eg. a= x /y or z
 Finiteness: All algorithm should terminate after
finite no. of steps
 Effectiveness: Must be feasible such that it is
executed using a machine or paper& pencil
 Eg.z= x/0

5
WHAT IS DATA STRUCTURE?
 Data structure is a representation of data and
the operations allowed on that data.

 A data structure is a way to store and organize data in


order to facilitate the access and modifications.

 Data Structure are the method of representing of logical


relationships between individual data elements related to
the solution of a given problem.

6
7
BASIC DATA STRUCTURE

Basic Data Structures

Linear Data Structures Non-Linear Data Structures

Arrays Linked Lists Stacks Queues Trees Graphs Hash Tables

8
PRIMITIVE DATA STRUCTURE
 There are basic structures and directly
operated upon by the machine instructions.
 Data structures that are directly operated upon
the machine-level instructions are known as
primitive data structures.
 Integer, Floating-point number, Character
constants, string constants, pointers etc, fall
in this category.
 The most commonly used operation on data
structure are broadly categorized into
following types:
◦ Create
◦ Selection
◦ Updating
◦ Destroy or Delete
9
NON-PRIMITIVE DATA STRUCTURE
 There are more sophisticated data
structures.

The Data structures that are derived from the


primitive data structures are called Non-primitive
data structure.

 The non-primitive data structures


emphasize on structuring of a group of
homogeneous (same type) or heterogeneous
(different type) data items.

10
 Linear Data structures:
Linear Data structures are kind of data structure that
has homogeneous elements.

 The data structure in which elements are in a


sequence and form a linear
series.
 Linear data structures are very easy to implement,
since the memory of the
computer is also organized in a linear fashion.
◦ Some commonly used linear data structures are
Stack, Queue and Linked
Lists.

11
NON-LINEAR DATA STRUCTURES:

 A Non-Linear Data structures is a data structure in


which data item is connected to several other data
items.

 Non-Linear data structure may exhibit either a


hierarchical relationship or
parent child relationship.
 The data elements are not arranged in a sequential
structure.

 The different non-linear data structures are trees


and graphs

12
 The most commonly used operation on data
structure are broadly categorized into
following types:

◦ Traversal
◦ Insertion
◦ Selection
◦ Searching
◦ Sorting
◦ Merging
◦ Destroy or Delete

13
DIFFERENCE

 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 or
a linked-list, binary search tree, AVL Tree,
graphs

14
array

Linked list

300
2000 500
1000

15
16
17
SELECTION OF DATA STRUCTURE

 The choice of particular data model depends on


two consideration:
 It must be rich enough in structure to represent the
relationship between data elements
 The structure should be simple enough that one can
effectively process the data when necessary

18
TYPES OF DATA STRUCTURE
 Linear: In Linear data structure, values are arrange in
linear fashion.
 Array: Fixed-size
 Linked-list: Variable-size
 Stack: Add to top and remove from top
 Queue: Add to back and remove from front
 Priority queue: Add anywhere, remove the highest
priority

19
TYPES OF DATA STRUCTURE
 Non-Linear: The data values in this structure are not
arranged in order.
 Tree: Data is organized in branches.
 Graph: A more general branching structure, with
less strict connection conditions than for a tree
 Hash tables: Unordered lists which use a ‘hash
function’ to insert and search

20
TYPE OF DATA STRUCTURES

 Homogenous: In this type of data structures,


values of the same types of data are stored.
 Array

 Non-Homogenous: In this type of data structures,


data values of different types are grouped and
stored.
 Structures
 Classes

21
ABSTRACT DATA TYPE AND DATA STRUCTURE
 Definition:-
 Abstract Data Types (ADTs) stores data and allow various
operations on the data to access and change it.
 A mathematical model, together with various operations defined
on the model
 An ADT is a collection of data and associated operations for
manipulating that data

 Data Structures
 Physical implementation of an ADT
 data structures used in implementations are provided in a
language (primitive or built-in) or are built from the language
constructs (user-defined)
 Each operation associated with the ADT is implemented by one or
more subroutines in the implementation

22
THE CORE OPERATIONS OF ADT

 Every Collection ADT should provide a way


to:
 add an item
 remove an item
 find, retrieve, or access an item

 Many, many more possibilities


 isthe collection empty
 make the collection empty
 give me a sub set of the collection

23
 No single data structure works well for all
purposes, and so it is important to know the
strengths and limitations of several of them

24
SELECTING A DATA STRUCTURE

Analyze the problem to determine the resource


.constraints

a solution must meet

Determine the basic operations that must be
Quantify the resource constraintssupported.
.for

each operation

Select the data structure that best meets these


.requirements

zaid shabbir

You might also like