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

Lecture 2.1

The document outlines a course on Data Structures at the University of Management & Technology, covering essential topics such as complexity analysis, data types, and various data structures like stacks, queues, trees, and graphs. It emphasizes the importance of choosing efficient data structures for optimal program performance and introduces abstract data types to simplify problem-solving. Evaluation criteria for the course include class participation, quizzes, assignments, projects, and exams.

Uploaded by

noobscaferen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views24 pages

Lecture 2.1

The document outlines a course on Data Structures at the University of Management & Technology, covering essential topics such as complexity analysis, data types, and various data structures like stacks, queues, trees, and graphs. It emphasizes the importance of choosing efficient data structures for optimal program performance and introduces abstract data types to simplify problem-solving. Evaluation criteria for the course include class participation, quizzes, assignments, projects, and exams.

Uploaded by

noobscaferen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

University of Management &

Technology
Data Structures
Introduction

Mr. Shoaib Khan


[email protected]

Lecture No. 2.1


General Overview
Introduction to
Computer Science

What is Hardware, Software, Programming, Operating System etc

Computer
Programming

How to write software with the help of procedural and object oriented
programming?

Data Structures

How to efficiently utilize memory with the help of different data structures?

Algorithm
Analysis

How to efficiently solve complex problems?


Course Contents
• Introduction
• Complexity Analysis
• Simple Data Types and Abstract Data Types
• Arrays and Lists
• Elementary Data Structures
• Stack and Queues
• Trees and Graphs
• Set structure
• Searching techniques
• Hashing
• Sorting techniques
What is a data structure?
• In a general sense, any representation that
is used for storing information is a data
structure

• Example: An integer, structures, classes,


linked lists, etc

• More typically, a data structure provides a


way of organization for a collection of data
items
4
Where Data Structure is
Helpful?
• The choice of efficient data structure
makes the difference between a program
running in a few seconds or many days
What is Data Structure
Efficiency?
• A solution is said to be efficient if it solves
the problem within its resource
constraints.
– Space
– Time

• The cost of a solution is the amount of


resources that the solution consumes.
Costs and Benefits
• Each data structure has costs and benefits.

• It is very difficult to find a data structure


that is better than others in all situations.

• A data structure requires:


– space for each data item it stores,
– time to perform each basic operation,
– programming effort.
Goals of this Course
1. Learn the commonly used data structures.
– These form a programmer's basic data
structure ``toolkit.'‘

2. Case Studies of Data Structures.

3. We will examine the costs and benefits of


every data structure or program.
Example
• A cellular service company provides contract to
its 10 million users
• Due to new security enforcements, the company
wants to prevent issuing of multiple
contracts to users

• Method of Detecting Multiple Contracts


– Before issuing a new contract to user
– First search the id of user in existing contracts
database
– In case of success, issue a new contract
– In case of failure, do not issue a new contract to user
Example
NIC# Name Address
6584495-9 Muhammad House No 3 Gulshan Bahar Sec 16
Faheem
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
• Linear Array (with 10 million entries)
• 3 arrays (NIC, name, address),
• structure array,
• class’s object array
Example
New
Contract NIC#
6584495-9
Name
Muhammad
Address
House No 3 Gulshan Bahar Sec 16
Faheem
Searching
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

Failure 8224641-1
Success
Syed Faraz Sharfabad Street Gulshan, Faisalabad

Issue Not
Issue
• Any disadvantage of Linear Array (Data
Structure)?
Example
• Improved Data Structure
– Create a dictionary data structure
– Group all those records together that start with
similar NIC (first digit) numbers, and add a
dictionary entry for each distinct digit (0-9)

– Example: 3419668-1, 3445864-3, 1748425-5.


• 3 and 1 are dictionary entries

– In case of searching, first search the dictionary


entry, and then proceed to searching contracts
Example
0 2
3 3 4
6 0 5

Dictionary Array
Elements
NIC# Name Address
6584495-9 Muhammad House No 3 Gulshan Bahar Sec 16
Faheem
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
Example
• Another Data Structure
• Maintain pointers with records
• Non NULL pointer indicates presence of
next record

NIC# Name Address

0 6584495-9 Muhammad
Faheem
House No 3 Gulshan Bahar Sec 16

1748425-5 Naeem Alam A-11 Shams Plaza Block-B


3 N.Nazimabad
0889679-1 Arslan Akhtar H No 152 Bostang Colony
6 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
Dictionary 8224641-1 Syed Faraz Sharfabad Street Gulshan, Faisalabad
Some basic questions
• What is an integer?
– What are the operations that can be performed
on Integers?

• What is a character?
– What are the operations that can be performed
on characters?
Some more basic questions
• How an integer is represented in memory?
– How the integer based operations are
performed?

• How a rational number is represented?


– How different operations are performed?
Abstraction levels
• What are different kinds of programming
Languages?
– Low-level/Assembly/High-level languages

• Programming in a certain type of language


involves abstraction
– In order to simplify the representation
– In order to make it easier to program
Abstraction levels
• While programming in a high-level
language we are not that bothered about
low level representation
Abstract Data Types
• Abstract data-types allow us to take our
abstraction level, one-step further

• Instead of focusing on how a particular


data-structure can be implemented, focus
is on what should be chosen to solve the
problem
Abstract Data Types
Abstract Data Type (ADT): a definition for a data type
solely in terms of a set of values and a set of operations
on that data type.

Each ADT operation is defined by its inputs and outputs.


ENCAPSULATION: Hide Implementation details

20
Abstract Data Types
Def. a collection of related data
items
together with
an associated
e.g. whole setand
numbers (integers) ofarithmetic
operationsoperators for
addition, subtraction, multiplication and division.

e.g. Flight reservation


Basic operations: find empty seat, reserve a seat,
cancel a seat assignment

Why "abstract?"
Data, operations, and relations are studied independent of
implementation.

What not how is the focus.

21
Abstract Data Types
Def.Consists of
storage structures (data structures)
to store the data items
and
algorithms for the basic operations.

The storage structures/data structures used in


implementations are provided in a language (primitive
or built-in) or are built from the language constructs
(user-defined).

In either case, successful software design uses data


abstraction:
Separating the definition of a data type from its
22
implementation.
Books
• Data Structures Using C and C++ (By Y.
Langsam, M. J. Augenstein, A. M. Tenenbaum)

• Data Structures and Algorithms (By A. V. Aho,


J. E. Hopcroft, J. D. Ullman)

• Schaum's Outline Series, Theory and


problems of Data Structures (By Seymour
Lipschutz)

Some topics will be covered from other books.


Material will be provided for these topics.
`
Evaluation Criteria
• Class Participation 5%
• Quizzes 10%
• Assignments 10%
• Project 10%
• Mid Term 25%
• Final Term 40%

You might also like