Divide and Conquer
Contents:
examples of D&C
merge sort, binary search, an,
matrix multiplication, polynomial multiplication
NCKU IIM
NCKU
Chapter 28.2
2
Divide-and-Conquer Approach
Divide the problem into a number of subproblems
Conquer the subprobl
25. All-Pairs Shortest Paths
Contents:
Shortest Paths and Matrix Multiplication
Floyd-Warshall Algorithm
Johnsons Algorithm for Sparse Graphs
NCKU IIM
NCKU
Chapter 25
2
Overview
Problem: To find the shortest route between every pair of
points on a ma
Elementary Graph Algorithms
Contents:
Graph Representations
Breadth-First Search
Depth-First Search
Topological Sort
Strongly Connected Components
NCKU IIM
NCKU
Chapter 22
2
Graphs (Appendix B.4, B.5)
A graph is a nonempty finite set V along with
Disjoint Sets Data Structures
Disjoint
& Minimum Spanning Trees
Minimum
Contents:
Growing a Minimum Spanning Tree
Prims Algorithm
Data Structures for Disjoint Sets
Kruskals Algorithm
NCKU IIM
NCKU
Chapter 21,23
2
Overview
Problem: A town has a set o
Red-Black Trees
Contents:
Properties of red-black trees
Rotations
Insertion
Deletion
NCKU IIM
Chapter 13
2
Overview
A variation of binary search trees with one extra bit of
storage per node: its color (RED or BLACK)
Each node contains 4 fields: co
Binary Search Trees
Contents:
What is a binary search tree?
Querying a binary search tree
Insertion and deletion
Randomly built binary search trees (*)
NCKU IIM
Chapter 12
2
Search Trees
Data structures that support many dynamic-set operations
SEA
Elementary Data Structures
Contents:
Stacks & Queues
Linked Lists
Implementing Pointers and Objects
Representing Rooted Trees
NCKU IIM
Chapter 10
2
Data Structure
A data structure is a way to store and organize data in order to
facilitate access and
Medians and Order Statistics
Contents:
Minimum and Maximum
Selection in Expected Linear Time
Selection in Worst-Case Linear Time
NCKU IIM
NCKU
Chapter 9
2
Overview
ith order statistic is the ith smallest element of a set of n elements.
The minimum is
Sorting in Linear Time
Contents:
Lower bounds for sorting
Counting sort
Radix sort
Bucket sort
NCKU IIM
NCKU
Chapter 8
2
Overview
How fast can we sort?
We will prove a lower bound (nlgn) , then beat it by
playing a different game.
Comparison sort
Heapsort
Contents:
Heaps
Maintaining the heap property
Building a heap
Heapsort algorithm
Priority queues
NCKU IIM
NCKU
Chapter 6
2
Heap Data Structure
Heap A is a nearly complete binary tree.
Height of node = # of edges on a longest simple path
Randomized Algorithm
Contents:
the hiring problem
indicator random variables
randomized algorithms
NCKU IIM
NCKU
Chapter 5
2
The Hiring Problem
Scenario:
You are using an employment agency to hire a new office assistant.
You interview the candidate a
Recurrences
Contents:
The substitution method
The recursion-tree method
The master method
NCKU IIM
NCKU
Chapter 4
2
What is a recurrence?
A recurrence is an equality or inequality that
describes a function in terms of its value on smaller
inputs
MER
Growth of Functions
Contents:
asymptotic notation
standard notation and common functions
NCKU IIM
NCKU
Chapter 3
2
Asymptotic Notation
(g(n) = cfw_ f(n): there exist positive constants c1, c2,
and n0 such that
0 c1 g(n) f(n) c2 g(n), n n0
(g(n) = cfw
We will first introduce foundations of data structures such as the linked lists, stacks, queues, trees, heaps,...etc. Fundamental issues about algorithms, such as how to measure algorithmic efficiency, recurrence and functions
JavaHowtoProgram,8/e
Inheritance
A form of software reuse in which a new class is created by
absorbing an existing classs members and embellishing them
with new or modified capabilities.
Can save time during program development by basing new
classes on
JavaHowtoProgram,8/e
Covered in this chapter
Classes
Objects
Methods
Parameters
double primitive type
Analogy to help you understand classes and their
contents.
Suppose you want to drive a car and make it go faster by
pressing down on its accelerator ped
JavaHowtoProgram,8/e
Java application programming
Use tools from the JDK to compile and run programs.
Videos at www.deitel.com/books/jhtp8/
Help you get started with Eclipse and NetBeans integrated
development environments.
Java application
A computer
JavaHowtoProgram,8/e
Polymorphism
Enables you to program in the general rather than program
in the specific.
Polymorphism enables you to write programs that process
objects that share the same superclass as if theyre all objects
of the superclass; this
JavaHowtoProgram,8/e
Deeper look at building classes, controlling access to
members of a class and creating constructors.
Compositiona capability that allows a class to have
references to objects of other classes as members.
More details on enum types.
JavaHowtoProgram,8/e
Data structures
Collections of related data items.
Discussed in depth in Chapters 2022.
Arrays
Data structures consisting of related data items of the same type.
Make it convenient to process related groups of values.
Remain the
JavaHowtoProgram,8/e
Best way to develop and maintain a large program is to
construct it from small, simple pieces, or modules.
divide and conquer.
Topics in this chapter
static methods
Declare a method with more than one parameter
Method-call stack
Simu