Develop the algorithm as a module

  • Thread starter Thread starter teng125
  • Start date Start date
  • Tags Tags
    Algorithm module
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 3K views
teng125
Messages
416
Reaction score
0
Consider the following specification:
pre n >= 1
post search module(a, n, number) = FOUND(a, number)
reads a, n, number
changes -
mem -

Remark: Let i be an integer number. Then, FOUND = 0 iff a does not contain
number and FOUND = i iff a = number. search module is the name of the module
to be developed.
Design a search algorithm that searches for an integer number and that suffices the
above specification. Develop the algorithm as a module. Use the pseudo code notation



smby pls help
thanx
 
Physics news on Phys.org
try to search through the arrays [a] to see whether the number is found or not.If not,proceeds to the second position
 
Also, could you please post a brief reference to the pseudo-code style that you are using? I'm not getting it.
 
I do not understand the pseudocode very well either but I can help...

So you got an integer array. And you're looking for a certain number in the array. So this module is suppose to take care of that.

How would you traditionally sort through a list of things if you were looking for a certain thing in the list? You would start at the top of the list and keep going down until you found the thing you were looking for. Has your teacher taught you anything about control structures yet? If so, then you should be able to figure it out from here.