8 views

Uploaded by Elan Frenkel

Problems for algorithm study in computer science.

- book-2608
- Predicting New Collaborations in Academic Citation Networks of IEEE and ACM Conferences
- KG2018-Lecture-01-print.pdf
- Graphs
- Scientia Magna, Vol. 6, No. 3, 2010
- Treesslides
- fg 6 graphical transformations additional note help
- Ads and its marathon
- My Apogee Paper
- graceful.pdf
- Morton&Mareels
- graph-coloring
- Data Structure 2 as Ch
- Lesson 09
- 1999Gauss8Contest.pdf
- Dactyloscopy
- Nk Star Paper
- 0000041
- 5e lesson plan-oh deer
- Adversarial Synergy Graph Model for Predicting Game Outcomes in Human Basketball

You are on page 1of 5

1. Practice with FT

What is the FT of P (x) = 1 + x3 ? What values of x would we use with the FFT?

We will find P (x) with x-values 1, i, 1, i

P (1) = 2

P (i) = 1 i

P (1) = 0

P (i) = 1 + i

2. Practice with FFT

(a) Run the FFT on A(x) = 4 + 2x + 3x2 + x3 .

We wish to find A(1), A(i), A(1), and A(i).

We express A in terms of even and odd terms:

A(x) = B(x2 ) + xC(x2 )

where B(x) = 4 + 3x and C(x) = 2 + x.

We then recursively evaluate B and C each at 1 and 1. This will give us:

B(1) = 7

B(1) = 1

C(1) = 3

C(1) = 1

A(1) = B(1) + C(1) = 10

A(i) = B(1) + iC(1) = 1 + i

A(1) = B(1) C(1) = 4

A(i) = B(1) iC(1) = 1 i

No, A(x2 ) will have degree 6 so we need more points to uniquely determine A(x2 ).

We will need to evaluate at the eighth roots of unity instead.

As stated in (b), we must evaluate A at the eighth roots of unity (four of which

we computed in (a)). Let = ei/4 . We will now evaluate A at the remaining

roots. We will write 2 instead of i to make the math clearer.

B(i) = B( 2 ) = 4 + 3 2

B(i) = B( 2 ) = 4 3 2

C(i) = C( 2 ) = 2 + 2

C(i) = C( 2 ) = 2 2

Let = ei/4 . We will now evaluate A at the remaining roots. Here we will use

2 instead of i to make the math clearer.

A() = B( 2 ) + C( 2 ) = 4 + 3 2 + 2 + 2 = 4 + 2 + 3 2 + 3

A( 3 ) = B( 2 ) + 3 C( 2 ) =

A( 5 ) = B(1) C(1) =

A( 7 ) = B(1) iC(1) =

3. Graph traversal.

(a) For the directed graph below, perform DFS starting from vertex A, breaking ties

alphabetically. As you go, label each node with its pre- and post-number, and

mark each edge as Tree, Back, Forward or Cross.

A61

T

B23

E45

C720

C

C

16

I13

11

D10

T

G15

14

T

T

17

H12

F918

J819

(b) What are the strongly connected components of the above graph?

{A}, {B}, {E}, {G, H, I}, {C, J, F, D}

(c) Draw the DAG of the strongly connected components of the graph.

CJF D

GHI

4. Short answer For each of the following, either prove the statement is true or give a

counterexample to show it is false.

(a) If (u, v) is an edge in an undirected graph and during DFS, post(v) < post(u),

then u is an ancestor of v in the DFS tree.

True. There are two possible cases: pre(u) < pre(v) < post(v) < post(u) or

pre(v) < post(v) < pre(u) < post(u). In the first case, u is an ancestor of v.

In the second case, v was popped off the stack without looking at u. However,

since there is an edge between them and we look at all neighbors of v, this cannot

happen.

(b) In a directed graph, if there is a path from u to v and pre(u) < pre(v) then u is

an ancestor of v in the DFS tree.

False. Consider the following case:

T

u32

w16

v45

B

(c) In any connected undirected graph G there is a vertex whose removal leaves G

connected.

True. Remove a leaf of a DFS tree of the graph.

5. Compiling on a parallel cluster We want to compile a large program containing n modules. We are given a dependency graph G = (V, E): G is a directed, acyclic graph with

a vertex for each module, and an edge from module v to module w means we must

finish compiling v before starting to compile w. Each module takes exactly one minute

to compile. We want to compile the program as quickly as possible. We are willing

to use Amazon EC2 for this purpose, so we can compile as many modules in parallel

as we want, as long as we satisfy the dependencies. Find a linear-time algorithm that

computes the minimum time needed to compile the program. Solution: Were looking

for the longest path in this DAG, so topologically sort the graph. Then, for each vertex

v (in topologically sorted order), we compute the length of the longest path ending at

v, in terms of other lengths previously calculated.

In pseudocode:

FindCompletionTime(Graph G):

1. Linearize the graph G, and let v1 , . . . , vn denote the vertices of G in topologically sorted order.

2. For j := 1, 2, . . . , n:

3.

Set `[j] = 1 + max(0, max{`[i] : (vi , vj ) E})

