MIRPUR UNIVERSITY OF SCIENCE AND TECHNOLOGY (MUST), MIRPUR
DEPARMENT OF ELECTRICAL ENGINEERING
Engr.Dr.Sohaib Manzoor
Web Page: http://cloud.eic.hust.edu.cn:8084/~sohaib/
 BS Electrical Engineering, Mirpur University of
Science and Technology, Pakistan Gold Medal
(2011)
 MS in Electrical & Electronics Engineering, Coventry
University, England Distinction (2014)
 PhD in Information and Communication
Engineering, Huazhong University of Science and
Technology China Academia Excellence Award
(2020)
Education Work Experience
Mininet
Web
Design
MATLAB
NS-3
OMNeT++
Skills Address:
Department of Electrical
Contact Numbers:
+923458905236
Email Address:
Sohaib.ee@must.edu.pk
Contact
Hobbies
Video Music Fixed
Gear
Travelling
Teaching, Advanced Programming Languages, Signals
and Systems, Computer Aided Design, Digital
Communications
Lecturer @ Mirpur University
Of Science and Technology, Pakistan
(2012 to date)
Achievements
 2nd Position O-levels Northern Region
 Best Debater (A-levels)
 Bronze Medal 400 m Relay (SAF Games) 2004
 Two Scholarships (London & CGS) 2013 & 2016
 Three Gold Medals Academia (2011, 2014, 2020)
Data Structures and Algorithm
EE-232
Lecture [01] : Introduction To Course
Engr.Dr.Sohaib Manzoor
Date: Dec 30th, 2020
Course Goals
 Upon completion of this course, a successful student will be able
to:
 Describe the strengths and limitations of linear data
structures, trees, graphs, and hash tables
 Select appropriate data structures for a specified problem
 Compare and contrast the basic data structures used in
Computer Science: lists, stacks, queues, trees and graphs
 Describe classic sorting techniques
 Recognize when and how to use the following data structures:
arrays, linked lists, stacks, queues and binary trees.
 Identify and implement the basic operations for manipulating
each type of data structure
Data Structures and Algorithms
Course Goals
 Upon completion of this course, a successful student will be able
to:
 Perform sequential searching, binary searching and hashing
algorithms.
 Apply various sorting algorithms including bubble, insertion,
selection and quick sort.
 Understand recursion and be able to give examples of its use
 Use dynamic data structures
 Know the standard Abstract Data Types, and their
implementations
 Students will be introduced to (and will have a basic
understanding of) issues and techniques for the assessment
of the correctness and efficiency of programs.
Data Structures and Algorithms
6
Course Outline - I
 Introduction to data structures
 Linear and non-linear data structures
 Arrays and pointers
 List data structure
 Singly linked list
 Doubly linked list
 Analysis of List data structures
 Circular linked list
 Stack; Implementation of stack using arrays
and linked list
 Applications of a stack
Data Structures and Algorithms
7
Course Outline - II
 Infix to postfix conversion
 Evaluation of postfix expressions
 Queues; Implementation of queues using
arrays and linked list
 Circular Queues; Priority Queues;
 Trees; Tree traversals; Binary search trees and
implementation
 Heaps and Heap sort;
 Graphs; Minimum spanning trees;
 Hashing
 Files
Data Structures and Algorithms
Course Information
 Textbooks
1. Data Structures through C in Depth, 2nd Edition or latest edition, S.K. Srivastava
2. Aaron M. Tenenbaum, “Data Structures Using C and C++”, Pearson Education, 2nd
Edition or latest edition
3. Mark A. Weiss, Data Structures and Algorithm Analysis in C, 2nd Edition,
Pearson Education Inc. India, 1997 .
4. Data Structures using C 2nd edition by Reema Thareja
Data Structures and Algorithms
A Nice Quote
Want to get something in life
Always think positive
You will definitely get the thing you want
A nice saying
I keep 6 honest serving men.
They taught me all I knew.
Their names are:
WHAT and WHY and WHEN and HOW and WHERE and
WHO.
(R. Kipling)
And believe me,
on the road of learning,
these are your best companions.
11
Five Tips to Success
 Work Hard
 Try More
exercises and
more practice
 Do the Labs and
