CSCI-UA 102 (Data Structures)

GTG = Data Structures and Algorithms in Java, Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser,
ODSA = Open DSA

end of chapter problems to look at

Date
Material Covered, Notes, Handouts and Links
Readings, Assignments, Homework

Mon, 12/17

Final exam, Dec. 17, 2:00pm - 3:50pm.

Class #28
Wed,12/12

Q&A for the final exam.

Come with questions.

Problem sets:

These problem sets are for the purpose of review for the final. You should attempt the problems before looking at the solutions.

Topics to review for the final:

  • advanced Java topics
    • inheritance and polymorphism
    • interfaces and abstract classes
    • exception handling
    • generics
  • lists (array based and reference based implementation)
  • stacks and queues (array based and reference based implementation)
  • recursion
  • general trees (node structure, abstract view of the tree and the actual linkage between nodes, implementation of methods that traverse all or part of the tree)
  • binary trees
  • priority queue, heap (how it works, no implementation)
  • search trees
    • binary search tree
  • iterators for lists and trees
  • sort algorithms: mergesort, quicksort
  • basics of hash tables (how it works, no implementation)
  • performance results for all the discussed data structures and algorithms, big-O notation

Book sections that you are responsible for:

(Note, there may be parts in these sections that we did not discuss in class explicitly, or for which we used a different implementation.)

  • chapter 1: all sections
  • chapter 2: all sections
  • chapter 3: all sections
  • chapter 4: only parts related to big-O notation, no proofs
  • chapter 5: sections 2 through 5
  • chapter 6: sections 1, 2
  • chapter 7: sections 1, 2, 4, 5, 6
  • chapter 8: all sections (skip array-based representation of binary tree, and breadth-first traversal)
  • chapter 9: sections 1-3 (you are not responsible for knowing how to implement it, but you should be able to read the code that implements it)
  • chapter 11: section 1
  • chapter 12: sections 1, 2
  • chapter 10: sections 1, 2 (very lightly)

Class #27
Mon,12/10

Hash tables.

hash tables notes

Recitation
Tue,12/11 (sec. 6 and 9)
Thu,12/13 (sec. 10)

Class #26
Wed,12/05

Sorting: quicksort (algorithm, implementation, performance).

Reading: sections 10.1 and 10.2

Class #25
Mon,12/03

Sorting: review of quadratic sorts, merge sort (algorithm, implementation, performance).

sort notes

Recitation
Tue,12/04 (sec. 6 and 9)
Thu,12/06 (sec. 10)

Class #24
Wed,11/28

Finish with binary search trees.

Reading: sections 12.1, 12.2 and 12.4

Class #23
Mon,11/26

Project 6 - discussion.

Implementation of the remove operation for the binary search tree.

Project 6 posted, due Dec. 5 at 11:55pm.

Wed, 11/21 - Sun, 11/25

Thanksgiving recess - no classes scheduled.

Recitation
Tue,11/27 (sec. 6 and 9)
Thu,11/29 (sec. 10)

Binary Search Trees instructions , worksheet

Class #22
Mon,11/19

Adding elements to the binary search tree: recursive and iterative implementations.

Removing elements from the binary search tree: how does it work for leaves, nodes with one child, nodes with two children.

Recitation
Thu,11/15 (sec. 10)
Tue,11/20 (sec. 6 and 9)

Priority Queues instructions , worksheet

Class #21
Wed,11/14

Introduction to binary search trees. Searching for a value in a binary search tree (algorithm, recursive vs iterative implementations, performance analysis).

BST notes

Reading: chapter 11 (section 1)

Class #20
Mon,11/12

Priority queues, heaps, heap properties (invariants), adding values to a binary heap, removing values from a binary heap.

Reading: chapter 9 (concentrate on how it works, not how it is implemented in the chapter)

Recitation
Thu,11/08 (sec. 10)
Tue,11/13 (sec. 6 and 9)

Binary trees instructions , worksheet

Class #19
Wed,11/07

Introduction to tree and binary tree data structure. Node structure for a binary tree. Writing functions that calculate the size of a binary tree (recursive and iterative algorithms).

tree notes

Project 5 posted:

Readings: chapter 8 (can skip 8.3, or read it lightly), start reading chapter 9 (concentrate on how it works, not how it is implemented).

Class #18
Mon,11/05

Finish with recursion. Calculating size of a linked list recursively. Designing a recursive method to add a node to a linked list.

Mon, 11/05

Last day to withdraw from classes with a W.

Recitation
Thu,11/01 (sec. 10)
Tue,11/06 (sec. 6 and 9)

Magic of Recursion instructions , worksheet

Class #17
Wed,10/31

