Вы находитесь на странице: 1из 20

Data Structures and Algorithms

Introduction
Subject Overview
Introduction to many of the basic data structures
used in computer software
Understand the data structures
Analyze the algorithms that use them
Know when to apply them
Practice design and analysis of data structures.
Practice using these data structures by writing
programs.
Make the transformation from programmer to
computer scientist
Data Structures
Clever ways to organize information in order
to enable efficient computation

What do we mean by clever?
What do we mean by efficient?
Picking the best
Data Structure for the job
The data structure you pick needs to
support the operations you need
Ideally it supports the operations you will
use most often in an efficient manner
Examples of operations:
A List with operations insert and delete
A Stack with operations push and pop
Why So Many Data Structures?
Ideal data structure:
fast, elegant, memory efficient
Generates tensions:
time vs. space
performance vs. elegance
generality vs. simplicity
one operations performance vs. anothers
The study of data structures is the study of
tradeoffs. Thats why we have so many of
them!
6
The Need for Data Structures
Data structures organize data
more efficient programs.
More powerful computers more complex
applications.
More complex applications demand more
calculations.
Complex computing tasks are unlike our
everyday experience.
7
Organizing Data
Any organization for a collection of
records can be searched, processed in
any order, or modified.

The choice of data structure and algorithm
can make the difference between a
program running in a few seconds or
many days.
8
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.


9
Selecting a Data Structure
Select a data structure as follows:
1. Analyze the problem to determine the
resource constraints a solution must
meet.
2. Determine the basic operations that must
be supported. Quantify the resource
constraints for each operation.
3. Select the data structure that best meets
these requirements.
10
Data Structure Philosophy
Each data structure has costs and benefits.
Rarely is one data structure better than
another in all situations.
A data structure requires:
space for each data item it stores,
time to perform each basic operation,
programming effort.
11
Data Structure Philosophy (cont)
Each problem has constraints on available
space and time.
Only after a careful analysis of problem
characteristics can we know the best
data structure for the task.
Bank example:
Start account: a few minutes
Transactions: a few seconds
Close account: overnight
Terminology
Abstract Data Type (ADT)
Mathematical description of an object with set of
operations on the object. Useful building block.
Algorithm
A high level, language independent, description of a step-
by-step process
Data structure
A specific family of algorithms for implementing an abstract
data type.
Implementation of data structure
A specific implementation in a specific language
13
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.
14
Data Structure
A data structure is the physical
implementation of an ADT.
Each operation associated with the ADT is
implemented by one or more subroutines in
the implementation.

Data structure usually refers to an
organization for data in main memory.

File structure is an organization for data on
peripheral storage, such as a disk drive.
15
Metaphors
An ADT manages complexity through
abstraction: metaphor.
Hierarchies of labels

Ex: transistors gates CPU.

In a program, implement an ADT, then think
only about the ADT, not its implementation.
Data Structures
A data structure is a scheme for
organizing data in the memory
of a computer.
Some of the more commonly
used data structures include lists,
arrays, stacks, queues, heaps,
trees, and graphs.
Binary Tree
Data Structures
The way in which the data is
organized affects the
performance of a program for
different tasks.
Computer programmers decide
which data structures to use
based on the nature of the
data and the processes that
need to be performed on that
data.
Binary Tree
Thank You

Вам также может понравиться