Lecture 1 - Introduction
Lecture 1 - Introduction
Fall 2023
Kainat Iqbal
[email protected]
1-Introduction 1
Some Rules
• Be respectful to others.
1-Introduction 2
Attendance Policy
• Attendance:
– At least 80% attendance is required.
– It will be marked in the first 10 minutes.
1-Introduction 3
Dishonesty and Plagiarism
1-Introduction 4
Some Details
1-Introduction 5
Assumed Background
• We can fill in gaps as needed, but if any topics are new, plan on
some extra studying
1-Introduction 6
Course & Reference Books
• Data Structures Using C++ (By D.S. Malik)
1-Introduction 7
Google Classroom
64igi2i
1-Introduction 8
Tentative Evaluation Breakdown
1-Introduction 9
Course Content
• Introduction to data structures and abstract data types
• Arrays
• Background: Templates and Algorithm Analysis
• Searching and sorting techniques
• Linked Lists
• Queues
• Stacks
• Trees: Definitions and terminology
• Trees: Binary Search Trees, AVL Trees
• Heap
• Graphs
• B+ Trees
• Hashing
1-Introduction 10
General Overview
1-Introduction 11
What is a Data Structure?
1-Introduction 12
Costs and Benefits
1-Introduction 14
Motivational Example
1-Introduction 15
Example: Linear Array Data Structure (1)
1-Introduction 16
Example: Linear Array Data Structure (2)
1-Introduction 17
Example: Improved Data Structure
1-Introduction 18
Example: Dictionary Data Structure (1)
NIC# Name Address
6584495-9 Muhammad Faheem House No 3 Gulshan Bahar Sec 16
1748425-5 Naeem Alam A-11 Shams Plaza Block-B N.Nazimabad
0889679-1 Arslan Akhtar H No 152 Bostang Colony
3419668-1 Zain Ahmed Sharfabad Street Gulshan Karachi
3445864-3 Sumair Farooq Post Office Tayyar, Multan
6395653-4 Ali Affan H.No. 425, Sector F-11/4, Islamabad
8224641-1 Syed Faraz Sharfabad Street Gulshan, Faisalabad
0 2
3 3 4
6 0 5
• Another possibility
– Maintain pointers with structures (or records)
– Non NULL pointer indicates presence of next record
1-Introduction 20
Practice Task
1-Introduction 21
What is Data Structure Efficiency?
1-Introduction 22
Abstract Data Types (1)
Implementation
2-ADTs
Operations 23
Data Structures vs. ADT
• The relationship between ADT and Data Structure is a bit like the
relationship between an interface (class.h file – tells WHAT is done)
and a class implementation (the class.cpp file – tells HOW it is
done).
2-ADTs 24
Array as an ADT
• An array is defined as
– Ordered collection of a fixed number of elements
– All elements are of the same data type
• Basic operations
– Direct access to each element in the array
– Values can be retrieved or stored in each element
3-Arrays ADT 25
C/C++ Implementation of an Array ADT
datatype arrayName[intExp];
As an ADT In C/C++
Ordered Index: 0,1,2, … SIZE-1
Fixed Size intExp is constant
Homogeneous dataType is the type of all elements
Direct Access Array subscripting operator [ ]
3-Arrays ADT 26
Summary
• What is an ADT?
– A logical representation of a data structure.
0-Preliminaries 27
Any Question So Far?
1-Introduction 28