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
Lesson 12: while loops with the farmer. Number 9.
Vikki [24]

Answer:

just repeat the move forward as many times until you get to the hole and fill 1

Explanation:

i think this might work

if it does can i have brainliest

3 0
3 years ago
Read 2 more answers
A ---------------- enable an organization to use cloud computing technology as a means of centralizing access to IT resources by
sp2606 [1]

Answer: Private cloud

Explanation:

In a private cloud it is owned by the organization and its cloud computing technology is utilized by its various departments as a centralized access to its IT resources. Here the authority of the cloud lies entirely to the organization.

7 0
3 years ago
Java variable is the name of a Group of answer choices numeric data value stored in memory data value stored in memory that can
artcher [175]

Answer:

Java variable is the name of a group of data value stored in memory that can change its value but cannot change its type during the program's execution

Explanation:

Generally, a variable is a temporary location in the memory where data are stored in a computer program. Values in the variable can always be change during the course of program execution.

The equal sign ( = ) is use to assign and identify a variable. The value to be stored in the variable is always at the right of the equal sign, while the variable name is always at the left of the equal sign.

5 0
3 years ago
Anwser the question below plz due in 15 mins.
klemol [59]
Novels about Harry Potter, a boy who learns on his eleventh birthday that he is the orphaned son of two powerful wizards and possesses unique magical powers of his own. He is summoned from his life as an unwanted child to become a student … More
Releas
6 0
3 years ago
Consider the following code segment:
Leni [432]

The code segment is an illustration of loops and arrays

<h3>What is a loop?</h3>

A loop is a program statement used to perform repetitive operations

<h3>What is an array?</h3>

An array is a variable used to hold multiple values

<h3>How to analyze the program?</h3>

The loop of the program adds the index 0 elements of the first and the second row of the 2-dimensional array.

From the program, the numbers to add are 1 and 100

The sum of 1 and 100 is 101

Hence, 101 will be displayed when the code segment is executed

Read more about code segments at:

brainly.com/question/26683418

7 0
2 years ago
Other questions:
  • Which of the following statements outputs the value of the gpa member of element 1 of the student array?
    5·1 answer
  • Describe the "Mister Splashy Pants" campaign. How did it start? What happened?
    7·2 answers
  • For your biology class, you will be giving a presentation of the findings of a plant growth experiment. Which application is bes
    7·1 answer
  • In recent years, the amount of time people spend using electronic devices has sharply increased. What are the benefits and downs
    7·1 answer
  • In which situation is coauthoring of presentations primarily utilized?
    9·1 answer
  • Write a for loop to print all the even numbers from 200 to 300.
    14·1 answer
  • Which tabs are expandable and collapsible
    14·1 answer
  • Hey, My paperclips just stoped producing, does anyone have any idea how to start them up again?
    5·1 answer
  • Which two extensions in scratch are correctly matched to their accessibility goals
    11·1 answer
  • For the function below, list 4 ordered pairs for that function.<br> y = 3x + 1
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!