CS5403 Data Structures and Algorithms
Assignment 2
Assigned date: 02/13/2014
Due date: 02/20/2014
Please include your name in your source file
Do not use a separate header file, application file and i

CS 5403 Data Structures and Algorithms
Midterm - Spring 2014
Notes:
This is an open-book, open-notes exam. Both hardcopy and digital
books/notes are allowed.
Internet browsing is NOT allowed. You may NOT use any ki

CS 5403 - Lecture 7
CS 5403 Lecture 7
Templates
Templates
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Templates
Templates
Enable code reuse in a more seamless way than
the type define statements used in B

CS 5403 - Lecture 3
CS 5403 Lecture 3
Point Class
Point Class
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Point Class
Point Class
A class to represent a point in two dimensional space
y axis
p1(4, 2)
x ax

CS 5403 - Lecture 1
CS 5403 Lecture 1
Software Development
Software Development
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Focus of the Course
Focus of the Course
Data Structure is an organized collectio

CS-GY6033 Homework 2
(Due March 7, 2016)
All problem/exercise numbers are for the third edition of CLRS text book
.
1. Apply the bubble sort and insertion sort to an inverted array [9, 7, 5, 3, 1], show all intermediate results. [1 point]
2. Exercise 2.3-

Chapter 1: The Nature of Statistics
Section 1.1
1. The steepest negative slope in the graph is between the years 1994 and 1995.
3.
(a) About 36,000,000. Actual answer: 36,132,147.
(b) About 7600. Actual answer: 7594.
5.
About 5400. Actual answer: 5428.
7.

Chapter 6: Probability Distributions
Note to instructors and students: Some answers may differ by 1 or 2 in the last digit
depending on whether you round for intermediate steps or wait until you get the final answer
to round. Also, different software and

We can now use Bayes formula to compute various posterior probabilities. The computer program
Bayes computes these posterior probabilities. The results for this example are shown in Table 4.4. We
note from the outcomes that, when the test result is +, the

CS 5403 - Lecture 2
CS 5403 Lecture 2
Class Design
Class Design
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Class Design
Class Design
Focus of this lecture is on learning how to
Design classes
Implement c

CS 5403 - Lecture 6
CS 5403 Lecture 6
Linked Lists
Linked Lists
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Linked List
Linked List
Is a fundamental data structure which will be used
throughout this cours

/
/
/
/
/
/
/
main.cpp
hw2
Created by Fangzhou Liu on 16/2/15.
Copyright 2016 Fangzhou Liu. All rights reserved.
#include
#include
#include
#include
<iostream>
<cstdlib>
<string>
<sstream>
using namespace std;
struct Nodecfw_
typedef int Item;
Item num;
N

