Midterm1 Sol Essay

CPSC 320 Midterm 1
Monday, October 18th, 2010
[13] 1. Short answers
[4] a. We frequently prove an O(n2 ) bound on the worst-case running time T (n) of an algorithm, without proving any Ω bound on T (n). However, we would never prove an Ω(n2 ) bound on T (n) without also proving a O bound on T (n). Why not?
Solution : Proving an Ω(n2 ) bound on T (n) simply means that the algorithm runs slowly. There is no point in giving an algorithm without providing an upper-bound on its running time (since then the algorithm might be arbitrarily bad).
[4] b. Why is Dijkstra’s algorithm greedy?
Solution : Because at each iteration of the for loop, it adds to the tree the vertex with the smallest cost at that point, without considering what that might mean for future iterations.
[5] c. Mr. Isulo, a famous alien computer scientist, has designed a greedy algorithm to solve the Clique problem (you don’t need to know what it is) on a type of graphs called circular arc graphs (you don’t need to know what they are either). His algorithm starts by choosing the vertex with the most neighbours.
Mr. Isulo wants to prove the following lemma: “Every circular arc graph has a maximum clique that contains the vertex with the most neighbours”, but he eventually finds a counter-example to his conjecture. What does this imply for Mr. Isulo’s algorithm, and why?
Solution : All of the solutions constructed by Mr. Isulo’s algorithm will contain the vertex with the most neighbours, since a greedy algorithm never removes the vertices it has chosen. Because the lemma is false, his algorithm will not return the correct answer for some graphs (that is, it doesn’t work).
[5] 2. Give an example of a function f : N → R+ that is not in O(n log n), but is not in ω(n log n) either. Justify your answer briefly.
Solution : Consider the function f : N → R+ defined by f (n) =

n n2 if n is even if n is odd

Because f (n) = n for every even value of n, f (n) is not in ω(n log n). And because f (n) = n2 for every odd value of n, f (n) is not in O(n log n) either.

page 2
[5] 3. A long string consists of the four characters A, C, G and T ; they appear with frequencies
31%, 20%, 9% and 40% respectively. What code would Huffman’s algorithm return for each of these characters (that is, list the sequence of bits that would be used to represent each character)? Justify your answer.
Solution :
Character
A
C
G
T

Code
01
000
001
1

[5] 4. Recall that a simple path from a vertex s of a graph G to another vertex v of G is a path from s to G that contains each vertex at most once. A student who was interested in finding the maximum cost simple path from a vertex s of G to every other vertex of G decided that he could achieve this by using Dijkstra’s algorithm, using a Max-Heap instead of a Min-Heap, and replacing the line if (Cost(v) > Cost(u) + cost(u,v)) then
Cost(v) ← Cost(u) + cost(u,v) by if (Cost(v) < Cost(u) + cost(u,v)) then
Cost(v) ← Cost(u) + cost(u,v)
Give an example of a graph where this student’s algorithm will fail. Show both the output from the modified version of Dijkstra’s algorithm, and a path from s to v that is longer than the path found by the algorithm.
Solution : Consider the following graph:

page 3
The modified version of Dijkstra’s algorithm will first select vertex u (with a cost of 3) and then vertex t (with a cost of 7). However the longest simple path from s to u is the path stu which has a cost of 6.
[12] 5. Given a graph G = (V, E), and a parity function p : V → {”odd”, ”even”} (that is, we assign a value ”odd” or ”even” to each vertex of G), the parity matching problem consists in finding a subset E ′ of the edges of G such that for every v ∈ V , the number of edges of
E ′ having v as an endpoint is odd if p(v) = ”odd”, and even if p(v) = ”even”.
For instance, if p(v) = ”even” for every vertex v of G, then the empty…

Related Documents: Midterm1 Sol Essay

Biology SOL Review - 2012
Experimental Design
Observation: -Using your senses to explore life &
collect data
Inference: -Logical interpretation based on background knowledge and experience.
Testable Question:
All science research starts with a question that you can test.
Steps to Designing and Conducting
an Experiment
Problem: -The question you are trying to answer
Hypothesis: -A possible explanation for an observation
*Must be testable
*Always should be an "IF, then"…

Sol Rio Apartments Complex Rules
Meter Number: PBW_______________
1. No shopping Trolleys in or around any of the Buildings or surrounding paths $150.00
2. All Tradesmen MUST be reported to Statewide Developments Realty office prior to works carried out. (eg phone lines, gas, electrical)
3. No Loud Music or disturbing noise after 11Pm, You will incur a call out fee $175…

Chapter 3 Solutions
Review Questions
1. Which command is used to create a table based upon data already contained in an existing table? CREATE TABLE command with a subquery
2. List four datatypes supported by Oracle10g, and provide an example of data that could be stored by each datatype. DATE – 20-JAN-99, VARCHAR2 – HELLO, NUMBER – 5.23, CHAR - HELLO
3. What are the guidelines you should follow when naming tables and columns in Oracle10g? A maximum of 30 characters are allowed, the first character…

1. What is geography?
The study of the physical features of the earth and its atmosphere, and of human activity as it affects and is affected by these, including the distribution of populations and resources, land use, and industries.
2. Five themes of geography
Location:
Absolute- As in coordinates of a map using longitude and latitude
Relative- General location, ex: next door, a short drive, next to the post office
Place: An area that is defined by everything in it. All places have features that…

EE E6887 (Statistical Pattern Recognition)
Solutions for homework 2
P.1 Let p(x|ωi ) ∼ N (µi , Σ) for i = 1, 2 in a two-category d-dimensional
problem with the same covariance but arbitrary means and prior probabilities. Consider the square Mahalanobis distance:
ri2 = (x − µi )t Σ−1 (x − µi )
(a) Show that the gradient of ri2 is given by
∇ri2 = 2Σ−1 (x − µi )
(b) Show that any position on a given line through µi the gradient
∇ri2 points in the same direction. Must this direction be parallel
to that…

International Finance
Professor Baruch
Fall, 2013
Home Work Assignment1
This assignment is based on the lecture on Theories of International Trade and
Chapter 1 in B&H.
(1) Deﬁne globalization. How has it proceeded in trade in goods and services
versus capital markets?
Answer: Globalization refers to the increasing connectivity and integration
of countries and corporations and the people within them in terms of their economic, political, and social activities. Because of globalization…

Economics 4130
AU14 MWF Exam 1 Review
The exam will have 5, 10-point questions on it from the questions below.
1. List 2 data sources researchers use to estimate historical standards of living and explain what they can infer from these sources.
1) tax records (production information, shipping information, exports and imports, wealth)
2) church records (births, deaths, life expectancy)
List three indicators of economic development other than National Income measures (NI, GDP, or GNP, level…

Words 2511 - Pages 11

* Test names and other trademarks are the property of the respective trademark holders. None of the trademark holders are affiliated with this website.