assignments by
yourself
12
Five Tips
 Be patient with the
Machine
 If you really need
that, do it quietly
13
Is the same situation is with you?
yes
No
14
Boss assigns task
 To perform certain task?
How u will do?
15
Your Question
 Um? Tell me what to code.
16
So your answer
 I can develop a new algorithm for you.
Great thinkers
will always be needed.
17
Study
 Many experienced programmers were asked to
code up binary search.
80% got it wrong
Good thing is was not for a
nuclear power plant.
18
What did they lack?
 Fundamental understanding of the
algorithmic design techniques.
Programming is Problem Solving
 Programming is a process of problem solving
 Problem solving techniques
 Analyze the problem
 Outline the problem requirements
 Specify what the solution should do
 Design steps, called an algorithm, to solve the problem
(the general solution)
 Verify that your solution really solves the problem
 Algorithm – a step-by-step problem-solving process in
which a solution is arrived at in a finite amount of time
Data Structures and Algorithms
20
Introduction to Problem Solving
 Programming is a problem solving activity.
When you write a program, you are actually
writing an instruction for the computer to solve
something for you.
 Problem solving is the process of transforming
the description of a problem into a solution by
using our knowledge of the problem domain
and by relying on our ability to select and use
appropriate problem-solving strategies,
techniques and tools.
Data Structures and Algorithms
21
Problem Analysis
 Analyzing the problem require us to
identify the following:
 Input(s) to the problem, their form and the input
media to be used
 Output(s) expected from the problem, their
form and the output media to be used
 Special constraints or conditions (if any)
 Any formulas or equations to be used
22
Yummy Cupcake Example
 Input?
 Quantity of the cupcake purchased (integer)
 Price per cupcake (RM, float)
 Output?
 Total amount to be paid by the customer (RM, float)
 Constraint/condition?
 Quantity purchased must be more than zero
 Price per cupcake must be more than zero (it is not free)
 We assume that the price given is the standard price to all
cupcakes
 Formula/equation?
 Amount to pay = quantity of cupcake x price per cupcake
Data Structures and Algorithms
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.
Data Structures and Algorithms
Basic Data Structure
Basic Data Structures
Linear Data Structures Non-Linear Data Structures
Arrays Linked Lists Stacks Queues Trees Graphs Hash Tables
Data Structures and Algorithms
array
Linked list
tree
queue
stack
Data Structures and Algorithms
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
Data Structures and Algorithms
Types of Data Structure
 Non-Linear: The data values in this structure are not
arranged in order.
 Hash tables: Unordered lists which use a ‘hash function’ to insert
and search
 Tree: Data is organized in branches.
 Graph: A more general branching structure, with less strict
connection conditions than for a tree
Data Structures and Algorithms
Types 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
Data Structures and Algorithms
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
Data Structures and Algorithms
Abstract Data Type
 ADTs support abstraction, encapsulation, and information
hiding.
 Abstraction is the structuring of a problem into well-
defined entities by defining their data and operations.
 The principle of hiding the used data structure and to only
provide a well-defined interface is known as encapsulation.
Data Structures and Algorithms
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
 is the collection empty
 make the collection empty
 give me a sub set of the collection
• No single data structure works well for all purposes, and so
it is important to know the strengths and limitations of
several of them
Stacks
 Collection with access only to the last element inserted
 Last in first out
 insert/push
 remove/pop
 top
 make empty
Top
Data4
Data3
Data2
Data1
Queues
 Collection with access only to the item that has been
present the longest
 Last in last out or first in first out
 enqueue, dequeue, front
 priority queues and dequeue
Data4
Data3
Data2
Data1
Front Back
List
 A Flexible structure, because can grow and
shrink on demand.
Elements can be:
 Inserted
 Accessed
 Deleted
At any position
first
last
Tree
 A Tree is a collection of elements called nodes.
 One of the node is distinguished as a root, along with a
relation (“parenthood”) that places a hierarchical structure
on the nodes.
Root
Data Structures and Algorithms

