CPSC 250 Fall 2011
Lab 1:Get familiar with Linux
By Dr. Yingwu Zhu, Seattle University
Tasks (You should perform the following tasks step by step):
1.
2.
3.
4.
5.
Check out your CS1 account
Set up you
ADT: Design & Implementation
Dr. Yingwu Zhu
Outline
Concept: ADT
Demonstration of ADTs design and
implementation
List as an ADT (our focus)
Stack & Queue as ADTs (exercises)
Abstract Data Type (AD
Quicksort
Dr. Yingwu Zhu
Quicksort
A more efficient exchange sorting scheme than
bubble sort
A typical exchange involves elements that are far apart
Fewer interchanges are required to correctly pos
Hashing
Dr. Yingwu Zhu
What do I have?
Recall order of magnitude of searches
Linear search O(n)
Binary search O(log2n)
Balanced binary tree search O(log2n)
Unbalanced binary tree can degrade to O
Tree Balancing: AVL Trees
Dr. Yingwu Zhu
Recall in BST
The insertion order of items determine the
shape of BST
Balanced: search T(n)=O(logN)
Unbalanced: T(n) = O(n)
Key issue:
Need to keep a BST
Algorithm Complexity Analysis: Big-O
Notation (Chapter 10.4)
Dr. Yingwu Zhu
Measure Algorithm Efficiency
Space utilization: amount of memory
required
Time efficiency: amount of time required to
acco
Binary Search Trees (BST)
Dr. Yingwu Zhu
Review: Linear Search
Collection of data items to be searched is
organized in a list
x1, x2, xn
Assume = and < operators defined for the
type
Linear search
Review: C+ Basic Concepts
Dr. Yingwu Zhu
Outline
C+ class declaration
Constructor
Overloading functions
Overloading operators
Destructor
Redundant declaration
A Real-World Example
Question #1: How to
Basic Sorting Algorithms
Dr. Yingwu Zhu
Sorting Problem
Consider list
x1 , x 2 , x 3 , x n
Goal: arrange the elements of the list in
order
Ascending or descending
Some O(n2) schemes
easy to understand
Introduction
Dr. Yingwu Zhu
What to learn?
ADT design & implementation using different
data structures
Algorithm time efficiency analysis by Big-O
ADTs operations & applications
Binary search tree
CPSC 250 Data Structures by Dr. Zhu
Homework Assignments #1
Due by 9:20AM, Sept 30, Friday
1. Goals
This assignment aims to further understanding of some basic C+ concepts weve discussed in class,
whi
Solutions to Mid-Term Exam #1
Part I: Algorithm Efficiency Using Big-O Notations. (16 points)
1. True
2. Since T(n) = O(n2), we have
T(n) Cn2
(where C is a constant)
3
C n
(where n 1)
3
= O(n )
3. T(
Assignments #2
Due by 9:20 AM, Wednesday, 10/12/2011
Note: 16 points in total. Hardcopy submission is required! Please staple your
HW solution papers if it has multiple pages!
1. Explain why, if T(n)