CSC 263 H1
Worth: 8%
Assignment # 2
Fall 2015
Due: By 5:59pm on Tuesday 13 October
Remember to write the full name and student number of every group member prominently on
your submission.
Please read
READING: Sections 11.1, 11.2, 11.3 (except 11.3.3).
SELFTEST: Exercises 11.11, 11.21, 11.22.
Hashing
Problem 1: Read a text file, keep track of number of occurrences of each
character (ASCII codes 0 1
An undirected graph G = (V,E) is called "bipartite" when the vertices can be
partitioned into two subsets V = V_1 u V_2 (with V_1 n V_2 = cfw_) such that
every edge of G has one endpoint in V_1 and th
CSC 263 H1
Worth: 2%
Problem Set # 8
Fall 2014
Due: By 9:59pm on Wednesday 19 November
Remember to write your full name and student number prominently on your submission.
Please read and understand th
CSC 263 H1
Worth: 2%
Problem Set # 3
Fall 2014
Due: By 9:59pm on Wednesday 1 October
Remember to write your full name and student number prominently on your submission.
Please read and understand the
CSC 263 H1
Worth: 2%
Problem Set # 6
Fall 2014
Due: By 9:59pm on Wednesday 5 November
Remember to write your full name and student number prominently on your submission.
Please read and understand the
CSC 263 H1
Worth: 2%
Problem Set # 7
Fall 2014
Due: By 9:59pm on Wednesday 12 November
Remember to write your full name and student number prominently on your submission.
Please read and understand th
CSC 263 H1
Worth: 2%
Problem Set # 2
Fall 2014
Due: By 9:59pm on Wednesday 24 September
Remember to write your full name and student number prominently on your submission.
Please read and understand t
CSC 263 H1
Problem Set # 1
Worth: 2%
Fall 2014
Due: By 9:59pm on Wednesday 17 September
Remember to write your full name and student number prominently on your submission.
Please read and understand t
CSC 263 H1
Worth: 2%
Problem Set # 5
Fall 2014
Due: By 9:59pm on Thursday 30 October
Remember to write your full name and student number prominently on your submission.
Please read and understand the
CSC 263 H1
Assignment # 1Complete
Worth: 12%
Fall 2014
Due: By 9:59pm on Thursday 16 October
Remember to write the full name and student number of every group member prominently on
your submission.
Pl
CSC 263 H1
Problem Set # 4
Worth: 2%
Fall 2014
Due: By 9:59pm on Wednesday 8 October
Remember to write your full name and student number prominently on your submission.
Please read and understand the
1. Prove an Omega(m log n) bound on the worst-case sequence complexity of m
MAKE-SET, UNION, and FIND-SET operations (n of which are MAKE-SET) using
the tree implementation with only union-by-rank (no
READINGS: Chapter 6.
SELFTEST: Exercises 6.11, 6.14, 6.24.
Priority Queues
"Priority queue": like a queue except every item has a "priority" (usually a
number) that determines retrieval order. More fo
READING: Chapter 23.
SELF-TEST: Exercise 23.1-1, 23.2-2.
Minimum Spanning Trees
Let G = (V,E) be a connected, undirected graph with
edge weights w(e) for each edge e in E.
A tree is a subset of edges
CSC 263 H1
Worth: 8%
Assignment # 1
Fall 2015
Due: By 5:59pm on Tuesday 29 September
Remember to write the full name and student number of every group member prominently on
your submission.
Please rea
CSC 263 H1
1.
Assignment # 1Sample Solutions
Fall 2015
(a) In the best case, A[1], the rst element we check, is v, so we nd v after one comparison, i.e.,
Line #2 is executed only once.
(b) The probabi
CSC 263 H1
1.
Assignment # 2Sample Solutions
Fall 2015
(a) We use two AVL trees with keys sorted in dierent ways. Each node corresponds to one
position (x, y), and each nodes stores the set of colours
READING: Sections 22.2, 22.3.
SELF-TEST: Exercise 22.3-2.
Last week Larry taught the BFS algorithm.
Q: What did we use to avoid getting caught in an infinite loop?
A: colours
Q: What did we end up wit
READINGS: Chapters 2, 3; Sections 4.5, 5.1, 5.2.
Data Structures
"Abstract Data Type" (ADT) set of objects together with set of operations
on these objects, e.g.:
1. Objects: integers
Operations: ADD(
The "complete graph" K_n is the undirected graph on n vertices with every
pair of vertices connected by an edge.
1. Draw K_1, K_2, K_3, K_4 and K_5.
Write down the adjacency lists representation for K
READING: Sections 21.1, 21.2, 21.3.
SELF-TEST: Exercise 21.2-2.
Disjoint Sets
Disjoint Set ADT:
- Objects: Collection of nonempty disjoint sets S = cfw_S_1,S_2,.,S_k
each S_i is a nonempty set that ha
READINGS: Part III (introduction), Sections 12.1, 12.2, 12.3.
SELFTEST: Exercises 12.23, 12.31.
Dictionaries
Dictionary ADT (slightly different version than textbook):
Objects:
Sets S where each eleme
READING: Sections 8.1, 9.1.
SELF-TEST: Exercise 8.1-1.
Lower Bounds
How fast can we sort?
- Existence of algorithms that run in worst-case time O(n log n) confirm
sorting can be done in time O(n log n
READING: Chapter 17.
SELF-TEST: Exercises 17.1-2.
Amortized Analysis
- Often, we perform _sequences_ of operations on data structures and time
complexity for processing the entire sequence is importan
READINGS: Problem 133, Sections 14.1, 14.2.
SELFTEST: Exercises 14.11, 14.12.
Mechanism to rebalance BST: "rotations"
y
right rotation
/\
>
/\
x C
/\
A y
left rotation
A B
x
<
/\
B C
Three references
1. Let G = (V,E) be a weighted connected undirected graph with n vertices
and m edges. Write an O(m log(n) algorithm for finding E_cfw_min, a set
of edges of minimum total weight such that every cycle
READING: Chapter 7.
SELFTEST: Exercises 7.11, 7.22.
QuickSort
The following algorithm sorts an input sequence S in nondecreasing order.
QuickSort(S):
1.
if |S| <= 1: return S
else:
2.
select pivot p i