1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
maria [59]
3 years ago
14

Write the pseudocode for linear search, which scans through the sequence, looking for ν. Using a loop invariant, prove that your

algorithm is correct. Make sure that your loop invariant fulfills the three necessary properties.
Computers and Technology
1 answer:
zavuch27 [327]3 years ago
8 0

Answer:

1 for i = 1 to A.length

2 if A[i] = nu

3 return i

4 return NIL

Explanation:

Loop invariant:

At the start of each iteration of the for loop of lines 1-3, there is no j<i such that A[j]=ν.

Initialization:

At the beginning of the first iteration, we have i=1, so there is no j<i such that A[j]=ν.

Maintenance:

We fix i and assume there is no j<i such that A[j]=ν.

If A[i]=ν, then we return a value, so then there are no more iterations, so the property is preserved.

If A[i]≠ν, then there is no j<i+1 such that A[j]=ν, which is the desired property for the next step.

Termination:

The loop terminates either for i=A.length+1, or if ever we encounter A[i]=ν.

In the first case, then there is no 1≤j≤A.length such that A[j]=ν, and we are correctly returning NIL

In the second case, if we encounter some i such that A[i]=ν, we are correctly returning i.

You might be interested in
Which of the following statements about Java Class Libraries is false: a. Java class libraries consist of classes that consist o
blondinia [14]

Answer:

Statement D is false

D. Java class libraries are not portable = FALSE

Explanation:

Because java class library are portable and JVM (java virtual machine) makes java class library and other java codes portable and platform independent and JVM act as a OS or imaginary CPU for that code.

8 0
3 years ago
Why is a Quality assurance tester needed on a software development team?
arsen [322]

Answer:

Quality assurance testing plays a very crucial role in the process of software development. It saves money and time by spotting bugs and errors early in the software development life-cycle. Software that is newly developed may have inconsistencies, redundancies, and flaws; therefore, proper QA testing is mandatory.

Explanation:

3 0
2 years ago
A _____________ is designed for a individual user.
pishuonlain [190]

Answer:

i don't know it sorry

Explanation:

7 0
3 years ago
The default color scheme is called ____.
notsponge [240]
What program is this regarding?

If it's a Microsoft Office product, the default colour scheme is "office"
5 0
3 years ago
Which of the following statements are true about mobile app development? Select 3 options.
mestny [16]

Answer:

Option 1,4 and 5 are correct.

7 0
2 years ago
Read 2 more answers
Other questions:
  • The item in this illustration that is highlighted is the _____. quick access tool bar view buttons status bar zoom control
    10·2 answers
  • What are some causes of the number of bytes on the wire exceeding the number of bytes being captured?
    6·2 answers
  • Which buttons should you use to publish and change a message on a message board
    6·2 answers
  • In cryptography, the term "Secret algorithm" refers to an algorithm designed in a way that prevents the examination of its inner
    12·2 answers
  • Which statement will properly start the main() function? def main(): def Main def main# def main[]
    14·2 answers
  • A small business has suffered from a cyber attack, what could be the resultant damage​
    10·1 answer
  • Suppose the fixed width of an aside element in a fixed layout is 300 pixels, and the fixed width of its parent element (body) is
    15·1 answer
  • Who would win in a fight iron man or bat man​
    5·2 answers
  • High level languages are closer to machine language than humans yes or no​
    12·2 answers
  • How do we produce quality work in editing audio?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!