EE-232-LEC-01 Data_structures.pptx

  • 1.
    MIRPUR UNIVERSITY OFSCIENCE AND TECHNOLOGY (MUST), MIRPUR DEPARMENT OF ELECTRICAL ENGINEERING
  • 2.
    Engr.Dr.Sohaib Manzoor Web Page:http://cloud.eic.hust.edu.cn:8084/~sohaib/  BS Electrical Engineering, Mirpur University of Science and Technology, Pakistan Gold Medal (2011)  MS in Electrical & Electronics Engineering, Coventry University, England Distinction (2014)  PhD in Information and Communication Engineering, Huazhong University of Science and Technology China Academia Excellence Award (2020) Education Work Experience Mininet Web Design MATLAB NS-3 OMNeT++ Skills Address: Department of Electrical Contact Numbers: +923458905236 Email Address: Sohaib.ee@must.edu.pk Contact Hobbies Video Music Fixed Gear Travelling Teaching, Advanced Programming Languages, Signals and Systems, Computer Aided Design, Digital Communications Lecturer @ Mirpur University Of Science and Technology, Pakistan (2012 to date) Achievements  2nd Position O-levels Northern Region  Best Debater (A-levels)  Bronze Medal 400 m Relay (SAF Games) 2004  Two Scholarships (London & CGS) 2013 & 2016  Three Gold Medals Academia (2011, 2014, 2020)
  • 3.
    Data Structures andAlgorithm EE-232 Lecture [01] : Introduction To Course Engr.Dr.Sohaib Manzoor Date: Dec 30th, 2020
  • 4.
    Course Goals  Uponcompletion of this course, a successful student will be able to:  Describe the strengths and limitations of linear data structures, trees, graphs, and hash tables  Select appropriate data structures for a specified problem  Compare and contrast the basic data structures used in Computer Science: lists, stacks, queues, trees and graphs  Describe classic sorting techniques  Recognize when and how to use the following data structures: arrays, linked lists, stacks, queues and binary trees.  Identify and implement the basic operations for manipulating each type of data structure Data Structures and Algorithms
  • 5.
    Course Goals  Uponcompletion of this course, a successful student will be able to:  Perform sequential searching, binary searching and hashing algorithms.  Apply various sorting algorithms including bubble, insertion, selection and quick sort.  Understand recursion and be able to give examples of its use  Use dynamic data structures  Know the standard Abstract Data Types, and their implementations  Students will be introduced to (and will have a basic understanding of) issues and techniques for the assessment of the correctness and efficiency of programs. Data Structures and Algorithms
  • 6.
    6 Course Outline -I  Introduction to data structures  Linear and non-linear data structures  Arrays and pointers  List data structure  Singly linked list  Doubly linked list  Analysis of List data structures  Circular linked list  Stack; Implementation of stack using arrays and linked list  Applications of a stack Data Structures and Algorithms
  • 7.
    7 Course Outline -II  Infix to postfix conversion  Evaluation of postfix expressions  Queues; Implementation of queues using arrays and linked list  Circular Queues; Priority Queues;  Trees; Tree traversals; Binary search trees and implementation  Heaps and Heap sort;  Graphs; Minimum spanning trees;  Hashing  Files Data Structures and Algorithms
  • 8.
    Course Information  Textbooks 1.Data Structures through C in Depth, 2nd Edition or latest edition, S.K. Srivastava 2. Aaron M. Tenenbaum, “Data Structures Using C and C++”, Pearson Education, 2nd Edition or latest edition 3. Mark A. Weiss, Data Structures and Algorithm Analysis in C, 2nd Edition, Pearson Education Inc. India, 1997 . 4. Data Structures using C 2nd edition by Reema Thareja Data Structures and Algorithms
  • 9.
    A Nice Quote Wantto get something in life Always think positive You will definitely get the thing you want
  • 10.
    A nice saying Ikeep 6 honest serving men. They taught me all I knew. Their names are: WHAT and WHY and WHEN and HOW and WHERE and WHO. (R. Kipling) And believe me, on the road of learning, these are your best companions.
  • 11.
    11 Five Tips toSuccess  Work Hard  Try More exercises and more practice  Do the Labs and assignments by yourself
  • 12.
    12 Five Tips  Bepatient with the Machine  If you really need that, do it quietly
  • 13.
    13 Is the samesituation is with you? yes No
  • 14.
    14 Boss assigns task To perform certain task? How u will do?
  • 15.
    15 Your Question  Um?Tell me what to code.
  • 16.
    16 So your answer I can develop a new algorithm for you. Great thinkers will always be needed.
  • 17.
    17 Study  Many experiencedprogrammers were asked to code up binary search. 80% got it wrong Good thing is was not for a nuclear power plant.
  • 18.
    18 What did theylack?  Fundamental understanding of the algorithmic design techniques.
  • 19.
    Programming is ProblemSolving  Programming is a process of problem solving  Problem solving techniques  Analyze the problem  Outline the problem requirements  Specify what the solution should do  Design steps, called an algorithm, to solve the problem (the general solution)  Verify that your solution really solves the problem  Algorithm – a step-by-step problem-solving process in which a solution is arrived at in a finite amount of time Data Structures and Algorithms
  • 20.
    20 Introduction to ProblemSolving  Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer to solve something for you.  Problem solving is the process of transforming the description of a problem into a solution by using our knowledge of the problem domain and by relying on our ability to select and use appropriate problem-solving strategies, techniques and tools. Data Structures and Algorithms
  • 21.
    21 Problem Analysis  Analyzingthe problem require us to identify the following:  Input(s) to the problem, their form and the input media to be used  Output(s) expected from the problem, their form and the output media to be used  Special constraints or conditions (if any)  Any formulas or equations to be used
  • 22.
    22 Yummy Cupcake Example Input?  Quantity of the cupcake purchased (integer)  Price per cupcake (RM, float)  Output?  Total amount to be paid by the customer (RM, float)  Constraint/condition?  Quantity purchased must be more than zero  Price per cupcake must be more than zero (it is not free)  We assume that the price given is the standard price to all cupcakes  Formula/equation?  Amount to pay = quantity of cupcake x price per cupcake Data Structures and Algorithms
  • 23.
    What is DataStructure?  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. Data Structures and Algorithms
  • 24.
    Basic Data Structure BasicData Structures Linear Data Structures Non-Linear Data Structures Arrays Linked Lists Stacks Queues Trees Graphs Hash Tables Data Structures and Algorithms
  • 25.
  • 26.
    Types of DataStructure  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 Data Structures and Algorithms
  • 27.
    Types of DataStructure  Non-Linear: The data values in this structure are not arranged in order.  Hash tables: Unordered lists which use a ‘hash function’ to insert and search  Tree: Data is organized in branches.  Graph: A more general branching structure, with less strict connection conditions than for a tree Data Structures and Algorithms
  • 28.
    Types of DataStructures  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 Data Structures and Algorithms
  • 29.
    Abstract Data Typeand 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 Data Structures and Algorithms
  • 30.
    Abstract Data Type ADTs support abstraction, encapsulation, and information hiding.  Abstraction is the structuring of a problem into well- defined entities by defining their data and operations.  The principle of hiding the used data structure and to only provide a well-defined interface is known as encapsulation. Data Structures and Algorithms
  • 31.
    The Core Operationsof 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  is the collection empty  make the collection empty  give me a sub set of the collection
  • 32.
    • No singledata structure works well for all purposes, and so it is important to know the strengths and limitations of several of them
  • 33.
    Stacks  Collection withaccess only to the last element inserted  Last in first out  insert/push  remove/pop  top  make empty Top Data4 Data3 Data2 Data1
  • 34.
    Queues  Collection withaccess only to the item that has been present the longest  Last in last out or first in first out  enqueue, dequeue, front  priority queues and dequeue Data4 Data3 Data2 Data1 Front Back
  • 35.
    List  A Flexiblestructure, because can grow and shrink on demand. Elements can be:  Inserted  Accessed  Deleted At any position first last
  • 36.
    Tree  A Treeis a collection of elements called nodes.  One of the node is distinguished as a root, along with a relation (“parenthood”) that places a hierarchical structure on the nodes. Root Data Structures and Algorithms

Editor's Notes

  • #6 ADT : ADT is a mathematical model or concept that define the data type logically. It specifies a set of data and collection of operations that can be performed on data. The definition of ADT only mentions what operations are to be performed but not how these operations will be implemented. It does not specify how data will be organized in memory and what algorithms will be used for implementing the operation.