Homework set 6
March 17, 2009
1
Minimizing gas stops
You are driving your car from city A to city B. Along the road connecting the two cities there are gas stations, at distances x1 , x2 , . . . , xn from city A. You know that your car can travel a distan
Analysis of Algorithms
Amotz Bar-Noy
CUNY
Amotz Bar-Noy (CUNY)
Analysis of Algorithms
1 / 56
Algorithm: Definitions
1
A finite set of precise instructions for performing a computation or
for solving a problem.
2
A specific set of instructions for carrying
Finding the GCD
Amotz Bar-Noy
CUNY
Spring 2012
Amotz Bar-Noy (CUNY)
Finding the GCD
Spring 2012
1 / 17
Computing the Greatest Common Divisor
Input: Two integers x > 0 and y > 0.
Output: The maximum integer z 1 such that z divides both x
and y .
Notation:
1
Dealing with Hierarchies
There are many real world situations where the relational model doesnt fit naturally. One of
them are generalizations and specializations from object oriented languages. Others involve
recursive data structures, such as as trees
1
Loading Data
In a data warehouse environment, theres often a need to load massive amounts of data,
usually at regular intervals (daily, weekly, monthly, etc.). These notes discuss some of the
options and automation hints.
1.1
INSERT statements
An obviou
Robust Database Design
Alex S.
I believe the hard part of building software to be the specification, design, and
testing of this conceptual construct, not the labor of representing it and testing
the fidelity of the representation. Frederick P. Brooks, Jr
1
Stored Procedures
Many modern databases support a more procedural approach to databasesthey allow you
to write procedural code to work with data. Usually, it takes the form of SQL interweaved
with the more familiar IF statements and loops, etc.
Note tha
Distributed Databases
Alex S.
1
Introduction
For large databases, especially for date warehousing, it often becomes impractical to store
and/or process data on a single physical computer. The problem is scalability, of which there
are two kinds: vertical
1
Indexes
The purpose of an index is much like the purpose of an index in a book: to help us find the
important bits quickly.
1.1
Dense vs Sparse
Just as with book indexes, sparse database indexes dont point to individual records, but
to pages (chunks of
Big Data Primer
Alex Sverdlov
[email protected]
1
Why Big Data?
Data has value. This immediately leads to: more data has more value, naturally causing
datasets to grow rather large, even at small companies. Since storage space is cheap (and
getting che
Analytic Functions
(short intro)
Alex S, http:/theparticle.com/
[email protected]
Analytic functions (or windowing functions) are a new class of
aggregate functions in SQL that add a summary column to a result set.
For example, imagine you have stock t
Algorithms: Background
Amotz Bar-Noy
CUNY
Amotz Bar-Noy (CUNY)
Algorithms: Background
1 / 56
What is a Proof?
Definition I: The cogency of evidence that compels acceptance
by the mind of a truth or a fact.
Definition II: The process or an instance of esta
Homework set 8
April 9, 2009
1
Broadcasting in trees
Note: Though this exercise is a bit long, most of it is not hard. It is a good example of what you might expect to see in the test. In the context of computer and communication networks broadcasting mea
Solutions for homework 6
March 20, 2009
1
1.1
In this case the trip is clearly impossible, because there is no way to reach gas station xi+1 .
1.2
The algorithm is the following: starting from A, pick the gas station that is at maximum distance, but at mo
Solutions for Homework Set 8
April 21, 2009
1
1.1
In the local broadcasting model it would just one round in Kn , because every other vertex is a neighbor of the starting vertex.
1.2
The fastest way is for 1 to first send the message to 3 and then to 4. T
Solutions for homework 7
March 25, 2009
1
Edges: cfw_(A, E), (E, F ), (B, E), (F, G), (G, H), (C, G), (D, G). Total cost: 19 Another minimum spanning tree can be obtained if we swap (B, F ) for (B, E). There is no other optimal solution.
2
Given a graph,
Solutions for homework 9
May 15, 2009
1
1. Yes. P is a subset of NP. 2. No, this would imply that P=NP. 3. No, NP certainly contains problems which are not the hardest in NP. (For example, every problem solvable in constant time, such as deciding whether
Homework set 9
May 14, 2009
1
NP-completeness
1. A is in P 2. A is in NP 3. A is NP-complete 4. B is in P 5. B is in NP 6. B is NP-complete 7. A P B 8. B P A
Here is a list of statements regarding two problems A and B
Answer the following True/False quest
Homework Set 5
March 7, 2009
1
The Petersen graph is one of the most famous graphs in graph theory. You can see one drawing of it in Figure 1.
1.1
Give a representation of the Petersen graph using adjacency matrices and one using adjacency lists.
1.2
Run
Homework set 7
March 24, 2009
1
Solve Exercises 5.1(a) and 5.1(b) from DPV. For (a), also give the set of edges which make up the spanning tree.
2
Maximum spanning tree
Give an algorithm to compute the maximum spanning tree of a graph, that is the spannin
Solutions for Homework 5
March 19, 2009
1
1.1
(Omitted)
1.2
(Omitted)
1.3
(Omitted)
1.4
One minimum vertex cover is cfw_2, 3, 5, 6, 9, 10. This has size 6. This cannot be improved because the graph contains two cycles of length 5, and 3 vertices are neede
Algorithms: Order Statistics
Amotz Bar-Noy
CUNY
Spring 2012
Amotz Bar-Noy (CUNY)
Algorithms: Order Statistics
Spring 2012
1 / 53
A Search Problem
Input:
An ordered array A of n keys: A[1] A[2] A[n].
A key K .
Output:
Does K appear in A? YES or NO.
If YES:
Name: _
CISC 3220 SAMPLE EXAM 1
For maximum partial credit, show all your work clearly. Be sure your final answers are
clearly marked. You may work on the backs of the pages, but indicate that you are doing
so.
Question 1 Time Complexity and Asymptotic Or