Practice Midterm
Here are some typical questions. I did not consider the length of the practice exam. I
definitely do consider the length when writing a real exam.
Recursion
What is the output when the following program is run?
public class Output cfw_
pu
Courant Institute of Mathematical Sciences
Department of Computer Science
Anasse Bari, Ph.D.
Trees as a Data Structure
Read Ch. 8 p.531 and Ch. 9.3, p. 633
Outline
A Quick Introduction to Graphs (A tree
is a special case of a Graph)
Definition of Trees
Ro
A. Bari
New York University
Computer Science Department
Data Structures
Dr. Anasse Bari
Homework Four: Serving Customers.
Deadline: See NYUclasses for the deadline, 15% off per day after the deadline (4 days
maximum).
Learning Objectives:
Implementing Que
New York University
Computer Science Department
Data Structures
Dr. Anasse Bari
Homework Three: Practical Application to Sorting
Deadline: See NYUclasses for the deadline, 15% off per day after the deadline (4 days
maximum).
Learning Objectives:
Observing
New York University
Computer Science Department
Data Structures
Dr. Anasse Bari
Homework Two: Recursion, Searching, and Sorting Algorithms
Deadline: See NYUclasses for the deadline, 15% off per day after the deadline (4 days
maximum).
Learning Objectives:
New York University
Computer Science Department
Data Structures
Dr. Anasse Bari
Homework Five: Binary Search Trees
Deadline: See NYUclasses for the deadline, 15% off per day after the deadline (4 days
maximum).
Learning Objectives:
Learning how to design
Introduction to Graphs
Anasse Bari | Computer Science Department
Community Detection in Twitter
a Community of Twitter Users
Detect Online
Social Communities
Find Most Influential
Users
Detect Community
Outliers
Detect Community
Leaders
Community Detectio
CS102 Dr. Anasse Bari
Linked Lists Part II
Queues, Stacks and Postfix, and Infix
QUEUES
A data structure that stores a list of items
Items are always added at the end of the list
Items are always removed from the start of the list
Add items
here
ITEM
Remo
C:\Users\anasse\Desktop\Spring2016\CS102_Spring2016\7.Chapter#6_LinkedLists\LinkedListPractice\CodeLinkedList\QLinkedList.java
/*this is just a snapshot (one possibility) of how you can implement
a queue using a Linked-list and generic types.
you might ne
Courant Institute of Mathematical
Sciences
Department of Computer Science
CS102 Data Structures
Recitation Eight
Objectives
Solution for Lab 6 and 7
Linked List
2
Lab 6
Quick sort and merge sort
Need to make a copy of the original array
Create private
Courant Institute of Mathematical
Sciences
Department of Computer Science
CS102 Data Structures
Recitation Six
Objectives
O(n log n) Time Sorting
Merge Sort
Quick Sort
Comparable<T> interface
2
Part 1: Merge Sort
Remove the descendingSort method from
Iso
Courant Institute of Mathematical Sciences
Department of Computer Science
Anasse Bari, Ph.D.
Chapter Five:
Searching and Sorting Algorithms
Learning Outcomes
Reviewing linear search and binary search
Learning about major sorting algorithms (bubble sort,
Copyright
2
These slides belong to Pr. David Laidlaw from Brown
University
DATA STRUCTURES
CSCI-SHU210
Lecture 4 Analysis of Algorithms
Outline
3
How fast is your algorithm?
4
1.
2.
3.
Running time and theoretical analysis
Big-O notation
Big- and Big-
Wh
Slide Copyrights
2
Pr J. Vergara, Ateneo De Manila University
! Pr S. Gray, College of Wooster
! Pr G. Abecasis, University of Michigan
! Pr D. Matuszek, University of Pennsylvania
! Pr B. Abeysekera, University of Houston Clear Lake
!
DATA STRUCTURES
CSC
3-way partitioning
2
!
Dutch National Flag (DNF) problem
Edsger Dijkstra
!
!
Random arrangement of N colored balls
cfw_blue, white, red
Write an algorithm that arranges the balls
! All
balls of the same color together
groups in the cfw_blue, white, red or
Notion of Sorting
2
Input
Array containing unordered Comparables
Duplicates are allowed
Output
A sorted array containing the same items
DATA STRUCTURES
CSCI-SHU210
Comparison based sorting
Only two operations allowed
n
n
Comparison between a pair of items
Copyright
2
These slides are a mix from original slides that belong to:
Pr.
Chokchai Leangsuksun from Louisiana Tech University
Pr. Qiang Yang from HKUST
Pr. David Matuszek from the University of Pennsylvania
Pr. Marty Stepp from Stanford University
D
Copyright
2
These slides are a mix from original slides that belong to:
! Pr.
David Matuszek from the University of Pennsylvania
! Pr. Mike Scott from the University of Texas at Austin
DATA STRUCTURES
CSCI-SHU210
Lecture 7 Abstract Data Types
Data types
3
Copyright
2
These slides are an edited version of original slides that
belong to:
!
!
Pr. Chokchai Leangsuksun from Louisiana Tech University
Pr. Evan Korth from NYU
DATA STRUCTURES
CSCI-SHU210
Lecture 9 Recursion
Definition
3
Triangular Numbers
4
!
Progr
Overview of Stacks and Queues
2
!
Arrays allow unrestricted access
!
Conceptual tools enforce access restrictions
Defined primarily by their interface
Set of permissible operations
Implementation is of little interest to the user
Array, Linked List, Heap,
Getting started
2
!
This is merely an introduction to Java
programming
We will skim through many topics, Advanced OOP in
particular
DATA STRUCTURES
CSCI-SHU210
!
What you need is. JDK
Download & Installation instructions available on
NYUClasses
Lecture 2
Overview of Arrays
2
!
Collection of data items that can be selected by indices
Static arrangement of items in memory
Equally spaced addresses
Computable at runtime
!
DATA STRUCTURES
CSCI-SHU210
Most commonly used data storage structure
Linear (one-dimens
Courant Institute of Mathematical
Sciences
Department of Computer Science
CS102 Data Structures
Recitation Seven
Objectives
Binary Search
Recursive Methods Revisit
2
Recursive Binary Search
In this exercise you will need to
implement a recursive binary
Courant Institute of Mathematical
Sciences
Department of Computer Science
CS102 Data Structures
Recitation Nine
Objectives
Linked List
2
Plus One
Given a non-negative number represented as a singly
linked list of digits, plus one to the number. The digit
Joanna Klukowska
[email protected]
CSCI-UA 102
DNHI Homework 4
DNHI Homework 4 Solutions
Searching and Sorting
Problem 1
Given the IntegerQueue ADT below state the return value and show the content of the, initially empty, queue of Integer objects after
Courant Institute of Mathematical Sciences
Department of Computer Science
CS102 Data Structures
Recitation One
Quiz 1 Solutions
1) From Dale, Joyce, Weems: The implementation of organized
data
2) Overriding means changing the method of a parent class
with
A wildcard describes a family of types. There are 3 different flavors of wildcards:
" ? " - the unbounded wildcard. It stands for the family of all types.
" ? extends Type " - a wildcard with an upper bound. It stands for the family of
all types that ar
Generic types and methods have formal type parameters, which are replaced by actual
type arguments when the parameterized type or method is instantiated.
Example (of a generic type):
class Box <T> cfw_
private T theObject;
public Box( T arg) cfw_ theObjec
Practice Final
Here are some typical questions. I did not consider the length of the practice exam. I
definitely do consider the length when writing a real exam.
The real final will be cumulative and cover material from the entire semester.
However, this