Final
double linked-list
/*
QUESTION 1.
Given a pointer to an arbitrary element in a doubly-linked list, write a
method which moves the element to the head of the list. Your method
should be written as a member function of the class list<Object> (Figure
1

Red Black Trees
Top-Down Deletion
Recall the rules for BST deletion
1. If vertex to be deleted is a leaf, just delete
it.
2. If vertex to be deleted has just one child,
replace it with that child
3. If vertex to be deleted has two children,
replace the va

CS 5403 - Lecture 10
CS 5403 Lecture 10
Recursion
Recursion
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Recursion
Recursion
Recursive function a function that calls itself
Used to solve complicated probl

CS 5403 - Lecture 8
CS 5403 Lecture 8
Stacks
Stacks
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Stacks
Stacks
Adding a book
Removing a book
War and Peace
Leo Tolstoy
Moby Dick
Herman Melville
War and Pea

CS 5403 - Lecture 9
CS 5403 Lecture 9
Queues
Queues
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Queues
Queues
Bank
Tellers
Front of
line
2
A Computer Science
A Computer Science
Queue
Queue
insert function

CS 5403 - Lecture 4
CS 5403 Lecture 4
Container Classes
Container Classes
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Container Classes
Container Classes
A class used to store Items of data
A container i

CS 5403 - Lecture 5
CS 5403 Lecture 5
Pointers
Pointers
Department of Computer Science
and Engineering
Polytechnic Institute of
New York University
1
Pointers and Dynamic Memory
Pointers and Dynamic Memory
Dynamic memory memory which is allocated at run

The sample space is R3 = R R R with R = cfw_1, 2, 3, 4, 5, 6. If = (1, 3, 6), then X1() = 1, X2() = 3, and
X3() = 6 indicating that the first roll was a 1, the second was a 3, and the third was a 6. The probability
assigned to any sample point is m() = 1

CHAPTER 4. CONDITIONAL PROBABILITY pS = 0 1 47/60 13/60 . The random variables S and C are not
independent, since P(C = 1, S = 1) = 3 60 = .05 , P(C = 1)P(S = 1) = 10 60 13 60 = .036 . Note that we
would also see this from the fact that P(C = 1|S = 1) = 3

CS 5403 Data Structures and Algorithms
Midterm - Spring 2014
Notes:
This is an open-book, open-notes exam. Both hardcopy and digital
books/notes are allowed.
Internet browsing is NOT allowed. You may NOT use any ki

CS5403 Data Structures and Algorithms
Assignment 8
Assigned date: April 24, Thursday
Due date: May 2, Friday
Do not use a separate header file, application file and implementation file. Instead,
put all

CS5403 Data Structures and Algorithms
Assignment 7
Assigned date: April 8, Tuesday
Due date: April 18, Friday
Do not use a separate header file, application file and implementation file. Instead,
put all

CS5403 Data Structures and Algorithms
Assignment 6
Assigned date: April 3, Thursday
Due date: April 11, Friday
Do not use a separate header file, application file and implementation file. Instead,
put al

CS5403 Data Structures and Algorithms
Assignment 5
Assigned date: 04/18/2014
Due date: 04/28/2013
Do not use a separate header file, application file and implementation file. Instead,
put all your code in

CS5403 Data Structures and Algorithms
Assignment 4
Assigned date: 04/07/2014
Due date: 04/14/2013
Do not use a separate header file, application file and implementation file. Instead,
put all your code in

CS5403 Data Structures and Algorithms
Assignment 3
Assigned date: 02/21/2014
Due date: 03/05/2014
Do not use a separate header file, application file and implementation file. Instead,
put all your code in

CS5403 Data Structures and Algorithms
Spring 2014
Programming Assignment 1
Assigned date: February 4, 2014.
Due date: February 12, 2014 11:59pm EST,
Please read the direction in the first item in the Assignments section on Blackboard
before working on you

DISCRETE CONDITIONAL PROBABILITY 143 Not smoke Smoke Total Not cancer 40 10 50 Cancer 7 3 10
Totals 47 13 60 Table 4.1: Smoking and cancer. S 0 1 0 40/60 10/60 C 1 7/60 3/60 Table 4.2: Joint
distribution. for i = 1, 2, 3. However, in the case of Y , the p

Example 4.9 Finally, let us give an example of two events that are not independent. In Example 4.7, let I
be the event heads on the first toss and J the event two heads turn up. Then P(I)=1/2 and P(J)=1/4.
The event IJ is the event heads on both tosses an

CS-GY 6033, Spring 2016
Design & Analysis of Algorithm I
Lecture 10: Dynamic Programming, Introduction to Greedy Algorithm
April 18, 2016
Instructor: Houwei Cao
Last Lecture
!
Graphs Basics
! DAGs & Topological ordering
! Strongly connected components
! K

CS-GY6033 Homework 2 Solutions
All problem/exercise numbers are for the third edition of CLRS text book
.
1. Apply the bubble sort and insertion sort to an inverted array [9, 7, 5, 3, 1], show all intermediate results. [1 point]
Solution: Bubble Sort:
Fir

CS-GY6033 Homework 4
(Due May 2, 2016)
All problem/exercise numbers are for the third edition of CLRS text book
1. Exercise 22.3-2 in CLRS text book
2. You have an acyclic graph in the following figure. Explain how a topological sort
algorithm works an