CPSC 221: Written Assignment 2
Last Updated: October 9, 2013
Due: Monday, October 29, 2012 at the beginning of class in class.
Late submissions are not accepted.
1. (5 points) Consider the following code for nding a maximum element in an array:
/ Find a m
CPSC 221: Written Assignment 3
Last Updated: November 14, 2013
Due: Monday, November 25, 2013 at the beginning of class in class.
Late submissions are not accepted.
1. Draw the Dictionary data structure obtained after inserting:
10, 20, 30, 40, 50, 60, 70
CPSC 221: Written Assignment 1
Last Updated: September 10, 2013
Due: Monday September 23, 2013 at the beginning of class in class.
Late submissions are not accepted.
1. (5 points) The following pseudo-code is intended to remove all occurrences of element
CPSC 221: Fall 2015
Lab 1
These must be completed and shown to your lab TA either by the end of this lab,
or by the start of your next lab. You may work in groups of up to two people.
This is an introduction to C+ through some simple activities. You shoul
CPSC 221: Fall 2015
Lab 2
These must be completed and shown to your lab TA either by the end of this lab,
or at the start of your next lab. You may work in groups of up to two people.
1. Please look at the brief introduction to C+ slides available on the
CPSC 221:
Algorithms and Data Structures
Lecture #0: Introduction
Alan J. Hu
(Borrowing some slides from Steve
Wolfman)
Webpage: http:/www.ugrad.cs.ubc.ca/~cs221
1
Rule #1: Ask questions!
Who I Am
Alan J. Hu (You can call me Alan or Prof. Hu.)
ajh@cs.ubc.
CPSC 221:
Algorithms and Data Structures
ADTs, Stacks, and Queues
Alan J. Hu
(Slides borrowed from Steve Wolfman)
Be sure to check course webpage!
http:/www.ugrad.cs.ubc.ca/~cs221
1
Lab 1 available very soon!
Instructions for Lab 1 will be posted on cour
A Sophomoric Introduction to
Shared-Memory Parallelism and Concurrency
Dan Grossman
Adapted to C+ by Steve Wolfman
Version of March 30, 2012
Contents
1
2
Meta-Introduction: An Instructors View of These Notes
1.1 Where This Material Fits in a Changing Curr
CS221: Algorithms and
Data Structures
Asymptotic Analysis
Alan J. Hu
(Borrowing slides from Steve Wolfman)
1
Learning Goals
By the end of this unit, you will be able to
Define which program operations we measure in an
algorithm in order to approximate its
CS221: Algorithms and
Data Structures
Quick Review of Pointers
Alan J. Hu
(Borrowing some slides from Steve Wolfman)
1
Learning Goals
Get comfortable with C+ pointers, understand
the * and & operators.
Draw diagrams to help understand code that
manipula
CPSC 221:
Algorithms and Data Structures
Crash Course on Arrays
Alan J. Hu
1
Why Arrays?
Arrays are a very low-level data structure, that
basically matches the underlying memory.
Good: They are very efficient!
Bad: They have unpleasant limitations.
Fac
CS221: Algorithms and
Data Structures
Analyzing Runtime
Alan J. Hu
(Borrowing many slides from Steve Wolfman)
1
Types of analysis
Orthogonal axes
bound flavor
upper bound (O)
lower bound ()
asymptotically tight ()
analysis case
worst case (adversary)
CS221: Algorithms and
Data Structures
Priority Queues and Heaps
Alan J. Hu
(Borrowing slides from Steve Wolfman)
1
Learning Goals
After this unit, you should be able to:
Provide examples of appropriate applications for
priority queues and heaps
Manipula
CS221: Algorithms and
Data Structures
Big-O
Alan J. Hu
(Borrowing some slides from Steve Wolfman)
1
Learning Goals
Define big-O, big-Omega, and big-Theta: O(), (), ()
Explain intuition behind their definitions.
Prove one function is big-O/Omega/Theta o
CPSC 221:
Algorithms and Data Structures
ADTs, Stacks, and Queues
Alan J. Hu
(Slides borrowed from Steve Wolfman)
Be sure to check course webpage!
http:/www.ugrad.cs.ubc.ca/~cs221
1
Lab 1 is up!
Instructions for Lab 1 have been posted on course
webpage f
CS221: Algorithms and
Data Structures
Quick Review of Pointers
Alan J. Hu
(Borrowing some slides from Steve Wolfman)
1
Learning Goals
Get comfortable with C+ pointers, understand
the * and & operators.
Draw diagrams to help understand code that
manipula
CPSC 221:
Algorithms and Data Structures
Lecture #0: Introduction
Alan J. Hu
(Borrowing some slides from Steve
Wolfman)
Webpage: http:/www.ugrad.cs.ubc.ca/~cs221
1
Rule #1: Ask questions!
Who I Am
Alan J. Hu (You can call me Alan or Prof. Hu.)
ajh@cs.ubc.
CSE 221: Algorithms and
Data Structures
Lecture #9
Graphs (with no Axes to Grind)
Steve Wolfman
2011W2
1
Todays Outline
Topological Sort: Getting to Know Graphs with a Sort
Graph ADT and Graph Representations
Graph Terminology (a lot of it!)
More Graph Al
CS221: Algorithms and
Data Structures
Lecture #1
Complexity Theory and
Steve Wolfman
Asymptotic Analysis
2013W2
1
Todays Outline
Programming Project #1 and Forming Teams
Brief Proof Reminder
Asymptotic Analysis, Briefly
Silicon Downs and the SD Cheat Shee
CS221: Algorithms and
Data Structures
Big-O
Alan J. Hu
(Borrowing some slides from Steve Wolfman)
1
Learning Goals
Define big-O, big-Omega, and big-Theta: O(), (), ()
Explain intuition behind their definitions.
Prove one function is big-O/Omega/Theta o
CPSC 221: Data Structures
Balanced BST (AVL Trees)
Alan J. Hu
(Using mainly Steve Wolfmans Slides)
Balance
Balance
t
5
height(left subtree) - height(right subtree)
zero everywhere perfectly balanced
small everywhere balanced enough
Balance between -1
CPSC 221
Basic Algorithms and Data Structures
A Sophomoric Introduction to Shared-Memory
Parallelism and Concurrency, Part 2
Analysis of Fork-Join Parallel Programs
Steve Wolfman, based on work by Dan Grossman
(with minor tweaks by Hassan Khosravi)
CPSC 2
CPSC 221
Basic Algorithms and Data Structures
Binary Search Trees
Textbook References:
Koffman: 8.1 8.4
EPP 3rd edition:11.5
EPP 4th edition:10.5
Hassan Khosravi
January April 2015
Borrowing many slides from Steve Wolfman
CPSC 221
Binary Search Trees
Page
Department of Computer Science
Undergraduate Events
More details @ https:/my.cs.ubc.ca/students/development/events
EA Info Session
CS Speed Mentoring &
Townhall Event
Thurs., Jan 15
5:30 pm
Rm X860, ICICS/CS Bldg.
Mon.,
CPSC 221
Basic Algorithms and Data Structures
Balanced BST (AVL Trees)
Textbook References:
Koffman:11.1, 11.2
Hassan Khosravi
January April 2015
(Borrowing many slides from Alan Hu and Steve Wolfman)
CPSC 221
Balanced BST (AVL Trees)
Page 1
Learning goal
CPSC 221
Basic Algorithms and Data Structures
Priority Queues and Heaps
Textbook References:
Koffman: 8.5
Hassan Khosravi
January April 2015
CPSC 221
Priority Queues and Heaps
Page 1
Learning Goals
Provide examples of appropriate applications for
priorit
CPSC 221
Basic Algorithms and Data Structures
ADTs, Stacks, and Queues
Textbook References:
Koffman: 4.5-4.7, 5, 6.1-6.3, 6.5
Hassan Khosravi
January April 2015
CPSC 221
ADTs, Stacks, and Queues
Page 1
Learning goals
Differentiate an abstraction from an
CPSC 221: Theory Assignment 1
Last Updated: January 25, 2017
Due: 9pm, Tuesday, February 7, 2017.
Submission Instructions
Submit your solutions using handin. You can write your solutions by hand and scan the pages
or take pictures of them with your phone;