• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 12 pages
Exam (elaborations)

CS6515 Exam 1 Prep with verified answers

Document preview thumbnail
Preview 2 out of 12 pages

CS6515 Exam 1 Prep with verified answers

Content preview

CS6515 Exam 1 Prep with verified answers

Knapsack without repetition - correct answer ✔k(0) = 0
|!| |!| |!| |!| |!| |!| |!| |!|




for w = 1 to W:
|!| |!| |!| |!| |!|




if w_j >w: k(w,j) = k(w, j - 1)
|!| |!| |!| |!| |!| |!| |!| |!| |!|




else: K(w,j) = max{K(w, j -1),K(w - w_j, j -1) + v_i}
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!|




knapsack with repetition - correct answer ✔knapsack repeat(w_i....w_n, w_i... w_n, B)
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!|




k(0) = 0 |!| |!|




for i = 1 to n
|!| |!| |!| |!| |!|




if w_i <= b & k(b) <v_i + K(b-w_i)
|!| |!| |!| |!| |!| |!| |!| |!| |!|




then k(b) = v_i + K(b-w_i)
|!| |!| |!| |!| |!| |!|




Longest Increasing Subsequence - correct answer ✔LIS(a_1.... a_n)
|!| |!| |!| |!| |!| |!| |!|




for i = 1 to n
|!| |!| |!| |!| |!|




L(i) = 1
|!| |!| |!|




for j = 1 to n -1
|!| |!| |!| |!| |!| |!| |!|




if a_j < a_i & L(i) < 1 + L(j)
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!|




L(i) = 1 + L(j)
|!| |!| |!| |!| |!|




max = 1 |!| |!|




for i = 2 to n
|!| |!| |!| |!| |!|




if L(i) > L(max) then max = i
|!| |!| |!| |!| |!| |!| |!| |!|




return(L(max))
|!|




longest common subsequence algo - correct answer ✔LCS(X,Y)
|!| |!| |!| |!| |!| |!| |!|




for i = 0 to n: L(i, 0) = 0
|!| |!| |!| |!| |!| |!| |!| |!| |!|




for j = 0 to n: L(0,j) = 0
|!| |!| |!| |!| |!| |!| |!| |!|

, for i = 1 to n
|!| |!| |!| |!| |!|




for j = 1 to n
|!| |!| |!| |!| |!| |!|




if X_i == Y_j:
|!| |!| |!| |!|




L(i,j) = L(i - 1, j - 1) + 1
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!|




else:
|!|




L(i,j) = max(L(i - 1, j),L(i,j-1)
|!| |!| |!| |!| |!| |!|




return(L(i,j)
|!|




longest common substring - correct answer ✔
|!| |!| |!| |!| |!| |!|




what is Big oh of LCS? - correct answer ✔O(n* * 2 )
|!| |!| |!| |!| |!| |!| |!| |!| |!|




what is big Oh of longest common substring? - correct answer ✔O(mn)
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!|




what is important to remember when calculating longest common subsequence as opposed
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!|


to substring? - correct answer ✔substring is very diagonal and plus 1
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!|




subsequence you have to use a max function |!| |!| |!| |!| |!| |!| |!|




Perform longest common substring and subsequence on:
|!| |!| |!| |!| |!| |!|




"abcdaf"

"3bcdf"

What are the recurrences? write down the algorithm and results - correct answer ✔
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!|




if you are presented with a coins (1,5,6,8) and your knapsack is k = 11, what is the
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!|


minimum number of coins, what would be the computational time, and what is the
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!| |!|


recurrence? - correct answer ✔https://www.youtube.com/watch?v=Y0ZqKpToTic
|!| |!| |!| |!|




how to calculate longest increasing substring. Try it using the following:
|!| |!| |!| |!| |!| |!| |!| |!| |!| |!|




541208563 - correct answer ✔It should only require two separate loops: |!| |!| |!| |!| |!| |!| |!| |!| |!| |!|




one to loop to go through to calculate the values
|!| |!| |!| |!| |!| |!| |!| |!| |!|

Document information

Uploaded on
February 11, 2025
Number of pages
12
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Ruiz
3.2
(15)
Sold
107
Followers
4
Items
14206
Last sold
1 day ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions