-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture "Algorithms", exercise 2 #6
Comments
PREMISEI wrote this in a couple of hours, not continuously but taking some breaks. I've been a little slow and I hope to be faster in the future. ASSUMPTIONAccording to the Oxford Dictionary, a letter is a written or printed sign representing a sound used in speech (https://www.oxfordlearnersdictionaries.com/definition/english/letter_1) . So, for this example, we'll have in mind as input the words "SHOOT" and "SHOUT". LET'S STARTIt is asked to input two words, and after that, to name them F(X) and G(Y) where X and Y indicate respectively the number of signs in the two words. If you want to take the example of SHOOT and SHOUT, we'll assume that SHOOT will be F(5) and SHOUT will be G(5). After that, it is informed that, if the two numbers X and Y are the same, we have a chance that the algorithm will give as output "yes" (i.e. it would mean that the two words had the same sign number). Next passage consists in naming every letter of the two words in numbers, respectively starting from 1 for A and so on. Then it is asked to sum the first and the last number in G(X) and check if is the same as the sum of first and last number in F(Y). If yes, it means that the two words in the input start and end with the same sign. A word has to have at least two signs. So in the next passage the flowline leads to a decision widget to see if the word constists in two signs of more. If the signs are more, the flowline conducts the algorithm to a process widget, through which the algorithm will be able to know how many signs in the words are left, apart from the first and the last sign. (See the photo below) So, if α= X-2=Y-2, where 2 is to exclude the first and last signs of the two words given as input, At this point, what the algorithm have to check is whether the two words are the same or not. So the algorithm will go through a process widget: every remaining sign in the two input words, transformed in number before, will get an indicative name: x₂ x₃ for signs in G(X) ... and y₂ y₃ for signs in F(Y)... If the sum between the x₂ + x₃ ... is equal to the sum between y₂ + y₃ ... , then the agorithm will get as output "yes". |
Hi all, There are a few suggestions I list here that may be useful to improve your diagram and, in general, for even the future diagrams you will have to define:
A note for @teragramgius: what happens if I run the algorithm specifying as input "shoot" and "thoos"? |
All right, you got me🤣 |
OUTPUT:
|
Write the flowchart of an algorithm that takes in input two objects and returns the string “yes” whether the two objects are the same; otherwise, it returns the string “no”.
The text was updated successfully, but these errors were encountered: