1 views

Uploaded by JamesLeon

© All Rights Reserved

- ansys-example0241.pdf
- Algorithms Design and Analysis Mcqs With Answers Set 1
- Bela Bollobas Graph Theory an Introductory Course
- EC2202-question bank
- A Proof Involving Graphs
- Full Text
- MC0063(B)-unit9-fi
- Remco van der Hofstad - Random graphs and complex network I.pdf
- DiesTel
- Week05 Graph 1
- q.bankds
- Single Valued Neutrosophic Signed Graphs
- BFS_DFS_Applicatio.pdf
- Saharon Shelah and Joel Spencer- Can You Feel the Double Jump
- Analysis Translated
- Graph
- A Proof Involving Graphs
- A STUDY ON MARKOV CHAIN WITH TRANSITION DIAGRAM
- Data Structures
- On the Distance Eccentricity Zagreb Indeices of Graphs

You are on page 1of 10

School of Computing

Semester 1 (2014/2015)

CS2010 - Data Structures and Algorithms II

Written Quiz 2 (10%)

Saturday, October 25, 2014, 10.00-11.17am (77 mins)

INSTRUCTIONS TO CANDIDATES:

1. Do NOT open this question paper until you are told to do so.

It comprises TEN (10) printed pages, including this page.

4. Write all your answers in this question paper, but only in the space provided.

You can use either pen or pencil. Just make sure that you write legibly!

Important tips: Pace yourself! Do not spend too much time on one (hard) question.

5. This is an Open Book Examination. You can check the lecture notes, tutorial ﬁles, problem

set ﬁles, Steven’s ‘Competitive Programming’ book, or any other books/printed material that

you think will be useful. But remember that the more time that you spend ﬂipping through

your ﬁles implies that you have less time to actually answer the questions.

6. When this Written Quiz 2 starts, please immediately write your Matric Number here:

(include the last letter) and your Tutorial Group Number/

Tutorial TA Name/Tutorial Day (Tue or Wed)/Tutorial Time:

do not write your name in order to facilitate unbiased grading.

After Written Quiz 2, this question paper will be collected, graded manually in about 1.5 weeks,

and likely returned to you via your Tutorial TA on Week12.

1

CS2010

–This page is intentionally left blank. You can use it as ‘rough paper’–

2

CS2010

Grading scheme: 0 (wrong answer), 1 (correct answer).

1. What is the resultant graph after performing a BFS (from any source) called ?

2. In BFS, the vertices to be en-queued after processing the source vertex are all those that

away from the source vertex.

3. If a graph has all edges of weight 3, the best algorithm to ﬁnd the shortest path from a vertex

A to all other vertices is .

4. The minimum number of times Bellman Ford’s algorithm need to relax all edges of a graph in

order to ﬁnd the shortest path is .

5. The worst case time complexity of Original Dijkstra’s algorithm when run on a tree is .

7. The best SSSP algorithm to use on a graph with -ve edge weights and (and potentially contain

-ve cycles) is .

9. There is only 1 unique path between any 2 vertices in a tree. (true/false) (circle the answer)

10. If a new edge connecting 2 existing nodes in a tree is added, a cycle will always be formed.

(true/false) (circle the answer)

11. Given the shortest path between 2 vertices A and B, the subpaths of that shortest path are

themselves shortest paths. (true/false) (circle the answer)

12. The set of edges in the SSSP spanning tree and the MST for any undirected connected graph

with positive edge weights will never be the same. (true/false) (circle the answer)

13. Adding a constant to every edge weight in a graph does not change the solution to the SSSP

problem. (true/false) (circle the answer)

14. The largest edge in each cycle of an undirected connected graph with unique edge weights must

not be in any valid MST of the graph. (true/false) (circle the answer)

15. The smallest edge in each cycle of an undirected connected graph with unique edge weights must

be in every valid MST of the graph. (true/false) (circle the answer)

3

CS2010

Prove (the statement is correct) or disprove (the statement is wrong) the following statements below.

