SlideShare a Scribd company logo
1 of 6
To get more info, Please
Visit : – https://www.programmingexamhelp.com/
E- Mail : – support@programmingexamhelp.com
Contact Us : – +1678 648 4277
The Mario brothers are hired to outfit the Stata Center with a plumbing system. There is a set of n rooms in the building
that ideally would all have plumbing. However, due to a reduced budget compounded by a fear of leaks, the administrators
ask the brothers to provide the minimum piping needed to service at least the rooms in a mission-critical subset S of all
rooms.
The Mario brothers have asked you to help find the piping of minimum overall length that serves all rooms in S, and may
serve some other rooms in the building as well. Keep in mind that, for engineering reasons, pipes can only be joined inside
rooms.
(a)Luigi, one of the Mario brothers, assumes that any pair of rooms can be connected by pipes and suggests finding the
Minimum Pipe Spanning Tree (MPST) for the rooms in the mission-critical set S. Let G be a complete graph where
vertices represent rooms in the building and the weight of each edge is the length of the pipes required to connect
the corresponding rooms. The MPST for S is simply the Minimum Spanning Tree for the subgraph of G induced by
S. Provide an example of a room graph where finding the MPST for S would not give the piping of minimum
overall length.
Solution:
See figure below.
(b)Luigi has taken a closer look at the blueprint, which shows the distance d(x, y) for each pair of rooms x, y in the
building. He notes that the distances between any two rooms satisfy the triangle inequality. So, for any three rooms
x,y and z, d(x, z) ≤ d(x, y) + d(y, z).
Assume any pair of rooms x,y can be connected using a pipe of length d(x, y). Devise an efficient polynomial-time
approximation algorithm for the plumbing problem with an approximation ratio α ≤ 2. Hint: Consider building an
MPST on S.
Solution:
This is the metric Steiner tree problem. Construct an MST T on the subgraph induced by set S. The claim is that the
cost of the MST is 2 ·OPT .
Design And Analysis Of Algorithms
Problem
programmingexamhelp.com
j
than f :
Proof Take a Steiner tree of cost OPT. Double the edges (as in the 2-approximation algorithm for TSP). Find an Euler
tour in the resulting Eulerian graph, by traversing the edges with a DFS. The cost of the Euler tour is 2 ·OPT . Use
shortcutting trick to obtain a Hamiltonian cycle on vertices of S. By triangle inequality the shortcuts don’t increase the
cost of tour. If an arbitrary edge of this Hamiltonian cycle is deleted we obtain a path that spans S with a cost at most 2
·OPT .
(c) Mario notes that due to the topology of the building, pipes can only run between some pairs of rooms and not others.
What’s more, Alyssa P. Hacker sets up a few strategic wormholes, shortcuts through spacetime, so that the pipe-based
space-time displacements no longer satisfy the triangle inequality.
You are provided with an updated blueprint of possible direct pipe connections and effective pipe lengths for each of
them. Devise a polynomial-time approximation algorithm with approximation ratio α ≤ 2, using what you learned in
part (b).
Solution:
We produce a polynomial reduction from the Steiner tree problem to the metric Steiner problem in (b) that also
preserves the approximation factor. Use John- son’s or Floyd Warshall algorithm to compute all pairs shortest paths for
the input graph, yielding a a complete graph that encodes all of the shortest path weights be- tween all pairs of vertices
in original graph. By construction it satisfies the triangle inequality. Since all edges in E′ that were also in E have a
cost smaller than or equal to those in E, the cost of the optimal solution to the transformed graph will not exceed that of
the optimal solution to original problem.
Now we prove the converse. Given a Steiner tree T ′ we obtain a Steiner tree T in polynomial time of at most the same
cost. Replace each of T ′ by the correspond- ing shortest path to obtain a subgraph of G. All the vertices are
connected, but the subgraph may contain cycles. Remove edges to obtain tree T . By construction the reduction
preserves the approximation factor.
Problem 2. Huffman Coding
(a) You are working with a Huffman encoding scheme over n symbols. How long could a codeword be in the worst
case? Provide an example set of frequencies f1, f2, . . . fn (as a closed formula of n) that would give rise to this longest
codeword.
programmingexamhelp.com
D
B
3
3
A
5
3
5
5
C
Figure 1: Illustration of a complete graph D4. The shaded,
outlying nodes are part of the required set S. The MST for
outlying nodes will have a higher cost than the tree that
also spans the internal vertex.
A
1/2 B
1/4 C
1/8 1/16
Figure 2: Illustration of a Huffman code tree
with the longest codeword for n = 4.
Solution:
Consider the following set of frequencies: f −i n−i = 2 for i ∈ {1, . . . n − 1} for an alphabet of length n. The
longest codeword will have length n − 1. The cumulative sum of all frequencies up to and including the j − 1-
th smallest frequency will be less than fj : Pj−1 i=1 fi < fj . So, by construction, the tree will be a spine with a
leaf joining each intermediate subtree.
programmingexamhelp.com
(b) Prove that if some character occurs with frequency more than 2/5, then there is guar- anteed to be a codeword of
length 1.
Solution:
Figure 3: Illustration of a hypothetical tree with no codewords of length 1.
Assume for the purpose of obtaining a contradiction that there is no codeword of length 1. Then both children of the
root can not be leaves. Let the left child of the root be L, right child R, and the two children of each subtree a, b, and c, d
respectively.
Without loss of generality assume that the character with frequency greater than 2/5 appears in the subtree a of the left
child of the root. The right subtree R will have to have combined weight more than 2/5, since otherwise R being
smaller than a would be joined first with b. The combined weight on b will be less than 1/5 since the total sum of
frequencies has to add up to 1.
At the same time, the right subtree has to have cumulative weight less than 3/5, since one of the elements in L has
frequency in excess of 2/5. One of the two subtrees of R has to have weight less then 3/10, but then it would be
combined with subtree b, since the total weight of R is greater than 2/5 and so the other subtree of R would have
weight greater than that of b.
This is a contradiction since, bwas joined with a, so there is guaranteed to be a code- word of length 1.
(c) Prove that if all characters occur with frequency less than 1/3, then there is guaranteed to be no codeword of length 1.
programmingexamhelp.com
w(A) + w(B) + fx < 1. This is a contradiction. Since the sum of all weights in the subtree has to add up to 1.
Solution:
There have to be at least 4 symbols in the alphabet. Assume by contradic- tion that there is a codeword of length 1. The
codeword of length 1 will branch from the root of the tree. WLOG say it has frequenct fx. By construction of the Huffman
code tree, it has to have been merged with a subtree, that is a result of two subtrees (possibly leaves), call them A and B. Both
A and B have to have cumulative weight less than fx, since this last element was pulled last from the priority queue. Then,
since fx ≤ 1/3 by assumption that all characters occur with frequency less than 1/3,
programmingexamhelp.com

More Related Content

Similar to Computer Science Exam Help

Cs6702 graph theory and applications Anna University question paper apr may 2...
Cs6702 graph theory and applications Anna University question paper apr may 2...Cs6702 graph theory and applications Anna University question paper apr may 2...
Cs6702 graph theory and applications Anna University question paper apr may 2...appasami
 
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8Nguyễn Công Hoàng
 
SPACE-EFFICIENT K-MER ALGORITHM FOR GENERALISED SUFFIX TREE
SPACE-EFFICIENT K-MER ALGORITHM FOR GENERALISED SUFFIX TREESPACE-EFFICIENT K-MER ALGORITHM FOR GENERALISED SUFFIX TREE
SPACE-EFFICIENT K-MER ALGORITHM FOR GENERALISED SUFFIX TREEijitcs
 
Differential Equations Homework Help
Differential Equations Homework HelpDifferential Equations Homework Help
Differential Equations Homework HelpMath Homework Solver
 
Differential Equations Assignment Help
Differential Equations Assignment HelpDifferential Equations Assignment Help
Differential Equations Assignment HelpMaths Assignment Help
 
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREEA NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREEijscmc
 
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREEA NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREEijscmcj
 
Ireducible core and equal remaining obligations rule for mcst games
Ireducible core and equal remaining obligations rule for mcst gamesIreducible core and equal remaining obligations rule for mcst games
Ireducible core and equal remaining obligations rule for mcst gamesvinnief
 