Basics or recursive backtracking: generating all binary sequences with a given length, generating binary sequences with a given length that meet a particular restriction (ex., no zero bit in the second position).

Think about: how to generate decimal sequences?, how to generate alphabetic sequences?

Class #16
Mon,10/29

Introduction to recursive functions. What makes a function recursive? Base case. Error handling / parameter validation in recursive functions. Examples of recursive functions: calculating sum of digits in a positive number, calculating a^n using O(n) and O(long n) algorithms, factorial calculation, Fibonacci sequence calculation (and why it is very inefficient to do it using recursion), determining if a string is a palindrome.

recursion notes

Reading chapter 5.

Recitation
Thu,10/25 (sec. 10)
Tue,10/30 (sec. 6 and 9)

Interview questions instructions , worksheet

Class #15
Wed,10/24

Finish with array-based and linked-based implementation of a queue.

Look at the sample code providing array-based implementation of stack and queue ADTs.

Project 4 (due date Nov. 3 at 11:55pm):

Familiarize yourself with the following code. Once you decide that you understand the code (how it works, what it does, how the particular abstract data types are implemented, what the performance is, …), you will take a quiz on NYU Classes that is based on the code. You should use the Javadoc documentation as well as the source code files for Java API that you downloaded at the beginning of the term. It is replicated for you in pdf and source code format below.

Classes that implement stack and queue ADTs in Java API:

  • ArrayDeque: pdf source code
  • LinkedList: pdf source code
  • Queue: pdf source code
  • Stack: pdf source code
  • Vector: pdf source code
  • Code provided as application examples for stack and queues in the textbook:
    • The source code for solving matching parentheses and HTML tags in section 6.1.5 in the textbook.
    • The source code for Josephus class in section 6.2.4 in the textbook.

(The quiz will be available on NYU Classes a few days before the due date.)

Class #14
Mon,10/22

Stacks: abstract data type, operations: add/push, remove/pop, top.

Queues: abstract data type, operations: add/enqueue, remove/dequeue.

Efficient array based implementation for stack and queues (all operations should be O(1)).

Efficient reference (linked-list) based implementation for stacks.

Reading: chapter 6.

Recitation
Thu,10/18 (sec. 10)
Tue,10/23 (sec. 6 and 9)

Test driven development (TDD) instructions , worksheet

Class #13
Wed,10/17

Algorithmic analysis: big-O notation. Array based list and linked-list performance analysis.

Reading: chapter 4 (concentrate on big-O, no proofs required

  • although they will come in handy for the next course).

Class #12
Mon,10/15

Midterm exam.

Recitation

Thu,10/11 (sec. 10)
Tue,10/16 (sec. 6 and 9)

Debugging.

slides from the recitation

Other materials:

Class #11
Wed,10/10

Q&A for midterm exam.

Come with questions.

Class #10
Tue,10/09

Legislatie day: classes follow Monday schedule

Equivalence testing and cloning data structures.

Read 3.5, 3.6.

Mon, 10/08

Fall recess - no classes scheduled.

Recitation
Tue,10/02 (sec. 6 and 9)
Thu,10/04 (sec. 10)

Iterating over things.

Iterating over things instructions , worksheet

Class #9
Wed,10/03

Iterators.
Collection and List interfaces in Java.

list notes

Read section 7.4 and 7.5.

Project 3 posted, due Oct. 13 at 11:55pm.

Class #8
Mon,10/01

Linked list: adding / removing elements, retrieving elements stored at a particular "index", efficiency concerns.

Recitation
Tue, 9/25 (sec. 6 and 9)
Thu, 9/27 (sec. 10)

ArrayList - case study: instructions , worksheet



Extra credit (due Sept. 29 ):

(This should be done individually, not as a group activity.)

The following program attempts to read two numbers from the command line (specified as the command line arguments to the program) and calculate their sum. It turns out this program ignores possibility of many errors. If you submit it to the autograder on Gradescope, you will see that it fails most of the tests.

You task is to fix the code so that it passes all of the test. This time around, you can see all of the feedback from the autograder, so you can work with that. But, it is a better idea to try to fix it on your own and only when you are certain that it handles all the possible problems, submit it to be tested.

Class #7
Wed, 9/26

Linked lists. Node structure and node manipulation. Calculating size of a linked list; iterating over a list; recognizing the end of a linked list; special case of an empty list.

Reading chapters 3 and 7 (lightly about PositionalList).

Class #6
Mon, 9/24

Continue with an array-based implementation for the List ADT. Case study of ArrayList<E> class.

Project 2 is posted. Due: Oct. 3 at 11:55pm.

Reading chapters 3 and 7.

Recitation
Tue, 9/18 (sec. 6 and 9)
Thu, 9/20 (sec. 10)

