Explore BrainMass

Algorithms Using Pseudo Code

1. Write an algorithm, using pseudo code, "Word Search": Given a string of letters, identify all substrings that create one of five given words. For example, if the words (arguments) are: structure; such; system; blue; red, then the string jkdistructuredstrusyssystemoon contains the first, third and fifth words, once each.

2. Write an algorithm, using pseudo code, "Consensus algorithm": A group of ten people need to decide which one flavor of ice cream they will all order, out of three options. The algorithm can question and re-question the participants, and present the answers to the participants, until a consensus is reached. This exercise is somewhat more open-ended. Add your assumptions if necessary. Obviously, this algorithm might never result in an answer. Deal with that too.

Solution Preview

Solution for 1st problem

Step 1: Initialize s to the string (which has string in it)
Step 2: Initialize Substr
Step 3: Initialize sLength to length of the string
Step 4: Store the words to search in an array
Step 5: Initialize arrofWords to words of search
Step 6: For I = 1 to ...

Solution Summary

Algorithms for a word search and a consensus are given in pseudo code.