Graph theory and life
Graph theory and lifeGraph theory and life
Graph theory and lifeMilan Joshi
 
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfUnit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfyashodamb
 
Minimizing cost in distributed multiquery processing applications
Minimizing cost in distributed multiquery processing applicationsMinimizing cost in distributed multiquery processing applications
Minimizing cost in distributed multiquery processing applicationsLuis Galárraga
 
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
23Network FlowsAuthor Arthur M. Hobbs, Department of .docxeugeniadean34240
 

Similar to Computer Science Exam Help (20)

Network Design Assignment Help
Network Design Assignment HelpNetwork Design Assignment Help
Network Design Assignment Help
 
Cs6702 graph theory and applications Anna University question paper apr may 2...
Cs6702 graph theory and applications Anna University question paper apr may 2...Cs6702 graph theory and applications Anna University question paper apr may 2...
Cs6702 graph theory and applications Anna University question paper apr may 2...
 
Design & Analysis of Algorithms Assignment Help
Design & Analysis of Algorithms Assignment HelpDesign & Analysis of Algorithms Assignment Help
Design & Analysis of Algorithms Assignment Help
 
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
 
Computer Network Homework Help
Computer Network Homework HelpComputer Network Homework Help
Computer Network Homework Help
 
Calculus Homework Help
Calculus Homework HelpCalculus Homework Help
Calculus Homework Help
 
SPACE-EFFICIENT K-MER ALGORITHM FOR GENERALISED SUFFIX TREE
SPACE-EFFICIENT K-MER ALGORITHM FOR GENERALISED SUFFIX TREESPACE-EFFICIENT K-MER ALGORITHM FOR GENERALISED SUFFIX TREE
SPACE-EFFICIENT K-MER ALGORITHM FOR GENERALISED SUFFIX TREE
 
Calculus Assignment Help
Calculus Assignment HelpCalculus Assignment Help
Calculus Assignment Help
 
Differential Equations Homework Help
Differential Equations Homework HelpDifferential Equations Homework Help
Differential Equations Homework Help
 
Differential Equations Assignment Help
Differential Equations Assignment HelpDifferential Equations Assignment Help
Differential Equations Assignment Help
 
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREEA NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
 
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREEA NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
A NEW PARALLEL ALGORITHM FOR COMPUTING MINIMUM SPANNING TREE
 
Ireducible core and equal remaining obligations rule for mcst games
Ireducible core and equal remaining obligations rule for mcst gamesIreducible core and equal remaining obligations rule for mcst games
Ireducible core and equal remaining obligations rule for mcst games
 
Graph theory and life
Graph theory and lifeGraph theory and life
Graph theory and life
 
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfUnit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
 
Thesis_Draft_Nurkhaidarov
Thesis_Draft_NurkhaidarovThesis_Draft_Nurkhaidarov
Thesis_Draft_Nurkhaidarov
 
Ch-3 lecture.pdf
Ch-3 lecture.pdfCh-3 lecture.pdf
Ch-3 lecture.pdf
 
Minimizing cost in distributed multiquery processing applications
Minimizing cost in distributed multiquery processing applicationsMinimizing cost in distributed multiquery processing applications
Minimizing cost in distributed multiquery processing applications
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
 

More from Programming Exam Help (20)

Best Algorithms Design Exam Help
Best Algorithms Design Exam Help Best Algorithms Design Exam Help
Best Algorithms Design Exam Help
 
Algorithm Exam Help
Algorithm Exam HelpAlgorithm Exam Help
Algorithm Exam Help
 