Finding code responsible for behavior: instructions , worksheet

source code for OpenJDK 10 - this is the source for Java classes. In this recitation, you will start looking at some of the files. We will continue using these files throughout the semester.


Class #5
Wed, 9/19

Input stream buffering. How do nextLine(), next(), nextInt(), … functions of the Scanner class differ. How to handle not well behaved users.

List ADT. How is ArrayList<E> implemented.

  • finish up with project 1
  • Reading: chapter 3

Mon, 9/17

Last day to drop classes without W.

Class #4
Mon, 9/17

Continue with code examples.

Polymorphism, dynamic binding, abstract classes.

Recitation
Tue, 9/11 (sec. 6 and 9)
Thu, 9/13 (sec. 10)

Writing bullet-proof code: instructions , worksheet



Extra credit (due Sept. 19 ):

(This should be done individually, not as a group activity.)

Last week you worked on solving several problems and using the CodeBat autograder/autotester to verify if your solution was correct. In more realistic situations, there is no such tester. The programmer needs to be able to convince themselves that their work is correct.
This semester we will be using an autograder on Gradescope to give you hints about your program's correctness. At first, you will see all of the tests and see if they passed or not. As the semester progresses, you will not be given the individual tests anymore.
As a practice for this, there is an exercise on Gradescope with 20 test cases, but you will not see the tests themselves. Each test is worth 0.05 points, so this can give you a hint as to how many tests passed and how many failed.

The problem for which you need to write a solution is as follows:

Write a function, that given a string, returns the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more digit chars in a row. (Note: Character.isDigit(char) tests if a char is one of the chars '0', '1', .. '9'. Integer.parseInt(string) converts a string to an int.)

  • sumOfNumbers("abc123xyz") should return 123
  • sumNumbers("aa11b33") should return 44
  • sumNumbers("7 11") should return 18
  • sumNumbers("hello") should return 0

You should implement your code in the following template:

Class #3
Wed, 9/12

Quiz 1.

Continue with advanced Java topics: inheritance, constructor chaining, overloading vs. overriding.

Review of code examples.

Class #2
Mon, 9/10

Advance Java concepts: reference variables vs. objects, inheritance, this vs. super, constructor chaining, …

Lecture 1 notes

PythonTutor visualization of the code examples

Read chapters 1 and 2 in GTG.

Work on chapter problems for chapters 1 and 2 (see above for the listing).

Project 1: Reading and understanding code. Due Sept. 22, 11:55pm.
Familiarize yourself with the following code. The three files provide a simple implementation of a color converter (CSS named colors, RGB values, hex-representation). Once you decide that you understand the code (how it works, what it does, how the three classes interact, how the user interaction happens, how the file I/O works, …), you will take a quiz on NYU Classes that is based on the code. (For the purpose of the quiz, you will use the line numbering in the PDF documents of the code, but you should use the actual code to run it and experiment with it.)

(The quiz will be available on NYU Classes at the end of this week.)

Class #1
Wed, 9/05

Introduction to the class. Syllabus. What do software engineers do.

Recitation
Tue, 9/04 (sec. 6 and 9)
Thu, 9/06 (sec. 10)

You should have been invited to complete registration for:

  • Poll Everywhere, follow student's guide instructions to register, if you did not get the invitation; use joannakl@cs.nyu.edu email address for your instructor
  • Gradescope, you can self register using code ME7J6D, if you did not get the invitation
  • Piazza, you can self register, if you did not get the invitation

Warm-up activity: instructions , worksheet


Once you complete the activity, download it in PDF format: File -> Download As … -> PDF Document (pdf)

The completed PDF file should be submitted to Gradescope for grading (only one person from your group needs to submit the activity; you will have a chance to enter the names of all group members once you upload the file).

Here are quick steps for uploading to Gradescope:

  • Go to gradescope.com and log in with you NYU email address (the version that contains your NetID).
  • On your Courses page, select the course for which you’re submitting work.
  • On your Courses page, you will see all of your current assignments. Click on the assignment you are turning in.
  • Click Submit PDF > Click Select PDF > locate the correct file on your computer > Click Upload PDF
  • (When activity has multiple parts) Tell us which pages correspond to each part/question on the assignment. You will see a list of all the assigned parts/questions, and images of all your document pages. For each question click the page(s) that contains your answer.
  • Finally, add the group members to the submission: on the right hand side under the name of the person who submitted the assignment, you should see "Add Group Members" link. Use it to add up to 3 more student names to the submission. (If you skip this step the other group members won't get credit for their work.)

Submitting work on Gradescope

Make sure that you add all of your group members to the submission on Gradescope - it is not enough to have their names in the pdf.