Threaded representation of binary trees
Notice three important facts:
(a) the traversal algorithms studied so far spend most of their time manipulating a stack;
(b) the storage space required for the stack is potentially large;
(c) the majority of pointer
Denitions and related concepts
Binary tree traversals
Binary tree representation in computer
Threaded binary trees
Binary Trees
Richard Bryann Chua
CS 123 (Data Structures)
August 2, 2013
Richard Bryann Chua CS 123 (Data Structures)
Binary Trees
Denitions
Linear Lists
Sequential Representation of Linear Lists
Linked Representation of Linear Lists
Implementing Pointers and Objects in Pointerless Language
Linear Lists
Richard Bryann Chua
CS 123 (Data Structures)
July 19, 2013
Richard Bryann Chua CS 123 (Data
Queue
Deques
Queues and Deques
Richard Bryann Chua
CS 123 (Data Structures)
July 12, 2013
Richard Bryann Chua CS 123 (Data Structures)
Queues and Deques
Queue
Deques
Sequential Implementation of a Queue
Linked Implementation of a Queue
Outline
1
Queue
Seq
Denition of Stack
Sequential Implementation of Stack
Linked Implementation of Stack
Applications of Stack
Stacks
Richard Bryann Chua
CS 123 (Data Structures)
July 5, 2013
Richard Bryann Chua CS 123 (Data Structures)
Stacks
Denition of Stack
Sequential Imp
Heaps and the heapsort algorithm
Priority queues
Applications of Binary Trees
Richard Bryann Chua
August 16, 2013
Richard Bryann Chua
Applications of Binary Trees
Heaps and the heapsort algorithm
Priority queues
Outline
1
Heaps and the heapsort algorithm
3
CHAPTER
3
33
3
The Running Time
of Programs
In Chapter 2, we saw two radically dierent algorithms for sorting: selection sort
and merge sort. There are, in fact, scores of algorithms for sorting. This situation
is typical: every problem that can be solv
How do we solve a problem?
What is a data structure?
What is an algorithm?
Implementing ADTs
Lecture 1 Basic Concepts
Richard Bryann Chua
CS 123 (Data Structures)
June 21, 2013
Richard Bryann Chua CS 123 (Data Structures)
Lecture 1 Basic Concepts
How do w
Binary Search Trees
AVL Trees
Binary Search Trees
Richard Bryann Chua
CS 123 (Data Structures)
August 30, 2013
Richard Bryann Chua CS 123 (Data Structures)
Binary Search Trees
Binary Search Trees
AVL Trees
Implementing Basic Operations for BST
Outline
1
B
Denitions and Related Concepts
Representation of Graphs
Graph Traversals
Classical Applications of DFS and BFS
Graphs
Richard Bryann Chua
CS 123 (Data Structures)
March 12, 2013
Richard Bryann Chua CS 123 (Data Structures)
Graphs
Denitions and Related Con
Denitions and Related Concepts
Representation of Graphs
Graph Traversals
Classical Applications of DFS and BFS
Graphs
Richard Bryann Chua
CS 123 (Data Structures)
October 1, 2013
Richard Bryann Chua CS 123 (Data Structures)
Graphs
Denitions and Related Co
Introduction
Converting Keys to Numbers
Choosing a Hash Function
Collision Resolution by Chaining
Collision Resolution by Open Addressing
Hash Tables
Richard Bryann Chua
CS 123 (Data Structures)
March 19, 2013
Richard Bryann Chua CS 123 (Data Structures)
Introduction
Converting Keys to Numbers
Choosing a Hash Function
Collision Resolution by Chaining
Collision Resolution by Open Addressing
Hash Tables
Richard Bryann Chua
CS 123 (Data Structures)
October 11, 2013
Richard Bryann Chua CS 123 (Data Structures
Denitions and Related Concepts
Natural Correspondence
Forest Traversal
Representations of Trees and Forests
Trees and the Equivalence Problem
Trees and Forests
Richard Bryann Chua
CS 123 (Data Structures)
September 13, 2013
Richard Bryann Chua CS 123 (Dat
DIZON, Precious Joy U.
CS 123 - Problem Set 4
Prof. Chua
August 16, 2011
1. (Q 6-5) List the nodes of the binary tree shown below in:
(a) preorder : DICEOSVRY
(b) inorder : CEIODSRVY
(c) postorder : ECOIRYVSD
(d) converse preorder : DSVYRIOCE
(e) converse
DIZON, Precious Joy U.
CS 123 - Problem Set 1
Prof. Chua
June 30, 2011
1. Let T(n) be the number of times S is executed; then we have:
T (n) =
n
i=1
n
j =i
=
n
i=1
n
j =i j
=
n
i=1 [
n
j =1 j
=
n(n+1)
n
i=1 [ 2
=
2
n
+
[n 2 n
i=1
= 1(
2
=
1
2
n
2
i=1 n
j
DIZON, Precious Joy U.
CS 123 - Problem Set 1
Prof. Chua
November 29, 2011
1. Let T(n) be the number of times S is executed; then we have:
T (n) =
n
i=1
n
j =i
=
n
i=1
n
j =i j
=
n
i=1 [
n
j =1 j
=
n(n+1)
n
i=1 [ 2
=
2
n
+
[n 2 n
i=1
= 1(
2
=
1
2
n
2
i=1
DIZON, Precious Joy U.
CS 123 - Problem Set 5
Prof. Chua
August 23, 2011
Binary search algorithm - selects the next search diapason by always dividing the search
interval of a sorted array in half. It runs in O(log (n) time, and this is signicantly better
Introduction to Graphs: Breadth-First, Depth-First Search, Topological Sort Chapter 23 Graphs So far we have examined trees in detail. Trees are a specific instance of a construct called a graph. In general, a graph is composed of edges E and vertices V t
DIZON, Precious Joy U.
CS 123 - Problem Set 2
Prof. Chua
July 05, 2011
1. Find the postx form of the following inx expressions:
(a) A + B C /(D E )
(b) B D 2/C E
(c) A (B (6 + D E )/8) - G 3
A B C + D E /
B D 2 C E /
A B 6 D + E 8/ G 3
2. A circular q
DIZON, Precious Joy U.
CS 123 - Problem Set 3
Prof. Chua
July 14, 2011
1. Let l1 and l2 be pointers to the list heads of two straight singly-linked lists (of the type
depicted in our lecture slides). Write a function in pseudocode format to test whether
t
CMSC 123 (Data Structures)
Problem Set 1
INSTRUCTION: Answer the following problems briey, cleanly, clearly and orderly. Solutions can be
A
written in a yellow pad. The next problem sets should be printed with L TEX typesetting.
1. (Quiwa P3-4) Find the t