Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS6515 Exam 1 Prep: Dynamic Programming Algorithms, Exams of Nursing

A comprehensive set of exercises and questions related to various algorithms and concepts in computer science, including knapsack problems, longest increasing subsequences, longest common subsequences, edit distance, and the master theorem. It offers a valuable resource for students preparing for cs6515 exam 1, covering key topics and providing insights into problem-solving techniques.

Typology: Exams

2024/2025

Available from 02/11/2025

smart-scores
smart-scores 🇺🇸

5

(2)

6.8K documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download CS6515 Exam 1 Prep: Dynamic Programming Algorithms and more Exams Nursing in PDF only on Docsity!

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 |!|- |!|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

What |!|are |!|the |!|components |!|of |!|the |!|master |!|theorem |!|and |!|when |!|can |!|you |!|use |!|it? |!|- |!|correct |!| answer |!| In |!|terms |!|of |!|the |!|master |!|theorem, |!|what |!|would |!|be |!|a |!|result |!|that |!|would |!|provide |!|O(nlogn) |!| time? |!|- |!|correct |!|answer |!| Consider |!|w_16. |!|For |!|what |!|power |!|k |!|is |!|(ω_16)^k |!|= |!|-1? |!|- |!|correct |!|answer |!| (ω_16)^8; This |!|is |!|because |!|it |!|adds |!|180*(7/8) |!|to |!|(w_16)^ Also, |!|zero |!|exponent |!|makes |!|0, |!|that |!|would |!|be |!|(w_16)^ Consider |!|the |!|n-th |!|roots |!|of |!|unity |!|for |!|n |!|=16. |!|WHat |!|is |!|ω_16 |!|in |!|polar |!|coordinates? |!|- |!|correct |!| answer |!| At |!|point |!|0, |!|polar |!|coordinates |!|are |!|(r, |!|theta) |!|== |!|(1, |!|2pie/2), |!|if |!|n |!|= |!|16, |!|then |!|it |!| becomes

  • |!|(1, |!|2pie/2)^16 |!|== |!|(1,2pie/16) |!|== |!|(1, |!|pie/8) Consider |!|ω_16. |!|For |!|what |!|power |!|k |!|is |!|(ω_16)^k |!|= |!|-ω_16? |!|- |!|correct |!|answer |!| it |!|is |!|(ω_n)^(1+ (n/2)), |!|in |!|the |!|case |!|of |!|ω_16, |!|n/2 |!|= |!|8, |!|(ω_16)^(1+8) |!|= |!|(ω_16)^ Consider |!|ω_16. |!|For |!|what |!|power |!|k |!|(ω_16)^-1 |!|= |!|ω16^k? |!|In |!|other |!|words, |!|for |!|what |!|k |!|is |!|ω |!|* |!|(ω_16)^k |!|= |!|1? |!|- |!|correct |!|answer |!| k |!|== |!| 15 This |!|is |!|because |!|(ω_16)^16 |!|== |!|(ω_16)^ For |!|what |!|power |!|k |!|is |!|(ω_16)^k |!|= |!|(ω_8)^2? |!|- |!|correct |!|answer |!| k |!|== |!| 4 In |!|terms |!|of |!|radians, |!|what |!|is |!|the |!|imaginary |!|axis? |!|- |!|correct |!|answer |!| what |!|is |!|the |!|significance |!|of |!|z |!|= |!|a |!|+ |!|bi |!|- |!|correct |!|answer |!| it |!|can |!|describe |!|a |!|point |!|in |!|a |!| cartesian |!|plane How |!|do |!|you |!|convert |!|the |!|cartesian |!|coordinates |!|(a,b) |!|to |!|polar |!|coordinates? |!|- |!|correct |!|answer |!| (a,b) |!|= |!|rcos(theta), |!|rsin(theta)

