Algorithms Consider the problem of counting, in a given text, the number of stri
ID: 3826308 • Letter: A
Question
Algorithms
Consider the problem of counting, in a given text, the number of strings that start with Y and end with Z. For example, for the string Y AZY Z, there are three such substrings. Design a brute-force algorithm for this problem and determine its efficiency class 4. Given a graph G(V, E) with vertices V and edges E, provide pseudocode for an exhaustive-search algorithm that determines whether or not a Hamiltonian path, a path that uses every vertex in the graph exactly once, exists for G. Determine the complexity of such algorithm as well.Explanation / Answer
3)
This below algortim will check the string is started with y and ended with z..will return true else return false
var string = "Y AZY Z"
VAR index = 0
var equal, equal1
var count = 0
if string[0] == 'Y' || 'y'
equal = true
else
equal = False
while string[i] != ''
string[i++]
count++;
if string[count-1]== 'Z' || 'z'
equal1 = true
else
equal1 = false
if equal == True && equal1 == True
print "String has started with y and ended with z"
else
print "Not Equal"
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.