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

Introduction 1

Uploaded by

2n6dhkjm6p
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)
13 views20 pages

Introduction 1

Uploaded by

2n6dhkjm6p
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/ 20

Data Structure and Algorithm

Instructor: Hafiz Abdul Rehman


Lecture 01: Introduction

1
About Me
• MS (CS)
• COMSAT University Islamabad (Lahore Campus)
• 2020-2022
• Research Officer
• AL-Khwarizmi Institute of Computer Science (KICS) UET
Lahore
• 2019-2023
• Lecturer 2 2
• Computer Science Department, SST
About Me
• Instructor: Hafiz Abdul Rehman
• Email: [email protected]
• Office: Room No 404, STD
• Google Scholar Profile: Hafiz Abdul Rehman
• GitHub Profile: Hafiz Abdul Rehman
• LinkedIn Profile: https://www.linkedin.com/in/ha-rehman/

3 3
About Me : Research Profile

4 4
Course Details
• Course Code: CC2042
• Assessment
• 25% Coursework
• 25% Midterm,
• 30% Final
• 20% Project
• Office Hours: 10:00am – 12:00pm or When Door Open
5 5
Textbooks - DSA

6
Pre Requisites - DSA

Good Programming Skills

Basic Knowledge of OOP

7
Course Outline
• Introduction to DSA
• Operations of Data Structures
• Types of Algorithms
• Arrays
• Dynamic Memory Allocation of Arrays
• Queue and Stack
• Searching and Sorting Algorithms
• Link List (Single, Double, and Circular)
• Operations of Data Structures
• Trees, Graphs 8 8
• Heap and Hashing
Data Structure
• A data structure is a fundamental concept in computer science
and programming that defines how data is organized, stored, and
manipulated in a computer's memory or storage.
• It provides a way to efficiently manage and access data, enabling
various operations and algorithms to be performed on that data.
• Data structures are essential for solving complex problems and
optimizing the use of computer resources.
• A data structure is a collection of basic data types combined
according to the rules of the programming language to create a
new user-defined data types. 9 9
Operations on Data Structures
The data in a data structure is processed using certain operations.

Inserting: Adding new data items into a data structure is called inserting.
Deleting: Removing new data items into a data structure is called
Deleting.
Searching: Finding specific data items in a data structure is called
Searching.
Traversing: Accessing each record or item in a data structure exactly once
for processing is called traversing. It is also called visiting.
Sorting: Arranging data items in a data structure into a specific order is
called sorting. 10 10
Merging: Combining two lists of data items into a single data list is called
merging.
Types of Data Structures

Data Structure

Primitive Data Types Non-Primitive Data Types

Linear Data Non-Linear Data


Integer Float Character Boolean
Structure Structures

Trees Graphs

Arrays Link List Stack Queue

11 11
Primitive and Non-Primitive Data Types
Primitive Data Types
• Fundamental building blocks for representing simple values
• Built into the programming language itself
• Used to represent basic data, such as numbers, characters, and
Boolean values.
• Primitive data types are directly supported by the hardware.
• They have fixed sizes, which means they use a specific amount of
memory.
• E.g. Integer contain 4 bytes and Boolean Contain 1 bit.

12 12
Primitive and Non-Primitive Data Types
Non-Primitive Data Types
• Also known as reference data types
• Not store the actual data directly but instead store references
(memory addresses) to the data.
• Typically created by the programmer and are not fixed in size.
• Common examples of non-primitive data types include:
• Arrays: Ordered collections of elements of the same or different
data types.
• Objects: Instances of user-defined classes that can encapsulate data
and behavior. 13 13

• Strings: A sequence of characters. In some languages, strings are


treated as non-primitive data types.
Linear and Non-Linear Data Structures
These categories describe how data elements are organized, stored, and
accessed within the data structure.
Linear Data structures
• Data elements are organized sequentially one after the other.
• Each element has a unique predecessor and successor, except for the
first and last elements.
• Linear or one-dimensional arrangement of elements.
Non-Linear Data Structure
• Data elements are organized in a hierarchical or non-sequential
manner.
• Elements may have multiple predecessors or successors.
14 14
• More complex and versatile compared to linear data structures.
Contiguous and Non- Contiguous Data Structures
Contiguous Data Structures
• data elements are stored in memory as a continuous block or
sequence.
• element follows the previous one without any gaps or spaces

Non-contiguous Data Structures


• data elements are not stored as a continuous sequence in memory.
• they may be scattered or dispersed across memory.
• provide more flexibility in terms of memory allocation and dynamic
resizing
15 15
Contiguous and Non- Contiguous Data Structures
Contiguous Data Structures
• data elements are stored in memory as a continuous block or
sequence.
• element follows the previous one without any gaps or spaces

Non-contiguous Data Structures


• data elements are not stored as a continuous sequence in memory.
• they may be scattered or dispersed across memory.
• provide more flexibility in terms of memory allocation and dynamic
resizing
16 16
Algorithms
• step by step procedure to solve a particular problem is called
algorithm
• algorithms notations are used to represent different steps
• It is the general solution of the problem.
• After solving the general problem, the program is written in a
programming language
• Each Program have the time complexity, memory consumption and
efficiency.

17 17
Classification of Algorithms
• Recursion or Iteration: Calls itself repeatedly until a base condition
is satisfied
• Procedural: we have to specify the exact steps to get the result
• Declarative (non-Procedural): we say what we want without having
to say how to do it.
• Serial: execute one instruction at a time
• Parallel: process several instructions at a time.
• divide the problem into subproblem
• serve them to several processors or threads.
• Distributed: If the parallel algorithms are distributed to different
18 18
machines, then we call such algorithms distributed algorithms.
Classification of Algorithms
• Deterministic or Non-Deterministic: Deterministic algorithms solve
the problem with a predefined process, whereas non-deterministic
algorithms guess the best solution at each step through the use of
heuristics.
• Divide and Conquer
• Divide: Breaking the problem into subproblems that are themselves
smaller instances of the same type of problem.
• Recursion: Recursively solving these subproblems.
• Conquer: Appropriately combining their answers.
19 19
• Examples: merge sort and binary search algorithms.
Thank You

I wish for your better Career!

20

You might also like