what |!|is |!|euler's |!|formula? |!|- |!|correct |!|answer |!| cos(theta) |!|+ |!|isin(theta) |!|= |!|e^(i*theta) what |!|degree |!|is |!|-1 |!|in |!|terms |!|of |!|polar |!|coordinates? |!|what |!|are |!|the |!|polar |!|coordinates? |!|- |!|correct |!| answer |!| 180 |!|degrees |!|(positive |!|starts |!|on |!|the |!|right |!|side)

  • |!|(1, |!|pie)
  • |!|What |!|is |!|the |!|radian |!|coordinates |!|which |!|degree |!|= |!|0?
  • |!|How |!|would |!|we |!|add |!| 180 |!|degrees |!|to |!|it? |!|- |!|correct |!|answer |!| - |!|(r,theta)
  • |!|(r, |!|theta) |!|* |!|(1,pie) what |!|is |!|meant |!|by |!|roots |!|of |!|unity? |!|- |!|correct |!|answer |!| 1 |!|to |!|be |!|exact
  • |!|What |!|numbers |!|can |!|be |!|used |!|when |!|n |!|= |!| 4 |!|for |!|the |!|roots |!|of |!|unity?
  • |!|Can |!|you |!|describe |!|why |!|that |!|is |!|the |!|case? |!|- |!|correct |!|answer |!| 1,-1,i, |!|-i At |!|what |!|point |!|does |!|the |!|roots |!|of |!|unity |!|repeat: |!|essential, |!|what |!|does |!|n |!|equal |!|in |!|order |!|to |!|go |!| 360 |!|degrees? |!|- |!|correct |!|answer |!| 8, |!|after |!| 8 |!|it |!|repeats why |!|is |!|omega |!|increased |!|in |!|the |!|exponent |!|in |!|order |!|to |!|traverse |!|through |!|the |!|roots |!|of |!|unity? |!|- |!|correct |!|answer |!| theta |!|= |!|2pie/n, |!|and |!|omega_n |!|= |!|(1, |!|2pie/n). |!|Multiply |!|them |!|together |!|to |!| increase |!|each |!|step what |!|is |!|the |!|point |!|on |!|the |!|roots |!|of |!|unity |!|circle |!|(using |!|omega) |!|where |!|it |!|is |!|zero |!|degrees? |!|- |!| correct |!|answer |!| w^0_n |!|== |!| 1 why |!|is |!|the |!|point |!|before |!|ω^(n-1) |!|right |!|before |!|w^n? |!|- |!|correct |!|answer |!| This |!|describes |!|the |!| step |!|(whether |!|it |!|is |!|in |!|4ths, |!|8ths, |!|or |!|16ths, |!|right |!|before |!|reaching |!|radian |!|2piei/n, |!|whether |!|is |!| the |!|degree |!|of |!|"0") what |!|is |!|another |!|way |!|to |!|express |!|-ω_16?? |!|- |!|correct |!|answer |!| ω^9_16, |!|this |!|is |!|because |!|it |!| moves |!|1/16 |!|into |!|the |!|lower |!|left |!|quartile