Algorithm Exam Help
Algorithm Exam HelpAlgorithm Exam Help
Algorithm Exam Help
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Algorithms Design Exam Help
Algorithms Design Exam HelpAlgorithms Design Exam Help
Algorithms Design Exam Help
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Algorithms Design Exam Help
Algorithms Design Exam HelpAlgorithms Design Exam Help
Algorithms Design Exam Help
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Algorithm Exam Help
Algorithm Exam HelpAlgorithm Exam Help
Algorithm Exam Help
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Algorithm Exam Help
Algorithm Exam HelpAlgorithm Exam Help
Algorithm Exam Help
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Programming Exam Help
Programming Exam Help Programming Exam Help
Programming Exam Help
 
Algorithm Exam Help
Algorithm Exam HelpAlgorithm Exam Help
Algorithm Exam Help
 
Programming Exam Help
Programming Exam Help Programming Exam Help
Programming Exam Help
 
Programming Exam Help
Programming Exam Help Programming Exam Help
Programming Exam Help
 
Algorithm Exam Help
Algorithm Exam Help Algorithm Exam Help
Algorithm Exam Help
 
Programming Exam Help
Programming Exam Help Programming Exam Help
Programming Exam Help
 

Recently uploaded

Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfJerry Chew
 

Recently uploaded (20)

Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 

Computer Science Exam Help

  • 1. To get more info, Please Visit : – https://www.programmingexamhelp.com/ E- Mail : – support@programmingexamhelp.com Contact Us : – +1678 648 4277
  • 2. The Mario brothers are hired to outfit the Stata Center with a plumbing system. There is a set of n rooms in the building that ideally would all have plumbing. However, due to a reduced budget compounded by a fear of leaks, the administrators ask the brothers to provide the minimum piping needed to service at least the rooms in a mission-critical subset S of all rooms. The Mario brothers have asked you to help find the piping of minimum overall length that serves all rooms in S, and may serve some other rooms in the building as well. Keep in mind that, for engineering reasons, pipes can only be joined inside rooms. (a)Luigi, one of the Mario brothers, assumes that any pair of rooms can be connected by pipes and suggests finding the Minimum Pipe Spanning Tree (MPST) for the rooms in the mission-critical set S. Let G be a complete graph where vertices represent rooms in the building and the weight of each edge is the length of the pipes required to connect the corresponding rooms. The MPST for S is simply the Minimum Spanning Tree for the subgraph of G induced by S. Provide an example of a room graph where finding the MPST for S would not give the piping of minimum overall length. Solution: See figure below. (b)Luigi has taken a closer look at the blueprint, which shows the distance d(x, y) for each pair of rooms x, y in the building. He notes that the distances between any two rooms satisfy the triangle inequality. So, for any three rooms x,y and z, d(x, z) ≤ d(x, y) + d(y, z). Assume any pair of rooms x,y can be connected using a pipe of length d(x, y). Devise an efficient polynomial-time approximation algorithm for the plumbing problem with an approximation ratio α ≤ 2. Hint: Consider building an MPST on S. Solution: This is the metric Steiner tree problem. Construct an MST T on the subgraph induced by set S. The claim is that the cost of the MST is 2 ·OPT . Design And Analysis Of Algorithms Problem programmingexamhelp.com
  • 3. j than f : Proof Take a Steiner tree of cost OPT. Double the edges (as in the 2-approximation algorithm for TSP). Find an Euler tour in the resulting Eulerian graph, by traversing the edges with a DFS. The cost of the Euler tour is 2 ·OPT . Use shortcutting trick to obtain a Hamiltonian cycle on vertices of S. By triangle inequality the shortcuts don’t increase the cost of tour. If an arbitrary edge of this Hamiltonian cycle is deleted we obtain a path that spans S with a cost at most 2 ·OPT . (c) Mario notes that due to the topology of the building, pipes can only run between some pairs of rooms and not others. What’s more, Alyssa P. Hacker sets up a few strategic wormholes, shortcuts through spacetime, so that the pipe-based space-time displacements no longer satisfy the triangle inequality. You are provided with an updated blueprint of possible direct pipe connections and effective pipe lengths for each of them. Devise a polynomial-time approximation algorithm with approximation ratio α ≤ 2, using what you learned in part (b). Solution: We produce a polynomial reduction from the Steiner tree problem to the metric Steiner problem in (b) that also preserves the approximation factor. Use John- son’s or Floyd Warshall algorithm to compute all pairs shortest paths for the input graph, yielding a a complete graph that encodes all of the shortest path weights be- tween all pairs of vertices in original graph. By construction it satisfies the triangle inequality. Since all edges in E′ that were also in E have a cost smaller than or equal to those in E, the cost of the optimal solution to the transformed graph will not exceed that of the optimal solution to original problem. Now we prove the converse. Given a Steiner tree T ′ we obtain a Steiner tree T in polynomial time of at most the same cost. Replace each of T ′ by the correspond- ing shortest path to obtain a subgraph of G. All the vertices are connected, but the subgraph may contain cycles. Remove edges to obtain tree T . By construction the reduction preserves the approximation factor. Problem 2. Huffman Coding (a) You are working with a Huffman encoding scheme over n symbols. How long could a codeword be in the worst case? Provide an example set of frequencies f1, f2, . . . fn (as a closed formula of n) that would give rise to this longest codeword. programmingexamhelp.com
  • 4. D B 3 3 A 5 3 5 5 C Figure 1: Illustration of a complete graph D4. The shaded, outlying nodes are part of the required set S. The MST for outlying nodes will have a higher cost than the tree that also spans the internal vertex. A 1/2 B 1/4 C 1/8 1/16 Figure 2: Illustration of a Huffman code tree with the longest codeword for n = 4. Solution: Consider the following set of frequencies: f −i n−i = 2 for i ∈ {1, . . . n − 1} for an alphabet of length n. The longest codeword will have length n − 1. The cumulative sum of all frequencies up to and including the j − 1- th smallest frequency will be less than fj : Pj−1 i=1 fi < fj . So, by construction, the tree will be a spine with a leaf joining each intermediate subtree. programmingexamhelp.com
  • 5. (b) Prove that if some character occurs with frequency more than 2/5, then there is guar- anteed to be a codeword of length 1. Solution: Figure 3: Illustration of a hypothetical tree with no codewords of length 1. Assume for the purpose of obtaining a contradiction that there is no codeword of length 1. Then both children of the root can not be leaves. Let the left child of the root be L, right child R, and the two children of each subtree a, b, and c, d respectively. Without loss of generality assume that the character with frequency greater than 2/5 appears in the subtree a of the left child of the root. The right subtree R will have to have combined weight more than 2/5, since otherwise R being smaller than a would be joined first with b. The combined weight on b will be less than 1/5 since the total sum of frequencies has to add up to 1. At the same time, the right subtree has to have cumulative weight less than 3/5, since one of the elements in L has frequency in excess of 2/5. One of the two subtrees of R has to have weight less then 3/10, but then it would be combined with subtree b, since the total weight of R is greater than 2/5 and so the other subtree of R would have weight greater than that of b. This is a contradiction since, bwas joined with a, so there is guaranteed to be a code- word of length 1. (c) Prove that if all characters occur with frequency less than 1/3, then there is guaranteed to be no codeword of length 1. programmingexamhelp.com
  • 6. w(A) + w(B) + fx < 1. This is a contradiction. Since the sum of all weights in the subtree has to add up to 1. Solution: There have to be at least 4 symbols in the alphabet. Assume by contradic- tion that there is a codeword of length 1. The codeword of length 1 will branch from the root of the tree. WLOG say it has frequenct fx. By construction of the Huffman code tree, it has to have been merged with a subtree, that is a result of two subtrees (possibly leaves), call them A and B. Both A and B have to have cumulative weight less than fx, since this last element was pulled last from the priority queue. Then, since fx ≤ 1/3 by assumption that all characters occur with frequency less than 1/3, programmingexamhelp.com