Chapter 4 Linked Lists
Recall that linked lists enable us to dynamically adjust the size of a list, eliminating the need to preallocate a specific amount of memory.
Static Array
Preallocation Requir
Chapter 13
Graphs
1
Graph
!
!
!
Set V of vertices and
E of edges
2
Subgraph
!
!
!
Subset of vertices
and edges
(a) A campus map as a graph; (b) a subgraph
3
Adjacent vertices
!
!
!
Joined by an edg
Ch 10
Trees
!1
Some terms to remember
root
node
siblings
leaf
nodes
!2
More terms .
left
subtree
right
subtree
!3
Let's look at a General tree first
root
root
R
L
L
L
L
L
L
!4
. and now a Binary tree
Achieving a
better solution
in three steps
Sunday, September 15, 13
A solution derived without a design will undoubtedly suffer from all sorts of problems. A solution that is properly designed however
Carrano Ch 3
Data Abstraction
1
Sunday, September 15, 13
1
Key Terms : Modularity
Favors simplicity
Small tasks are more manageable than large
tasks
Encourages reusability
Build large applications
Algorithm Efciency deals with
! Methods of Solution rather than programs!
!
! Efcient use of time and memory!
!
! Mathematical methods independent of coding,
computers or data
!1
Do not compare progra
Recursion
1
Monday, October 14, 13
1
What is Recursion?
Solution given in terms of problem. Huh?
Each problem is a smaller instance of itself.
Implemented via functions.
Very powerful solving tech
Stack : ADT
LIFO Last In First Out
top of stack
bottom of stack
1
Sunday, September 15, 13
1
Stack : Operations
1. Create an empty stack.
2. Destroy a stack.
3. Determine if a stack is empty.
4. Add a
Queue : ADT
1. Create an empty queue.
2. Destroy a queue.
3. Determine whether a queue is empty.
4. Add a new item to the queue.
5. Remove from the queue the item that was added earliest.
6. Retrieve
! Pointers
!
Linked List
Objectives
!
!
!
!
!
!
!
What is a linked list?
Create a list
Insert a node
Delete a node
Traverse a list
Find a node
Add a head node
!
! Create a circular linked list
! Conve
ADT: Table
!
! The ADT table, or dictionary!
! Uses a search key to identify
its items!
!
! Its items are records that
contain several pieces of
data
1
ADT Table : UML
2
ADT Table
!
! Our table assu
Chapter 5 Recursion
Recursion can be a very effective technique for solving what would otherwise be extremely elaborate problems.
Sample recursive applications include: Backtracking algorithms. Progra
Chapter 6 Stacks
The stack abstract data type is essentially a list using the LIFO (lastin firstout) policy for adding and removing elements.
The principal stack operations:
Create an empty stack.
Chapter 7 Queues
The queue abstract data type is essentially a list using the FIFO (first infirstout) policy for adding and removing elements.
The principal queue operations:
Create an empty queue.
Chapter 8 Class Relationships
Up to this point, the C+ classes that we've used have been little more than elaborate structs. We're now going to examine some of the features of C+ classes that expand t
Chapter 9 Algorithm Efficiency & Sorting
Programming efficiently has been important up to this point, but we're now going to examine the methods that have been developed to determine just how efficien
Chapter 10 Trees
The tree abstract data type provides a hierarchical structure to the representation of certain types of relationships.
Array Implementation Linked List Implementation Binary Search T
Additional Tree Traversal Example #1
/ Public function to "spell out" the values from the root to the tree's / / leaf nodes, with the results output on a separate line for each leaf. / template <class
Chapter 11 Tables And Priority Queues
Simple arrays and linked lists are not the only structures that can effectively maintain tables of data.
Array Implementation of Table Linked List Implementation
Chapter 13 Graphs
The graph ADT, while relatively unstructured, provides a platform for solving some of the most sophisticated problems in computer science.
Graph Abstract Data Types Topological Sort
The Eight Queens Problem
Backtracking
Problem: How do you place 8 queens on a chessboard in such a
way that no queens attack each other?
Possible Solutions:
Guess at a solution: C(64, 8) = 4,426,1