Data Structures (CS 102), Professor Yap Spring 2015
FINAL
May 13, 2015
QUESTION 1.
SHORT QUESTIONS (56 Points. Each Part is 7 Points)
(a) T/F: the following code is acceptable to Java:
class AA cfw_
public int f(int n) cfw_ return n+2;
public void f(int

Data structures
Lecture 10
March 7
Reminder
Monday, March 21 - Midterm review
Come with questions!
Tuesday, March 22 - Midterm review
Come with more questions!
Wednesday, March 23 Midterm exam
Linked Lists
The list has a head. This is just the referen

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
October 6, 2015
Homework 3: Due on Tue Oct 13
This homework is worth 100+5 Points.
From now on, you are disadvantaged if you do not know how to test your Java programs
directly from the Terminal

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
November 20, 2015
Homework 6: Due on Tue Dec 1, 2015
HAPPY THANKSGIVING to the Class!
This homework is worth 120+5 Points.
Carefully read the instructions for homework submission in
http:/cs.ny

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
October 14, 2015
Homework 4: Due on Tue Oct 20
This homework is worth 100+5 Points.
Carefully read the instructions for homework submission in
http:/cs.nyu.edu/~yap/wiki/class/index.php/DataStru

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK SOLUTION
December 19, 2015
Solution to Homework 8
This is the last homework of the course. It is a self-study for the final exam.
You do not submit your solution for grading. We suggest writing

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK SOLUTION
October 6, 2015
Solution to Homework 3
This homework is worth 100+5 Points.
From now on, you are disadvantaged if you do not know how to test your Java programs
directly from the Termin

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK SOLUTION
December 16, 2015
Solution to Homework 7
This homework is worth 146+5 Points.
Carefully read the instructions for homework submission in
http:/cs.nyu.edu/~yap/wiki/class/index.php/DataS

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK SOLUTION
October 20, 2015
Solution to Homework 4
This homework is worth 100+5 Points.
Carefully read the instructions for homework submission in
http:/cs.nyu.edu/~yap/wiki/class/index.php/DataSt

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK SOLUTION
November 16, 2015
Solution to Homework 5
This homework is worth 127+5 Points.
Carefully read the instructions for homework submission in
http:/cs.nyu.edu/~yap/wiki/class/index.php/DataS

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
September 4, 2015
Homework 1: Due on Thursday Sep 10, 2015
This homework is worth 85+5 Points.
Please get started IMMEDIATELY because you will need several pieces of software:
make program, some

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
November 2, 2015
Homework 5: Due on Tue Oct 11, 2015
This homework is worth 127+5 Points.
Carefully read the instructions for homework submission in
http:/cs.nyu.edu/~yap/wiki/class/index.php/Da

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK SOLUTION
December 12, 2015
Solution to Homework 6
HAPPY THANKSGIVING to the Class!
This homework is worth 120+5 Points.
Carefully read the instructions for homework submission in
http:/cs.nyu.e

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
September 23, 2015
Homework 2: Due on Thur Oct 1, 2015
This homework is worth 100+5 Points.
From this homework onwards, you would be disadvantaged if you do not know how to
test your Java progra

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
September 22, 2015
Homework 1: Due on Thursday Sep 10, 2015
This homework is worth 85+5 Points.
Please get started IMMEDIATELY because you will need several pieces of software:
make program, som

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
September 23, 2015
Homework 2: Due on Thur Oct 1, 2015
This homework is worth 100+5 Points.
From this homework onwards, you would be disadvantaged if you do not know how to
test your Java progra

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
December 8, 2015
Homework 7: Due on Dec 15, 2015
This homework is worth 146+5 Points.
Carefully read the instructions for homework submission in
http:/cs.nyu.edu/~yap/wiki/class/index.php/DataSt

Data Structures (CS 102), Professor Yap Fall 2015
HOMEWORK
December 17, 2015
Homework 8: Posted on Dec 17, 2015
This is the last homework of the course. It is a self-study for the final exam.
You do not submit your solution for grading. We suggest writi

Data structures
Lecture 11
March 28
Evaluating arithmetic expressions
Goal: write a program to evaluate an arithmetic
expression? For example
( ( ( 16 / ( 8 ( 2 + 2 ) ) ) 3) ( 2 + ( 1 1 ) ) )
We need to evaluate all subexpressions, and
then apply the co

Data structures
Lecture 7
February 22
Sorting Algorithms
Sorting Algorithms
When discussing recursion we talked about the Merge
Sort algorithm.
Today we will review other sorting algorithms.
Quadratic Sorts:
Bubble Sort
Selection Sort
Insertion Sort

Data structures
Lecture 2
January 27
Reference Variables
MyClass mc = ;
The variable mc is a reference variable that stores the
memory address of the object it point to.
When invoking a method with parameter mc
foo(mc)
we are sending the address of the

Data structures
Lecture 4
February 3
Big-O notation
We will use the Big-O notation to express the
complexity (running time) of a program.
If for inputs of size N the running time of a program is
f(N), the big-O notation will be represented by the
term t

Data structures
Lecture 3
February 1
Recursion
Recursion is a powerful tool for solving certain kinds
of problems.
Recursion breaks a problem into smaller problems
that are, in some sense, identical to the original, in
such a way that solving the smalle

Data structures
Lecture 8
February 29
Abstract Data Structures (ADT)
What is abstraction?
A model of a system used to describe only the details
needed by the user of the system.
Hides implementation details, and focuses only on the
functionality.
An a

Data structures
Lecture 6
February 17
Another example of Generics
Recall the syntax
class MyArray <E> cfw_
public static <E> int findElement (ArrayList<E> a , E elt ) cfw_
public static <E extends Comparable<E> void mergeSort(ArrayList<E> a) cfw_
Lets s

Data structures
Lecture 5
February 10
Comparing Objects
We discussed searching/sorting an array of integers.
But we may want to search/sort arrays of other
classes
To be able to do it we need a way to compare two
objects. For this we will use:
1. The m