Quiz 11 Solutions
.pdf
keyboard_arrow_up
School
Pennsylvania State University *
*We aren’t endorsed by this school
Course
465
Subject
Computer Science
Date
Dec 6, 2023
Type
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
Related Questions
Correct answer will be upvoted else Multiple Downvoted. Computer science.
Here gcd(x,y) means the best normal divisor (GCD) of integers x and y, and lcm(x,y) indicates the most un-normal numerous (LCM) of integers x and y.
You are given an exhibit an of length n. Each second the accompanying occurs: every component computer based intelligence of the exhibit is supplanted by the result of all components of the cluster (counting itself), that are neighboring the current worth.
Let di be the number of neighboring components to artificial intelligence (counting computer based intelligence itself). The magnificence of the exhibit is characterized as max1≤i≤ndi.
You are given q questions: each inquiry is portrayed by an integer w, and you need to output the excellence of the exhibit after w seconds.
Input
The originally input line contains a solitary integer t (1≤t≤105) — the number of experiments.
The main line of each experiment contains a solitary integer n…
arrow_forward
Use Big O notation to create winesses C and K, such that:
1) f(x) = ax+b is O(x2)
2) explain a condition where the code isn't O(x). also prove witness and graph
***consider the search algorithm***
arrow_forward
The set of letters S consists of 30 As, 6 Bs, 24 Cs, 15 Ds, and 15 Es. The set of letters T consists of 25 As, 20 Bs, 15 Cs, 5 Ds and 35 Es. What is the mutual index of coincidence between sets S and T? Leave your answer as a fraction in lowest terms
arrow_forward
Correct answer will be upvoted else downvoted. Computer science.
Officially, you should find a cluster b1,b2,… ,bn, to such an extent that the arrangements of components of exhibits an and b are equivalent (it is identical to cluster b can be found as a cluster a with some reordering of its components) and ∑i=1nMEX(b1,b2,… ,bi) is expanded.
MEX of a bunch of nonnegative integers is the negligible nonnegative integer to such an extent that it isn't in the set.
For instance, MEX({1,2,3})=0, MEX({0,1,2,4,5})=3.
Input
The primary line contains a solitary integer t (1≤t≤100) — the number of experiments.
The primary line of each experiment contains a solitary integer n (1≤n≤100).
The second line of each experiment contains n integers a1,a2,… ,an (0≤ai≤100).
Output
For each experiment print an exhibit b1,b2,… ,bn — the ideal reordering of a1,a2,… ,an, so the amount of MEX on its prefixes is amplified.
If there exist different ideal answers you can view as any
arrow_forward
1) In each problem determine a suitable EA algorithms (GA. the problem. , ES, Memetic, PSO, ....) to solve Problem EA Algorithm We want to solve a problem by some by CPU parallel processing with integer representation Solve a real representation and distributed problem Solve a real representation problem centrally Solve a discrete problem centrally Combine an EA method with Simulated Annealing to increase the speed and efficiency of algorithm A problem that its fitness changes each minutes A local search method to avoiding trap to the local minimum
arrow_forward
Correct answer will upvoted else downvoted.
segment of place where there is length n there are k climate control systems: the I-th climate control system is set in cell artificial intelligence (1≤ai≤n). At least two climate control systems can't be put in a similar cell (for example all man-made intelligence are particular).
Each climate control system is characterized by one boundary: temperature. The I-th climate control system is set to the temperature ti.
Illustration of portion of length n=6, where k=2, a=[2,5] and t=[14,16].
For every cell I (1≤i≤n) discover it's temperature, that can be determined by the equation
min1≤j≤k(tj+|aj−i|),
where |aj−i| means outright worth of the distinction aj−i.
As such, the temperature in cell I is equivalent to the base among the temperatures of forced air systems, expanded by the separation from it to the cell I.
How about we take a gander at a model. Consider that n=6,k=2, the main forced air system is put in cell a1=2 and…
arrow_forward
Discuss on the following example how the two heuristics in the Boyer-Moore algorithm can lead to faster pattern matching as compared to a brute force search. Please include diagrams into the solution.
Text string:
This is an elaborate example.
Pattern string:
exa
Note: All whitespaces in between each word and symbol need to be considered as characters.
arrow_forward
k-center clustering,k= 10. Implement the greedy algorithm for Mnist data (test data only) -- (dont implement K-mean)
arrow_forward
Machine Learning and Stats)
Show the first two iterations (after the initialization) of the k-means clustering algorithm (show centers and assignments of data points to clusters) for the following 2D data set: (4, 2), (0, 1), (1, 4), (2, 8), (3, 5), (8, 8), (3, 3), (10, 10), (20, 18), and (12, 9).
Assume the number of centers is equal to 2 and the centers are initialized to (1, 1) and (7, 8).
arrow_forward
solve the following questions
Q1Let the string having length eight of an arrays is defined as ;
01001010 ii. 01101101
Apply the definition of propositional logic conjunction and disjunction on it.
Q2
a). Define pandent vertex and isolated vertex by giving example.
(b). Show that “¬ p v q” is logically equivalent to “pq”.
Q3
a). Consider the propositional function (,) defined by ;
What is the truth value of (-2,4,-5)?
What is the truth value of (6-,2,8)?
(b). Write down the difference between universal quantifier and existential quantifier by giving
examples.
Q4 Let ‘H’ and ‘G‘ are two non-empty sets which are defined as;
and modulus function defined by;
Check the defined absolute value function for injective.
Q5
Given a simple graph “N” as below in figure ;
graph is attached below
Check it for the following ;
Find chromatic…
arrow_forward
Please answer all 4 questions in detailes. Number 3 is already answered it needs graph which I already provided. Thanks
1. What are the worst-, average-, and best-case asymptotic run times for each of the algorithms you implemented? Give intuitive arguments as to why these are the asymptotic run times.
2. Under what circumstances are these asymptotic run times achieved (i.e. for what kind of vectors, sorted, reversed, something else)?
3. Generate three graphs, one for best-, average-, and worst-case scenarios, using the data collected in your experiments and the plotData executable provided on Blackboard. plotData takes three arguments: (a) --data is the file holding the relevant data. (b) --case should be Best, Worst, or Average. (c) --save is the file where the resulting figure will be saved. For example, ./plotData --data best.csv --case Best --save best_fig generates figures for best-case run times in the file best.csv and saves the figure as best_fig.png.
4. For each of the graphs…
arrow_forward
Solve subparts 7a,7b and 7c
arrow_forward
Correct answer will be upvoted else downvoted. Computer science.
You are given an integer n and a cluster a1,a2,… ,an. You should reorder the components of the cluster an in such manner that the amount of MEX on prefixes (I-th prefix is a1,a2,… ,computer based intelligence) is expanded.
Officially, you should find an exhibit b1,b2,… ,bn, to such an extent that the arrangements of components of clusters an and b are equivalent (it is comparable to cluster b can be found as a cluster a with some reordering of its components) and ∑i=1nMEX(b1,b2,… ,bi) is expanded.
MEX of a bunch of nonnegative integers is the insignificant nonnegative integer to such an extent that it isn't in the set.
For instance, MEX({1,2,3})=0, MEX({0,1,2,4,5})=3.
Input
The principal line contains a solitary integer t (1≤t≤100) — the number of experiments.
The principal line of each experiment contains a solitary integer n (1≤n≤100).
The second line of each experiment contains n integers…
arrow_forward
%Encode A1, b1 and x1 as the vector of unknowns.
A1 =
b1 =
syms
xv1 =
%Check the size of A, set it as m1 and n1
[m1,n1] =
%Augment A and b to form AM1
AM1 =
%Solve the Reduced Rwo Echelon of AM1.
RREFA1 =
%Collect the last column and set as bnew1, set the remaining elements as Anew1
bnew1=
Anew1 =
%Check if Anew is an identity matrix, if it is, bnew is the solution
if Anew1 =eye(m1,n1)
Root1 = bnew1
else
display("No Solution")
end
%Augment the matrix A1 with the identity Matrix of the same size, set the result as AMI1
AMI1 =
%Find the reduced row echelon form of AMI1, set the result as RREFAI1
RREFAI1=
%Collect the second half of the matrix as AInew1, set the remaining elements as AIold1
AInew1=
AIold1 =
%Check if AIold1 is an identity matrix, if it is, AInew1 is the inverse
%Encode A2, b2 and xv2 as the vector of unknowns.
A2 =
b2 =
syms
xv2 =
%Check the size of A2, set it as m2 and n2
[m2,n2] =
%Augment A2 and b2 to form AM2
AM2 =
%Solve the…
arrow_forward
Assume for an undirected graph with 6 vertices and 6 edges that a vertex index requires 3 bytes, a pointer requires 5 bytes, and that edge weights require 3 bytes. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency matrix.
arrow_forward
Decide whether each of the following relations on the set {1, 2, 3, 4, 5} is a partial order or not using directed graphs.
(1, 2), (1, 1), (2, 3), (2, 2), (1, 3), (1, 4), (1, 5), (3, 3), (2, 5), (2, 4), (4, 4), (5, 4), (5, 5)}
arrow_forward
Answer True or False to the following claims:
a. Let G be a connected graph on 42 vertices and G contains exactly one cycle.
The G must contain exactly 42 edges.
b. There exists a graph on 42 vertices in which every path has length at most 2.
(Recall that a path is not permitted to use the same edge twice in a row.)
c. Let G1 be a graph on 5 vertices and 9 edges.Let G2 be a graph on 5 vertices and 9 edges.Then G1 and G2 are necessarily isomorphic.
arrow_forward
Given the complement of a graph G is a graph G' which contains all the vertices of G, but for each unweighted edge that exists in G, it is not in G', and for each possible edge not in G, it is in G'. What logical operation and operand(s) can be applied to the adjacency matrix of G to produce G'?
AND G's adjacency matrix with 0 to produce G'
XOR G's adjacency matrix with 0 to produce G'
XOR G's adjacency matrix with 1 to produce G'
AND G's adjacency matrix with 1 to produce G'
arrow_forward
5
Consider the degree-4 LFSR given by x to the power of 4 space plus space x squared space plus space x space plus space 1. Assume that the LFSR is initialized with the string left parenthesis s subscript 0 s subscript 1 s subscript 2 s subscript 3 right parenthesis equals left parenthesis 0110 right parenthesis. How long is the cycle generated?
arrow_forward
Decide whether each of the following relations on the set {1, 2, 3, 4} is a total order or not using directed graphs.
(1, 1), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 3), (3, 4), (4, 1), (4, 4)}
arrow_forward
Mattlan ataach screenshot of graph.
Gen ate sets of information (xi, Yi) utilizing = (0 : 0.1 : 2.5)';y=erf(x); in MATLAB. Expect that the result y(t) can be approximated by a 6th - th degree polynomial as far as x(t) (counting a consistent predisposition term, so seven dad rameters altogether): _y(t) = 0₁ + 0₂x(1) + 03x² (1) + 04x³ (1) + 05xª (1) + 0x³ (1) + 07xº (1) Settle for the coefficients 0₁, I = 1,2,3,4,5,6,7 utilizing clump least squares. Com-pare the outcome with the MATLAR capability "polyfit.".
arrow_forward
Discuss the principles and applications of Depth-First Search (DFS) algorithm in graph traversal. Include the following subparts:
a) Explain the working principles and steps involved in Depth-First Search. b) Analyze the time complexity of Depth-First Search and discuss its efficiency in different types of graphs. c) Discuss the space complexity of Depth-First Search and explain the memory requirements during its execution. d) Compare Depth-First Search with Breadth-First Search (BFS) and highlight the differences in their traversal strategies.
arrow_forward
What is a growth function? Describe Big-O, Big-Omega and Big-Theta in your own words (ensure originality). Make sure to show representation of each growth function separately (using graph).
arrow_forward
Correct answer will be upvoted else downvoted. Computer science.
It might have been a simple undertaking, yet it worked out that you ought to observe a few guidelines:
Before all else, you select any sure integer x.
Then, at that point, you do the accompanying activity n times:
select two components of cluster with total equivalents x;
eliminate them from an and supplant x with limit of that two numbers.
For instance, if at first a=[3,5,1,2], you can choose x=6. Then, at that point, you can choose the second and the third components of a with total 5+1=6 and toss them out. After this activity, x equivalents 5 and there are two components in cluster: 3 and 2. You can toss them out on the following activity.
Note, that you pick x before the beginning and can't transform it as you need between the activities.
Decide how could you act to toss out all components of a.
Input
The main line contains a solitary integer t (1≤t≤1000) — the number of experiments.…
arrow_forward
1) Select the intention of the following machine learning algorithms:
from sklearn.neighbors import KNeighborsClassifier
classifier = KNeighborsClassifier(n_neighbors = 5, metric = 'minkowski', p = 2)
classifier.fit(X_train, y_train)kmeans = KMeans(n_clusters = 5, init = 'k-means++', random_state = 42)
y_kmeans = kmeans.fit_predict(X)
Group of answer choices
a. overfit the data for classification and underfit the data for the clustering
b. Look for 5 closest neighbors and form 5 clusters
c. Only form 5 clusters
d. underfit the data for classification and overfit the data for the clustering
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Correct answer will be upvoted else Multiple Downvoted. Computer science. Here gcd(x,y) means the best normal divisor (GCD) of integers x and y, and lcm(x,y) indicates the most un-normal numerous (LCM) of integers x and y. You are given an exhibit an of length n. Each second the accompanying occurs: every component computer based intelligence of the exhibit is supplanted by the result of all components of the cluster (counting itself), that are neighboring the current worth. Let di be the number of neighboring components to artificial intelligence (counting computer based intelligence itself). The magnificence of the exhibit is characterized as max1≤i≤ndi. You are given q questions: each inquiry is portrayed by an integer w, and you need to output the excellence of the exhibit after w seconds. Input The originally input line contains a solitary integer t (1≤t≤105) — the number of experiments. The main line of each experiment contains a solitary integer n…arrow_forwardUse Big O notation to create winesses C and K, such that: 1) f(x) = ax+b is O(x2) 2) explain a condition where the code isn't O(x). also prove witness and graph ***consider the search algorithm***arrow_forwardThe set of letters S consists of 30 As, 6 Bs, 24 Cs, 15 Ds, and 15 Es. The set of letters T consists of 25 As, 20 Bs, 15 Cs, 5 Ds and 35 Es. What is the mutual index of coincidence between sets S and T? Leave your answer as a fraction in lowest termsarrow_forward
- Correct answer will be upvoted else downvoted. Computer science. Officially, you should find a cluster b1,b2,… ,bn, to such an extent that the arrangements of components of exhibits an and b are equivalent (it is identical to cluster b can be found as a cluster a with some reordering of its components) and ∑i=1nMEX(b1,b2,… ,bi) is expanded. MEX of a bunch of nonnegative integers is the negligible nonnegative integer to such an extent that it isn't in the set. For instance, MEX({1,2,3})=0, MEX({0,1,2,4,5})=3. Input The primary line contains a solitary integer t (1≤t≤100) — the number of experiments. The primary line of each experiment contains a solitary integer n (1≤n≤100). The second line of each experiment contains n integers a1,a2,… ,an (0≤ai≤100). Output For each experiment print an exhibit b1,b2,… ,bn — the ideal reordering of a1,a2,… ,an, so the amount of MEX on its prefixes is amplified. If there exist different ideal answers you can view as anyarrow_forward1) In each problem determine a suitable EA algorithms (GA. the problem. , ES, Memetic, PSO, ....) to solve Problem EA Algorithm We want to solve a problem by some by CPU parallel processing with integer representation Solve a real representation and distributed problem Solve a real representation problem centrally Solve a discrete problem centrally Combine an EA method with Simulated Annealing to increase the speed and efficiency of algorithm A problem that its fitness changes each minutes A local search method to avoiding trap to the local minimumarrow_forwardCorrect answer will upvoted else downvoted. segment of place where there is length n there are k climate control systems: the I-th climate control system is set in cell artificial intelligence (1≤ai≤n). At least two climate control systems can't be put in a similar cell (for example all man-made intelligence are particular). Each climate control system is characterized by one boundary: temperature. The I-th climate control system is set to the temperature ti. Illustration of portion of length n=6, where k=2, a=[2,5] and t=[14,16]. For every cell I (1≤i≤n) discover it's temperature, that can be determined by the equation min1≤j≤k(tj+|aj−i|), where |aj−i| means outright worth of the distinction aj−i. As such, the temperature in cell I is equivalent to the base among the temperatures of forced air systems, expanded by the separation from it to the cell I. How about we take a gander at a model. Consider that n=6,k=2, the main forced air system is put in cell a1=2 and…arrow_forward
- Discuss on the following example how the two heuristics in the Boyer-Moore algorithm can lead to faster pattern matching as compared to a brute force search. Please include diagrams into the solution. Text string: This is an elaborate example. Pattern string: exa Note: All whitespaces in between each word and symbol need to be considered as characters.arrow_forwardk-center clustering,k= 10. Implement the greedy algorithm for Mnist data (test data only) -- (dont implement K-mean)arrow_forwardMachine Learning and Stats) Show the first two iterations (after the initialization) of the k-means clustering algorithm (show centers and assignments of data points to clusters) for the following 2D data set: (4, 2), (0, 1), (1, 4), (2, 8), (3, 5), (8, 8), (3, 3), (10, 10), (20, 18), and (12, 9). Assume the number of centers is equal to 2 and the centers are initialized to (1, 1) and (7, 8).arrow_forward
- solve the following questions Q1Let the string having length eight of an arrays is defined as ; 01001010 ii. 01101101 Apply the definition of propositional logic conjunction and disjunction on it. Q2 a). Define pandent vertex and isolated vertex by giving example. (b). Show that “¬ p v q” is logically equivalent to “pq”. Q3 a). Consider the propositional function (,) defined by ; What is the truth value of (-2,4,-5)? What is the truth value of (6-,2,8)? (b). Write down the difference between universal quantifier and existential quantifier by giving examples. Q4 Let ‘H’ and ‘G‘ are two non-empty sets which are defined as; and modulus function defined by; Check the defined absolute value function for injective. Q5 Given a simple graph “N” as below in figure ; graph is attached below Check it for the following ; Find chromatic…arrow_forwardPlease answer all 4 questions in detailes. Number 3 is already answered it needs graph which I already provided. Thanks 1. What are the worst-, average-, and best-case asymptotic run times for each of the algorithms you implemented? Give intuitive arguments as to why these are the asymptotic run times. 2. Under what circumstances are these asymptotic run times achieved (i.e. for what kind of vectors, sorted, reversed, something else)? 3. Generate three graphs, one for best-, average-, and worst-case scenarios, using the data collected in your experiments and the plotData executable provided on Blackboard. plotData takes three arguments: (a) --data is the file holding the relevant data. (b) --case should be Best, Worst, or Average. (c) --save is the file where the resulting figure will be saved. For example, ./plotData --data best.csv --case Best --save best_fig generates figures for best-case run times in the file best.csv and saves the figure as best_fig.png. 4. For each of the graphs…arrow_forwardSolve subparts 7a,7b and 7carrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education