Develop the algorithm as a module

  • Thread starter Thread starter teng125
  • Start date Start date
  • Tags Tags
    Algorithm module
AI Thread Summary
The discussion focuses on developing a search algorithm as a module that identifies the presence of a specific integer in an array. The specification outlines that the module should return FOUND as 0 if the number is not present and as the index if it is found. Participants express confusion about the pseudocode and request examples of coding attempts. The conversation emphasizes the importance of understanding control structures for implementing the search logic. Overall, the goal is to create a functional search module that adheres to the given specifications.
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
What are your thoughts? Also, what is a "module"?
 
Last edited:
try to search through the arrays [a] to see whether the number is found or not.If not,proceeds to the second position
 
So can you please show us your first attempt at coding this up?
 
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.
 
Back
Top