






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
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
1 / 12
This page cannot be seen from the preview
Don't miss anything!
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
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)
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
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