3 marks per each statement below (1 mark for saying correct/wrong, 2 marks for explanation):

Note : You are only given a small amount of space below (i.e. do not write too long-winded answer)!

1. For any undirected connected graph where number of edges E > number of vertices V , if there

are some edges with the same weight, the MST of the graph will always not be unique. (3 marks)

2. If the weights of all edges in a weighted graph are unique, there is always a unique shortest path

from a source to destination in such a graph. (3 marks)

3. The following algorithm to ﬁnd the largest edge from a given source s to a given destination d

in the MST of a graph G is correct.

Run Kruskal’s on G, and keep track of the largest edge e∗ included in the MST so far. Every

time it includes an edge e to be in the MST, we query the UFDS whether s and d are in the

same set. If they are, stop Kruskal’s and simply output e∗ as the answer. (3 marks)

4

CS2010

4. For modiﬁed Dijkstra’s, a vertex v cannot be en-queued in the priority queue more times than

the number of in-edges to v. (3 marks)

5. In a tree of ≥ 3 vertices, for any three vertices a,b,c, let E∗ be the set of edges formed from the

union of the set of edges in the path a ∼> b and the path a ∼> c. The set of edges in the path

b ∼> c must then be a subset of the edges in E∗. (3 marks)

5

CS2010

Please write pseudo-code (which can be english descriptions) for all your algorithms. There should not

be any black-boxes in your pseudo-code. This means that if you use any function that is not deﬁned

in the lecture notes or a well recognized algorithm, then you must deﬁne them.

a.) (4 marks) Two friends lives in cities A and B respectively, and they want to meet up. In order

to convenience the both of them, they come up with a strategy to meet up at a city C, where C

satisﬁes the following 2 conditions.

Firstly city C satisﬁes the condition that the sum of their total travelled distance to C is the

smallest. Secondly city C satisﬁes the condition that the absolute diﬀerence between the distance

travelled by each person is minimized. The ﬁrst condition is more important than the second.

Come up with an eﬃcient algorithm to ﬁnd the city they should meet up in. If there are multiple

candidate cities which satisfy the above criteria just output one of them. You can assume that

there exist at least 1 such city C and also the roads and cities can be represented as an undirected

weighted graph, where the edge weight is the distance between the connected cities.

6

CS2010

b.) (4 marks) Given an undirected graph where edge weights w are multiples of 2 and have values

between 2 and 50, ﬁnd the shortest path from a given source vertex s to all possible destination

vertex d using an eﬃcient algorithm.

For some applications of MST, the original graph G(V, E) is not static but dynamic in the sense that

there can be changes to its edges and vertices. You may assume for each of the question below that

the edge list, adjacency list and current MST is given to you.

a.) (1 mark) Give an eﬃcient algorithm to update the MST when a new vertex s of degree 1 is

inserted into G(V, E).

b.) (3 marks) Give an eﬃcient algorithm to update the MST when a new vertex s of degree 2 is

inserted into G(V, E).

7

CS2010

c.) (8 marks) Give an eﬃcient algorithm to update the MST when an edge (a,b) in G(V, E) changes

its weight (can be a decrease or increase).

8

CS2010

d.) (BONUS QUESTION worth 10 marks***) Give an eﬃcient algorithm that has worst case

time complexity better than O(E + V logV ) to update the MST when a new vertex s of degree

up to |V − 1| is inserted into G(V, E). (This is a bonus question, do not attempt until you have

ﬁnished all the other questions! Also no marks are given for algorithms with eﬃciency worse or

equal to O(E + V logV ))

9

CS2010

1 15

2 15

3 min(8+12, your marks)

Total 50

10