4. Return max{`[j] : 1 j n}.

This gives us the correct answer because as soon as all predecessors of a module are

done compiling we can compile the module, and `[] as calculated holds the minimum

amount of time needed to compile each module along with all of its dependencies.

4

6. True Source Design an efficient algorithm that given a directed graph G determines

whether there is a single vertex v from which every other vertex can be reached. Hint:

first solve this for directed acyclic graphs. Note that running DFS from every single

vertex is not efficient.

Solution: In directed acyclic graphs, this is easy to check. We just need to see if the

number of source nodes (zero indegree) is 1 or more than 1. Certainly if it is more than

1, there is no true source, because one cannot reach either source from the other. But

if there is only 1, that source can reach every other vertex, because if v is any other

vertex, if we keep taking one of the incoming edges, starting at v, we have to either

reach the source, or see a repeat vertex. But the fact that the graph is acyclic means

that we cant see a repeat vertex, so we have to reach the source. This means that the

source can reach any vertex in the graph.

Now for general graphs, we first form the SCCs, and the metagraph. Now if there is

only one source SCC, any vertex from it can reach any other vertex in the graph, but

if there are more than one source SCCs, there is no single vertex that can reach all

vertices.

- book-2608Uploaded bysuccessor2020
- Predicting New Collaborations in Academic Citation Networks of IEEE and ACM ConferencesUploaded bySaad
- KG2018-Lecture-01-print.pdfUploaded byParham
- GraphsUploaded byminichel
- Scientia Magna, Vol. 6, No. 3, 2010Uploaded byAnonymous 0U9j6BLllB
- TreesslidesUploaded bySheraz Ali
- fg 6 graphical transformations additional note helpUploaded byapi-291889212
- Ads and its marathonUploaded byChristina Robinson
- My Apogee PaperUploaded bymaco_anshu
- graceful.pdfUploaded byMuflih Mubarak Darmadi
- Morton&MareelsUploaded byYashveer Takoory
- graph-coloringUploaded byapi-240547275
- Data Structure 2 as ChUploaded byEric Leo Asiamah
- Lesson 09Uploaded byAlif
- 1999Gauss8Contest.pdfUploaded bySahabudeen Salaeh
- DactyloscopyUploaded bymasemase
- Nk Star PaperUploaded byAllen Yuan
- 0000041Uploaded bywendersoncsdep
- 5e lesson plan-oh deerUploaded byapi-432506487
- Adversarial Synergy Graph Model for Predicting Game Outcomes in Human BasketballUploaded byBartoszSowul
- cadUploaded byshekhartit
- ECE3073 P8 Compilation answers.pdfUploaded bykewancam
- Unit 2s.pdfUploaded byNivitha
- 13160045Topic12GraphUploaded byعبدالرحيم اودين
- test1solUploaded byXan Pbw
- Cad Spiral CoolingUploaded bythemike03
- On Random GraphsUploaded byEric Mortberg
- cgraph.3Uploaded byRaphael de Vasconcelos Nascimento
- MATHSUploaded byDeepak Kumar
- Data Org NotesUploaded byVigneshwaran Srinivasan

- Sharples- Theory of MobileUploaded byjyotik09
- Soil – Structure Interaction & Foundations VibrationsUploaded bycasanovavn
- raj bankUploaded bySunny Bhatt
- Lenovo User_Manual_83-266-592Uploaded byanggoro
- Citrus Market Value Chain 2015Uploaded byAndres Paolantonio
- Marketing PlanUploaded bySharath Panicker
- How to Completely Uninstall and Remove a Software ProgramUploaded byMuhammad Naffah Amin
- Role of the Police and CourtsUploaded byShivam Patel
- City Of Sabah Marine.docxUploaded byReplica Oakley sunglasses
- Consolidated Bulletin Issue No.113Uploaded byIrfan
- IEEE Std 81-1983Uploaded bymjimenezg
- Tekla User Assistance - Model Folder Files and File Name Extensions - 2015-08-28Uploaded bysoftmailer1253
- Corporate and Commercial Alert 7 November 2016Uploaded byBisto Masilo
- 3555Diesel1pdf_00000005693Uploaded byMohamedSalah
- Random Matrix TheoryUploaded byHaider AlSabbagh
- Restoration Hardware v. Chicago Wicker - ComplaintUploaded bySarah Burstein
- Intro to Fire Sim-027Uploaded byAnonymous BbZceWkVn
- TI Report 2010Uploaded byAltaf Sheikh
- 5f RM fbsl sept 16 (accastudymaterial.com).pdfUploaded byyolo
- Power System Protection CourseUploaded byEdison Lim
- zf05Uploaded byblahblehu
- A History of the NationsUploaded byDhiraj Borade
- Dracast Ledt2000 Tube Series Info SheetUploaded byJohn
- 1757-tg001_-en-pUploaded byfitasmounir
- TriGeneration for Data Centres - Original PaperUploaded byKopi Brisbane
- ForestUploaded byGeeta
- Big Lots v BainUploaded byFortune
- Practic CCNA 3Uploaded byHamudi-style
- Knowledgebase _ Brainware_ Learnset Manager Technical OverviewUploaded byKS2
- FORM-15GUploaded byChristopher Vinoth