Lecture 01 Intro
Lecture 01 Intro
Introduction
Data Structures & Algorithms
COSC-2101
1
Administrative
• Instructor: Ms. Humaira Anwer
• [email protected]
• ICT Building, Office: 2nd Floor COSC-3.08
• Email: [email protected]
http://www.niit.edu.pk/~azhar
• Consulting hours:
• 800 hrs. to 1000 hrs.
• Email me and get in touch if in need
• Regularly check course folder on LMS
2
Course Contents
• Data Types
• Overview, Introductory concepts
• Data Types, meaning and implementation
• Abstract data types (ADT)
• Arrays (revisited)
• Linked Lists
• Stacks
• Queues
• Trees (traversals, implementation)
3
Course Contents
• Binary Trees (BTs)
• Binary Search Trees (BSTs)
• Balanced Search Trees
• (AVL Tree)
• Recurssion
• Towers of Hanoi
• Indexing Methods
• Hashing
• Heaps
• Graphs
4
Text book
• Reference Books:
• Data Structures and Algorithm Analysis, Mark Allen Weiss,
Florida International University, Addison-Wesley (latest
Edition)
5
Assignment Policy
• DO NOT copy assignments
• Both of the copy cases will be graded zero
• Submission time will be 1500 hrs on the due date
• NO credit on LATE submission of any deliverable.
• No excuse of USB/Floppy/email servers not working
• Sorry! No Exceptions
6
Weightage
• Mid Exam 25%
• Quizzes 10%
• Assignments 10%
• Attendance 5%
• Final Exam 50%
7
Honor Code
• Dishonesty will NOT be tolerated.
• Will result in zero marks in the corresponding work
• Cell Phones should be TURNED OFF during class
8
Lets start the course!
9
Today’s Agenda
• Purpose of Studying Data Structures (DS)
• Objectives of Course
• Basic Terminologies
• Real Life Example
• Data Types
• Primitive & Non-Primitive Data Types
• Abstract Data Types (ADTs)
• Classification of Non-Primitive Data Types
• Linear & Non-Linear DS
• Static & Dynamic DS
• Homogenous & Non-Homogenous DS
• Operations on DS
• Goals of DS
• Selection of Appropriate DS
10
Purpose
• Designed to develop students understanding the
impact of structuring data to achieve efficiency of
a solution to a problem
11
Objectives of the Course
• Present in a systematic fashion the most commonly
used data structures, emphasizing their abstract
properties.
• Discuss typical algorithms that operate each kind of
data structure, and analyze their performance.
• Compare different Data Structures for solving the
same problem, and choose the best
12
Introduction
• Data: Information processed or stored by
a computer.
• Structure: Way of organizing information, so that it
is easier to use.
• Data Structure: Its a particular way of organizing
data in a computer so that it can be used efficiently.
13
A Real Life Example
Electronic Phone Book • Lisa
Contains different DATA: • Michele
- names • John
- phone number • 110
- addresses • 622-9823
Need to perform certain OPERATIONS: • 112-4433
- add • 75
- delete • Bronson
- look for a phone number • Paola
- look for an address
14
Data Types
• Data type is way to classify various types of data
such as:
• integer
• float
• char
• String
• bool
• It determines values that can be used with the
corresponding type of data.
15
Classification of Data
Structure
16
Primitive & Non
Primitive Data Types
• Primitive data type
17
Abstract Data Types (ADTs)
• ADT is a mathematical model that gives a set of
utilities available to the user but never states the
details of its implementation.
18
Classification of Data Structures
(Non-Primitive Data Types)
• There are various ways to classify data
structures (non-primitive Data Types):
– Linear & non linear data structures
– Static and dynamic data structures
– Homogenous and non homogenous(Hetrogenous)
data structures.
19
Linear & Non Linear Data Structures
Non-
Primitive
DS
20
Linear Data Structures
• Those data structures where the data elements are
organized in some sequence are called linear data
structures.
21
Non Linear Data Structures
• When the data elements are organized in
some arbitrary function without any
sequence, such data structures are called non-
linear data structures.
• Examples are:
– Trees
– Graphs
– Heaps
22
Static and Dynamic Data Structures
Static Dynamic
Memory is allocated at the compile time. Memory is allocated to data structure at
Fixed size. the run time(dynamically) i.e. as the
program executes
The program/ memory management can Can extend as far as physically possible.
allocate fixed amount of memory. More flexible.
Sets aside memory regardless of whether Makes the most efficient use of memory
it is needed or not. Very inefficient. as the data structure only uses as much
memory as it needs.
Memory wastage. No wastage of memory.
Memory is allocated sequentially. Memory is not allocated sequentially.
Easier to program as there is no need to Harder to program as software needs to
check on data structure size at any point. keep track of its size and data item
locations at all times.
Arrays are examples of static data Linked lists are examples of dynamic data
structures. structures.
23
Homogenous & Non Homogenous
Data Structures
• In homogenous data structure, all the
elements are of same type. For Example:
arrays.
24
Operations on Data
Structure
• Traverse
• Display
• Insert/Add
• Delete/Destroy/Remove
• Select
• Search
• Sort
• Merge
• Peek
25
Goals of Data structures
• Identify and develop useful mathematical entities
and operations and to determine what classes of
problems can be solved by using these entities and
operations.
26
Selecting A Data Structure
• Analyze the problem.
27