- ansys-example0241.pdfUploaded byVictor Verga
- Algorithms Design and Analysis Mcqs With Answers Set 1Uploaded byKande Archana K
- Bela Bollobas Graph Theory an Introductory CourseUploaded byVaibhav Daga
- EC2202-question bankUploaded byAnirudhan Ravi
- A Proof Involving GraphsUploaded byshanksauce
- Full TextUploaded bySanjeev Kumar
- MC0063(B)-unit9-fiUploaded bySanjeev Malik
- Remco van der Hofstad - Random graphs and complex network I.pdfUploaded byCristiano Benjamin
- DiesTelUploaded byAtique Khattak
- Week05 Graph 1Uploaded byEdison Mamani Ramirez
- q.bankdsUploaded bypriya_coolcandy1583
- Single Valued Neutrosophic Signed GraphsUploaded byMia Amalia
- BFS_DFS_Applicatio.pdfUploaded byVineet Kumar Kanth
- Saharon Shelah and Joel Spencer- Can You Feel the Double JumpUploaded byHutsDM
- Analysis TranslatedUploaded byPranjalShankhdhar
- GraphUploaded bysonal
- A Proof Involving GraphsUploaded byshanksauce
- A STUDY ON MARKOV CHAIN WITH TRANSITION DIAGRAMUploaded byInternational Jpurnal Of Technical Research And Applications
- Data StructuresUploaded byjmat992
- On the Distance Eccentricity Zagreb Indeices of GraphsUploaded byIoan Degau
- Algorithms homework 1Uploaded byyi
- study guideUploaded byapi-292970084
- Single Valued Neutrosophic SignedgraphsUploaded byMia Amalia
- Les 070703 Var 2Uploaded byMinani Jean Baptiste
- Data Structure referenceUploaded byMashruk Kabir
- 240 Graphs OldUploaded byTripal Meshram
- 1101.3773v2Uploaded byPloni Almoni
- 9780521809207_indexUploaded byVasquez JC
- unit5 notesUploaded bySwathi Gowroju
- Concurrency Analysis ReportUploaded bySalemHasnaoui

- Smolinski Internat NegotiationUploaded byHasan Zidny
- MIT Time Dilations Tricks for FundsUploaded byJoe Nahhas
- Tanjong RhuUploaded bySalwani Azlina
- BSC - PrimerUploaded byConfluence
- Output Terminale RegistratoUploaded byFrank Lucas
- SALAS vs MATUSALEM (Object or Real Evidence)Uploaded byTjYambot
- INGLES- VON MISES Theory and history An interpretation of social and economic evolution 1957.pdfUploaded byEduardo Sandez
- Whistle Blowing Policy FinalUploaded byMuhammad Shahzad Rasool
- RULE 141 - Legal FeesUploaded byRamon Miguel Rodriguez
- Chapter 4Uploaded byNurul Badriah Anwar Ali
- Kickoff MeetingsUploaded byLucia Falco
- Giving InstructionUploaded bySario's Kingdom
- Nur 302 Health AssessmentUploaded byCandy Yip
- Iloilo City Regulation Ordinance 2016-209Uploaded byIloilo City Council
- Rotation-of.pptxUploaded byCess Chan
- June 25 - July 1, 2014 Sports ReporterUploaded byAnonymous 7j0ht8P2T1
- e-learning book review edci 888Uploaded byapi-313220392
- Making a Worm Farm - FactsheetUploaded byComm Dy
- Alfonso l. Iringan vs Court of Appeals_gr 129107_september 26, 2001Uploaded byBerniceAnneAseñas-Elmaco
- Kangas - Times and Tales of the Kalgoorlie City Football ClubUploaded byKangasFC
- 4 3 17 formal lesson plan sridharaUploaded byapi-375209006
- Termination for ConvenienceUploaded byNazRahim
- HILL v. CROSBY et al - Document No. 7Uploaded byJustia.com
- c Bo 9781139049207 a 011Uploaded byMathew Usf
- Kuwait Export Crude Oil.pdfUploaded byShiva Krishna
- Stefano Harney Moten DebtUploaded bymelona6913
- Pm 201 ResearchUploaded byHazem El-Essawy
- Proxim devicesUploaded byJoel Abissey
- Triten 2014 Guide - FINAL 131101Uploaded byBrad Reed Sr.
- Are Humans Still Evolving?Uploaded bymanuelmch