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
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
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: B-Trees.
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
Bare-bones Implementation
of a Binary Tree
http:/www.cs.columbia.edu/~bauer/cs3134/week
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(
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 16: Sorting II
4/2/2015
Daniel Bauer
Quick Sort
Another divide-and-conquer 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
Comparison-Based 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 (in-class)
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:30-7:30
608 Schermerhorn
Contents
Applications of DFS
Euler Circuits
Biconnectivity in Undirected Graphs.
F
Data Structures in Java
Lecture 23: Introduction to NP-Completeness
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 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 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
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
Lecture :
1. Total edges across all vertices is magnitude E
2. Breadth-First Traversal is a way of going thru trees row by row
Shortest Paths :
- Dijkstra
Lecture
Binary heaps - Build heap operation :
1. When you give a completely unordered array and thats made a valid build-heap.
a. Just keep running inserts - n elements translates to n inserts
b. This takes N-Log(N) time to run as the percolate-up takes l
Data Structures in Java
Lecture 3: ADTs in Java.
9/16/2015
Daniel Bauer
1
Today
ADTs and Data Structures in Java (Generics,
Interfaces etc., Java Standard Library)
Linked List Implementation.
Binary Search Example.
Recitation Sessions
Tuesday 7:30pm, 413
Data Structures and
Algorithms
Session 14. March 9, 2009
Instructor: Bert Huang
http:/www.cs.columbia.edu/~bert/courses/3137
Announcements
Homework 3 is due
Solutions 1 hour after class
Course Evaluation
Midterm Exam March 11th
Review
Clarification about
Data Structures and
Algorithms
Session 27. May 4th, 2009
Instructor: Bert Huang
http:/www.cs.columbia.edu/~bert/courses/3137
Annoucements and
Todays Plan
Final Exam Wednesday May 13th, 1:10 PM - 4 PM
Mudd 633
Course evaluation
Review 2nd half of semester
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 counter-example - 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
COMS3134 Data Structures and Algorithms
Spring 2017 Section 2 Midterm Solutions
1.
Let k be the height of a full binary tree.
Base case: if k = 0, N = 1. So the claim holds true for our base case.
Inductive hypothesis: assume the claim holds true for some
COMS W3134 Data Structures in Java Section 2
Midterm Exam, Spring 2017
NAME:_
UNI:_
There are 7 questions on this exam totaling 100 points. The exam is closed book and closed
notes. No calculators or computers are allowed. You will have 75 minutes to comp
COMS3134 Data Structures and Algorithms
Spring 2017 Section 1 Midterm Solutions
1.
Let k be the height of the perfect binary tree.
Base case: if k = 0, N = 1. So the hypothesis holds true for our base case.
Hypothesis: assume the claim holds true for some
COMS W3134 Data Structures in Java Section 1
Midterm Exam, Spring 2017
NAME:_
UNI:_
There are 7 questions on this exam totaling 100 points. The exam is closed book and closed
notes. No calculators or computers are allowed. You will have 75 minutes to comp