Quiz 11 Solutions

.pdf

School

Pennsylvania State University *

*We aren’t endorsed by this school

Course

465

Subject

Computer Science

Date

Dec 6, 2023

Type

pdf

Pages

1

Uploaded by MinisterBadgerMaster464 on coursehero.com

CMPSC 465 Data Structures & Algorithms Fall 2023 Antonio Blanca and Yana Safonova Quiz 11 solution Recitation Section: Date: Monday, Nov 13, 2023 Student Name: PSU Email ID: 1. (2 pts.) Let G be the underlying DAG of over- lapping subproblems in a problem. We may use any topological order of G as an ordering for solv- ing the subproblems to arrive at the global solution. *$ True *$ False Answer True Edges represent dependencies. Every topological ordering goes in an order where all prerequisites are resolved before the subproblems that depend on them. 2. (2 pts.) How long is the longest increasing sub- sequence in the following list of numbers? 7, 8, 1, 3, 9, 5, 6 *$ 2 *$ 3 *$ 4 *$ 5 Answer 4 The longest increasing subsequence is 1, 3, 5, 6. Remember that it need not be contiguous. 3. (2 pts.) What is the edit distance between the strings “AGGT” and “GCT”? *$ 1 *$ 2 *$ 3 *$ 4 Answer 2 For example, insert “A” at the start of the second string, then change the second string’s “C” to “G”. 4. (2 pts.) Which of the following methods can be used to solve the Edit Distance problem? Select all that apply. 939 Dynamic programming 939 Recursion 939 Greedy algorithm Answer Dynamic programming and Recursion The dynamic programming approach shown in class relies on a recurrence relation (as most DP solutions do), so it could be coded as a recursive function. 5. (2 pts.) Using the dynamic programming al- gorithm seen in class, which is the tightest upper bound on the running time to calculate the edit distance between two strings? Assume the longer string is length n . *$ O ( log n ) *$ O ( n ) *$ O ( n 2 ) *$ O ( n 3 ) Answer O ( n 2 ) It uses a table of size n 2 , and each cell in the table takes O ( 1 ) time to calculate. CMPSC 465, Fall 2023, Quiz 11 solution 1
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help