You are on page 1of 15

Lecture# 02

Data Structure & Algorithms

By
Engr. Mohammad Nawaz
Lecturer at CSE&S Deparment
Balochistan UET khuzdar
Outline:
• Data Structure Operations
• Examples and Real Life Applications
• Data Type
– Built-in Data Type
– Derived Data Type

Data Structure & Algorithms 2


CLO-1(PLO-1)
LECTURE OBJECTIVES:
At the End of this Lecture You will be able to
• Define Data Structure Operations
• Describe Data type
• Differentiate between built-in data type and
derived data type.

Data Structure & Algorithms 3


CLO-1(PLO-1)
Data Structure Operations
• The Data appearing in our data structures are processed by
means of certain operations.

• In fact, the particular data structure that one chooses for a


given situation depends largely in the frequency with which
specific operations are performed.

The following four basic operations


1. Traversing
2. Searching
3. Inserting
4. Deleting
Data Structure & Algorithms 4
CLO-1(PLO-1)
Traversal
• Processing Each Element of the data Structure
or visiting each element.
• Example:

0 1 2 3

A 10 20 30 40

• Find the addition of all elements of array A.


=100 Ans

Data Structure & Algorithms 5


CLO-1(PLO-1)
INSERTION
Adding a new Element into an Array or list.
Example:

0 1 2 3

A 10 20 30 40

• Now insert 55 at index 2.

0 1 2 3 4
10 20 55 30 40

Data Structure & Algorithms 6


CLO-1(PLO-1)
DELETION
• Removing or Erasing an Element from a data
structure.
Example: 0 1 2 3

A 10 20 30 40

• Now DELETE element from index 2.

0 1 2
10 20 40

Data Structure & Algorithms 7


CLO-1(PLO-1)
Searching
• Finding the location of the desired node with a
given key value.
Example: 0 1 2 3

A 10 20 30 40

• Value of A[2]?
• 30Ans

Data Structure & Algorithms 8


CLO-1(PLO-1)
Real Life Application
• A company contains employee file in which each
record contain the data for a given employee.
[Name, Address, age, gender]
• Suppose a new person joins the company. then one
would insert his record into file.
• Suppose an employee dies. Then one would delete
his record from file.
• Suppose company wants to announce bonus for
employess greater than 40 years old, then one
would traverse the whole record.
Data Structure & Algorithms 9
CLO-1(PLO-1)
Any Question?

Data Structure & Algorithms 10


CLO-1(PLO-1)
Data Type
• Storage format of any variable.
• Data type is way to classify various types of
data such as integer, string etc.
• Two type of data type-

1. Built-in data type


2. Derived Data type

Data Structure & Algorithms 11


CLO-1(PLO-1)
Built-in data type
• Those data types which are built-in supported
by any language are known as built-in data
type.
• Most of the languages provides following
built-in data types
– Integers
– Boolean(true, false)
– Floating(Decimal numbers)
– Character

Data Structure & Algorithms 12


CLO-1(PLO-1)
Derived data type
• Those data types which are built by the
combination of primary or built-in data type
are known as derived data types.
• These data types are implementation
dependent
• Example:
– List
– Array
– Stack
– Queue
Data Structure & Algorithms 13
CLO-1(PLO-1)
Any Question?

Data Structure & Algorithms 14


CLO-1(PLO-1)
Thanks

Data Structure & Algorithms


15
CLO-1(PLO-1)

You might also like