Lecture 3, Jan 25, 17:
1) Big O
T(n) = O(f(n)
Is true if there exists some constants C and n0 such that the actual time
T(n) <= cf(n) for all n >= n0

While taking bigO, exclude lower order terms and constants

Big O of n means that youre specifying an
Data Structures in Java
Lecture 16: Sorting II
4/2/2015
Daniel Bauer
Quick Sort
Another divideandconquer algorithm.
Pick any pivot element v.
Partition the array into elements
x v and x v.
Recursively sort the partitions, then concatenate them.
34
8
64
Data Structures in Java
Lecture 18: Graphs.
4/9/2015
Daniel Bauer
Graphs
A Graph is a pair of two sets G=(V,E):
V: the set of vertices (or nodes)
E: the set of edges.
each edge is a pair (v,w) where
v,w V
Graphs
A Graph is a pair of two sets G=(V,E):
v1
Data Structures in Java
Lecture 17: Radix Sort.
4/7/2015
Daniel Bauer
ComparisonBased Sorting
Algorithms
TWorst
TBest
TAvg
Space
Stable?
Insertion Sort
Shell Sort
Heap Sort
Merge Sort
Quick Sort
*depends on increment sequence
gray entries: not shown in c
Data Structures in Java
Lecture 21: Spanning Trees
4/14/2015
Daniel Bauer
A General View of Graph
Search
Goals:
Explore the graph systematically starting at s to
Find a vertex t / Find a path from s to t.
Find the shortest path from s to all vertices.
Data Structures in Java
Midterm Review
3/10/2015
Daniel Bauer
Midterm
Midterm on Thursday (inclass)
Similar format to sample questions.
Closed books/notes/electronic devices (except
calculators).
Bring a pen, water, and nothing else.
60 minutes. Be on ti
Data Structures in Java
Lecture 23: Algorithm Design Techniques
4/23/2015
Daniel Bauer
Algorithms and Problem Solving
Purpose of algorithms: find solutions to problems.
Data Structures provide ways of organizing data
such that problems can be solved more
Data Structures in Java
Lecture 22: Applications of DFS
4/16/2015
Daniel Bauer
Homework Review Session
Review of homework 3 and 4
Wednesday 4/22, 5:307:30
608 Schermerhorn
Contents
Applications of DFS
Euler Circuits
Biconnectivity in Undirected Graphs.
F
Data Structures in Java
Lecture 23: Introduction to NPCompleteness
4/21/2015
Daniel Bauer
Algorithms and Problem Solving
Purpose of algorithms: find solutions to problems.
Data Structures provide ways of organizing data
such that problems can be solved m
Data Structures in Java
Lecture 3: Introduction to Analysis of Algorithms.
Recursion.
1/29/2015
Daniel Bauer
1
Goals of Algorithm Analysis
Does the algorithm terminate?
Does the algorithm solve the problem?
(correctness)
What resources does the algorithm
Data Structures in Java
Lecture 7: More Stacks. Queues.
2/12/2015
Daniel Bauer
1
Whats wrong with this program?
public class Factorial cfw_
public static int factorial(int n) cfw_
return factorial(n1) * n;
public static void main(String[] args) cfw_
Sys
Data Structures in Java
Lecture 2: Sequences and Series, Proofs
1/22/2015
Daniel Bauer
1
Algorithms
An algorithm is a clearly specified set of simple
instructions to be followed to solve a problem.
Algorithm Analysis Questions:
Does the algorithm terminat
Data Structures in Java
Lecture 12: Sets, Maps. Introduction to Hashing.
3/3/2015
Daniel Bauer
Homework
Homework 3 after spring break.
Homework 2 review session
Wednesday, 6:107:30pm, 633 Mudd
Midterm
Midterm next Thursday (inclass)
Closed books/notes/e
Data Structures in Java
Lecture 6: Stacks.
2/10/2015
Daniel Bauer
1
Homework 1 Due Tomorrow
Make sure to follow submission instructions. Put all files in
a compressed archive (zip. or tgz.)! Make sure filenames
are correct!
Upload your solutions by 23:59p
Data Structures in Java
Lecture 16: Sorting I
3/31/2015
Daniel Bauer
Sorting
Input:
8
64 51 32 21
Array containing unordered Comparables
(duplicates allowed).
Output: 8
34
21 32 34 51 64
A sorted array containing the same items.
Only comparisons between p
Data Structures in Java
Lecture 15: Heaps II
3/26/2015
Daniel Bauer
Implementing Heaps
http:/www.cs.columbia.edu/~bauer/cs3134/weeks/9/Heap.java
Building a Heap
Want to convert a collection of N items into a heap.
Simple approach:
Each insert(x) takes O(
Lecture 12:
Swag and other things brought to you by Paul Blaer


We want a self balancing binary tree so that when we add remove or perform ops we
want the tree to remain balanced so we can perform functions in efficient time
The most common self balanc
L4 Jan 30th
Homework 1
 Assignment due on Friday 4pm
 The sample code times thing in milliseconds  use nanoseconds  shows up as zero Add a dummy loop to x as a constant slowdown or use system.sleep()  make sure you
disable run time optimisation.
Cla
Lecture
Sorting
1. Disjoint sets will be covered in recitation
2. T(N) where T is the time of merge sort on an input list of N:
Say T(1) = 1, Assume N is a power of 2.
a. T(N) = 2*T(N/2) (2 calls to mergesort on the divided list) + N(merge)
[Master Theore
Exam Stuff :
 Nothing specially tricky except 1 q
 Straightforward cover all material
 Will be long to too long
 No MCQs, Short answer questions close to definitions
 Figure the output, state the name of the algorithm type stuff
 Short answers : Req
COMS W3134
Sample Midterms Solutions
Linan Qiu and Daniel Bauer
March 10, 2015
Question 1.
Part (a).
True If f (x) = (g(x) then
f (x)
g(x)
=c
is defined such that if T (N ) = (f (N ), then
T (N ) = O(f (N )
T (N ) = (f (N )
These each mean that
T (N ) cf
12 questions: 150 points
Not rushed
Question 1: Induction proof on a graph, Proof by counterexample  pr
 Could be on a tree since trees are subsets of graphs
Question 2: AVL Tree balancing problem  done
Question 3: Big O notation definitions and costs
Lecture 10
Programming Assignment #3 due Tues, 3/25
Midterm on Thurs, 3/27
Note on Programming Assignment #2:
should print flipped on side:
d
b
a
c
a
b
c
d
Operands in operation tree: +  * /
(will be clarified in an email)
AVLs
Code from 2nd edition:
pri
Data Structures in Java
Lecture 4: ADTs. Array and Linked Lists.
2/3/2015
Daniel Bauer
1
Contents
1. Abstract Data Types
2. Array Lists and Linked Lists
Data Types
Basic data types: booleans, bytes, integers,
floats
Simple abstractions: Array, String
More
Data Structures in Java
Lecture 5: ADTs in Java.
2/5/2015
Daniel Bauer
1
Outline
Some Java features useful for implementing Data
Structures.
Generics, Interfaces, Nested classes.
Iterator, Iterable from the Java API.
Implementation of Linked List.
Lists i
Data Structures in Java
Lecture 10: AVL Trees.
2/24/2015
Daniel Bauer
Height of a Tree
height = 3
A
B
C
D
E
Height of tree T: the length (= number of edges on the
path) of the longest path from root to any leaf.
F
Worst and Best Case Height
of a Binary Se
Data Structures in Java
Lecture 14: Introduction to Priority Queues (Heaps)
3/24/2015
Daniel Bauer
Homework 3
Out tonight (Tuesday March 24th).
Due Thursday April 2nd.
Topics:
Balanced trees, hashing, heaps.
Implementing and using maps.
The Queue ADT
A Qu
Data Structures in Java
Lecture 11: BTrees.
2/26/2015
Daniel Bauer
Review: Binary Search Trees
BST property:
For all nodes s in Tl, sitem < ritem.
For all nodes t in Tl, titem > ritem.
r
Tl
Tr
To keep BST operations (search/insert/delete/findMin/
findM
Data Structures in Java
Lecture 9: Binary Search Trees.
2/19/2015
Daniel Bauer
1
Contents
1. Implementation of BinaryTree
2. Binary Search Trees
3. Comparables in Java
Barebones Implementation
of a Binary Tree
http:/www.cs.columbia.edu/~bauer/cs3134/week
Data Structures in Java
Lecture 13: Hashing: Collision Resolution.
3/5/2015
Daniel Bauer
Hash Table Collisions
Problem: There is an infinite number of keys, but only TableSize
entries in the array.
Need to find a hash function that distributes items in th
Submit Assignment
Homework 1
Due Friday by 4pm
Points 100
Submitting a file upload
Available Jan 22 at 12am  Feb 7 at 11:59pm 17 days
File Types zip
COMS W3134 Spring 2017 (Sections 1 and 2)
Homework 1
Due: 4:00pm on Friday, February 3
This homework has
Submit Assignment
Homework 3
Due Mar 22 by 11:59pm
Points 100
Submitting a file upload
Available Mar 1 at 12am  Mar 27 at 11:59pm 27 days
File Types zip
COMS W3134 Spring 2017
Homework 3
Due: 11:59pm on March, 22nd
Written (35 pts)
For the written sectio
Submit Assignment
Homework 4
Due Apr 13 by 11:59pm
Points 100
Available until Apr 17 at 11:59pm
Submitting a file upload
File Types zip
COMS W3134 Spring 2017
Homework 4
Due: 11:59pm on Thursday, April 13th
Written (30 pts)
For the written section of this
Submit Assignment
Homework 5
Due May 1 by 11:59pm
Points 100
Submitting a file upload
Available Apr 16 at 12am  May 4 at 11:59pm 19 days
File Types zip
COMS W3134 Spring 2017
Homework 5
Due: 11:59pm on Monday, May 1st
Written (48 pts)
For the written sec
Submit Assignment
Homework 6
Due Thursday by 11:59pm
Points 100
Submitting a file upload
Available Apr 16 at 12am  May 4 at 11:59pm 19 days
File Types zip
COMS W3134 Spring 2017
Homework 6
Due: 11:59pm on Thursday, May 4
Written (30 pts)
For the written