You |!|need |!|to |!|get |!|the |!|polynomial |!|multiply, |!|what |!|do |!|you |!|do? |!|- |!|correct |!|answer |!| simply |!| multiply, |!|and |!|list |!|from |!|coefficient, |!|to |!|x |!|ascending |!|exponent what |!|are |!|the |!|different |!|types |!|of |!|filtering? |!|- |!|correct |!|answer |!| mean |!|filtering |!|= |!|1/(2m+1) gaussian |!|filtering: |!|f |!|= |!|1/z(e^(-m^2), |!| gaussian |!|blur: |!|2-dim what |!|are |!|the |!|two |!|representations |!|of |!|A(x)? WHich |!|is |!|more |!|convenient |!|for |!|multiplying |!|polynomials? |!|- |!|correct |!|answer |!| 1.) |!|coefficients 2.) |!|values: |!|A(x_1), |!|A(x_2)....A(x_n) Values |!|are |!|more |!|efficient |!|to |!|do |!|so What |!|is |!|more |!|efficient |!|in |!|terms |!|of |!|complexity? |!|Polynomial |!|Multiplication |!|with 1.) |!|values |!|or 2.) |!|coefficients |!|- |!|correct |!|answer |!| - |!|values values |!|== |!|O(n) |!|time |!|(from |!| 1 |!|-> |!|2n) coefficients |!|== |!|O(n^2) |!|time What |!|is |!|the |!|solve |!|time |!|for |!|FFT |!|- |!|correct |!|answer |!| O(nlogn) what |!|is |!|the |!|difference |!|between: 1.) |!|((ω_n)^(j)) |!|and 2.) |!|((ω_n)^((n/2)+j)) |!|- |!|correct |!|answer |!| it |!|is |!|the |!|oppose |!|point. |!| (ω_n)^(n/2) |!|== |!|-ω_n so (ω_n)^((n/2)+j |!|== |!|(-ω_n)^j

When |!|calling |!|FFT |!|with |!|the |!|"even" |!|and |!|"odd" |!|partitions |!|of |!|your |!|function |!|(lets |!|say |!|"A"), |!| what |!|happens |!|to |!|"ω"? |!|- |!|correct |!|answer |!| It |!|is |!|squared Why |!|do |!|we |!|square |!|"ω" |!|in |!|FFT? |!|- |!|correct |!|answer |!| Why |!|is |!|omega |!|squared? |!|- |!|correct |!|answer |!| WHat |!|is |!|the |!|FFT |!|algorithm |!|of |!|a |!|single |!|function? |!|- |!|correct |!|answer |!| FFT(A,ω) if |!|n |!|= |!| 1 |!|then |!|return |!|a_ else |!|let |!|Aeven |!|= |!|[a_0, |!|a_2... |!|a_(n-2)] |!|let |!|Aodd |!|= |!|[a_1, |!|a_3... |!|a_(n-1)] |!|FFT(Aeven, |!|ω^2) |!|= |!|...s_n |!|FFT(Aodd, |!|ω^2) |!|= |!|...t_n |!|for |!|j |!|= |!|n/2 |!|- |!| 1 |!|r_j |!|= |!|s_j |!|+ |!|ω^j |!|* |!|t_j |!|r_((n/2)+j) |!|= |!|s_j |!|- |!|w^j |!|* |!|t_j In |!|the |!|FFT |!|algorithm, |!|why |!|does |!|"j" |!|in |!|the |!|last |!|section |!|only |!|go |!|to |!|(n/2 |!|- |!|1)? |!|- |!|correct |!| answer |!| This |!|is |!|because |!|each |!|portion |!|performs |!|half |!|of |!|the |!|function, |!|similar |!|to |!|the |!|root |!| unity |!|circle |!|traversal What |!|is |!|the |!|difference |!|between |!|FFT |!|of |!|one |!|item |!|vs |!|FFT |!|multiplication |!|of |!|two |!|functions? |!|- |!| correct |!|answer |!| - |!|ω |!|is |!|not |!|squared

  • |!|there |!|is |!|no |!|odd |!|even |!|separation
  • |!|coefficients |!|produced |!|are |!|n |!|= |!| 0 |!|to |!|2_n |!|-1, |!|same |!|for |!|the |!|only |!|j |!|loop
  • |!|lastly, |!|you |!|multiply |!|the |!|coefficients |!|together
  • |!|then |!|have |!|to |!|do |!|the |!|inverse |!|FFT

2.) |!|a.) |!|M_n(ω_n)^-1 |!|A |!|= |!|a b.) |!|(1/2) |!| |!|M_n((ω_n)^-1) 3.) |!|a |!|= |!|(1/2)FFT(A, |!|(ω_n)^n-1) What |!|is |!|the |!|direction |!|of |!|roots |!|of |!|unity |!|calculation |!|with |!|FFT |!|vs |!|inverse |!|FFT? |!|- |!|correct |!| answer |!| inverse |!|FFT |!|== |!|counterclockwise FFT |!|== |!|clockwise For |!|(ω_n)^2, |!|what |!|is |!|its |!|multiplicative |!|inverse? More |!|precisely, |!|for |!|what |!|power |!|k |!|is |!|(ω_n)^k |!|× |!|(ω_n)^2 |!|= |!|1? |!|- |!|correct |!|answer |!| k |!|= |!|(n-2) It |!|is |!|whatever |!|it |!|takes |!|to |!|get |!|to |!|0, |!|which |!|becomes |!|one so |!|if |!|applied: |!|For |!|(ω_16)^2 |!|*(ω_16)^(16-2) |!|== |!|(ω_16)^16 |!|== |!|(ω_16)^0 |!|== |!| 1 1.) |!|what |!|is |!|the |!|product |!|of |!|the |!|roots |!|of |!|unity? 2.) |!|What |!|about |!|the |!|sum? 3.) |!|What |!|is |!|the |!|sum |!|of |!|Aeven? 4.) |!|what |!|is |!|the |!|sum |!|of |!|Aodd? |!|- |!|correct |!|answer |!| 1.) |!|if |!|it |!|is |!|even, |!|then |!|it |!|is |!|== |!| 1 if |!|it |!|is |!|odd, |!|then |!|it |!|is |!|== |!|- 2.) |!|The |!|sum |!|is |!|== |!|0. |!|This |!|is |!|because |!|(ω_n)^0 |!|== |!| 1 |!|and |!|(ω_n)^(n/2) |!|== |!|-1. |!|These |!|cancel |!| each |!|other |!|out. |!|So |!|if |!|you |!|go |!|through |!|the |!|whole |!|sequence.. |!|it |!|eventually |!|becomes |!|0.

3.) |!|(n/2) |!|* |!| 1 4.) |!|(n/2) |!|* |!|- Why |!|are |!|off |!|diagonal |!|entries |!|not |!|equal |!|to |!|one? |!|- |!|correct |!|answer |!| In |!|the |!|original, |!|it |!|is |!| (ω_n)^k |!|* |!|(ω_n)^-k |!|== |!|(ω_n)^0 |!|== |!| 1 However, |!|the |!|off-diagonal |!|entries |!|are: |!|(ω_n)^k |!|* |!|(ω_n)^-j |!|== |!|(ω_n)^(k-j); |!|so |!|result |!|of |!| 1 |!|is |!|definitely |!|not |!|guaranteed in |!|degrees, |!|what |!|are |!|the |!|values |!|of |!|the |!|following: cos(0) cos(90) cos(180) cos(270) cos(360) Do |!|the |!|same |!|for |!|sin() |!|- |!|correct |!|answer |!| a.) |!| 1 b.) |!| 0 c.) |!|- d.) |!| 0 e.) |!| 1 How |!|to |!|translate |!|i^6 |!|to |!|i |!|or |!|1? |!|- |!|correct |!|answer |!| If |!|it |!|is |!|less |!|than |!| 4 |!|remember |!|the |!|table: i, |!|-1, |!|-i, |!| 1 if |!|greater, |!|do |!|exponent |!|mod |!|4, |!|and |!|whatever |!|the |!|remainder |!|is