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
Rutherford concluded from his calculations that the volume of an atom is filled with protons, neutrons and electrons. is mostly
enyata [817]

Answer:

The answer is "is mostly empty space".

Explanation:

In the given question option numbers is defined, so the explanation to this question  as follows:

The volume of an element holds one mole at high temperatures. The nuclear mass is usually indicated by mole: cc/mol in the \ cm^3. It is also known as a quantity, in which the same molecule was the measured values based on atomic mass as well as the thickness of both, and certain alternatives were wrong which can be explained as follows:

  • atom doesn't fill the protons, neutrons, and electrons.
  • It can't revolve with outside atoms and electrons.

6 0
3 years ago
Select the correct answer.
Mekhanik [1.2K]
The best answer is A
5 0
2 years ago
Read 2 more answers
Which major and minor keys have no sharps or flats apex?
9966 [12]
C major and A minor have no sharps or flats.
5 0
2 years ago
Read 2 more answers
Which of the following statements invokes the GetDiscount function, passing it the contents of two Decimal variables named decSa
ryzh [129]

Answer:

c. decDiscount = GetDiscount(decSales, decRate)                                                                                                                          

Explanation:

Option a. is incorrect because it is using Call word which is not a valid way to invoke a function.

Similarly option b. is also incorrect because it uses Call word to invoke function GetDiscount() which is not a valid way to call a function and also it is passing it the contents of three variables decSales, decRate and decDiscount and as mentioned in the question only two parameters are to be passed to GetDiscount() function.

Option c. is correct as it invokes the function GetDiscount() and passes it the contents of two variables decSales and decRate and assigns this to a variable decDiscount. For example if the GetDiscount() method has to calculate the discount using decSales and decRate then the resultant value of this computation is assigned to decDiscount. So whatever this function returns or computers is assigned to and stored in decDiscount variable. So this is a valid way to invoke a method.

3 0
2 years ago
Renee just got on the freeway to go to her cousin's house in Denver. She is driving 50 miles per hour. Her sister Kim left one h
defon

let's say they catch-up to each other after t hour.

so

in t hour distance travelled by Renee

d = speed × time = 50t

in t hour distance travelled by Kim

d = speed × time = 60(t-1) + 0×1 = 60(t-1)

Note: here kim didn't covered any distance in first hour and in rest t-1 hour it travelled all distance

now.as distance travelled by both is same so

60(t-1) = 50t

60t -60 = 50t

adding 60 both sides

60t = 50t+60

subtracting 50t both sides

60t -50t = 50t+60 - 50t

10t = 60

dividing by 10 both sides

t = 60/10 = 6

so in 6 hour both will catch-up to each other

3 0
3 years ago
Other questions:
  • ________ is a software that interprets java bytecode.
    12·1 answer
  • Design a module named getNumber, which uses a reference parameter variable to accept an Integer argument. The module should prom
    6·1 answer
  • How do I download the Microsoft word on my Hp probook
    8·2 answers
  • You can put a small level on your camera to help keep the horizons straight? TRUE OR FALSE
    14·2 answers
  • Whitch action should a user take to ensure that formatting is applied to a row? A. use the ctrl+a keys. B. highlight the whole t
    11·1 answer
  • If a code word is defined to be a sequence of different letters chosen from the 10 letters A, B, C, D, E, F, G, H, I, and J, wha
    15·1 answer
  • What type of error results from an error in the formatting of the program code?
    13·1 answer
  • Besides earning money why do people work​
    6·2 answers
  • Scenario
    7·1 answer
  • Please answer fast..​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!