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
When you open a new web browser window, you can customize its appearance using the ____ argument of the window.open() method.
goldenfox [79]

Answer:

"options" are the correct answer to the following question.

Explanation:

window.open() function is the function of the javascript which is used by the programmer inside the program, this method opens the new tab or the browser window which depends on the browser setting or the argument of the window.open() function.

In the parameter of this method, we pass the URL, window's name, or the comma separators, or replace current entries.

4 0
3 years ago
Write a program that defines anduses macro MINIMUM2to determine the smallest of two numeric values. Input the valuesfrom the key
lisov135 [29]

Answer:

#include<iostream>

#define MINIMUM2(s1,s2) ((s1<s2?s1:s2))

using namespace std;

int main(){

   //initialization

  int s1,s2;

  //display the message

   cout<<"Enter the number 1: "<<endl;

   cin>>s1;  //read the input

   cout<<"Enter the number 2: "<<endl;

   cin>>s2; //read the input

   //use micros

   int min_Value = MINIMUM2(s1,s2);

   //display

   cout<<"The minimum value is: "<<min_Value<<endl;

    return 0;

}

Explanation:

Micros is the constants of symbols, values, etc.

it is used with the preprocessor directives represented by '#'. it means, the program process the information first before compiling the code.

syntax:

#define macro_name replacement_information

it actually, replace the information written in the macros into the code where we used the macros before the compilation.

In the above code,

we define the macros

#define MINIMUM2(s1,s2) ((s1<s2?s1:s2))

and create the main function and declare the variable.

after that, print the message by using the instruction cout and store the value enter by the user into the variable by using the instruction cin.

then, we use the macros the process copy the information ((s1<s2?s1:s2))

and replace where we call macros in the code.

so, actually before compilation

 int min_Value = MINIMUM2(s1,s2);

the above statement becomes

 int min_Value = ((s1<s2?s1:s2));

the above is a ternary operator, if s1 < s2 gives true then s1 will be the output otherwise s2 will be output.

and finally, we display the output on the screen.

3 0
3 years ago
What is your biggest takeaway on that subject?​
tester [92]

Hi. You have not informed the subject to which this question refers, which makes it impossible for your question to be answered. However, I will try to help you as best I can.

The only way to answer this question is to evaluate the media where the subject in question is being presented. Thus, you must understand this subject, whether reading a text about it or watching a video about it, the important thing is that you understand it and absorb all the teachings it is capable of transmitting.

In this case, you need to evaluate all these teachings which was the most important for you and which represented a very important lesson in your life. This lesson will be the biggest takeaway you've achieved with this subject.

3 0
3 years ago
Which of the following is an example of new and emerging classes of sofware
malfutka [58]
We need to know what was listed :)!
3 0
3 years ago
You have just created this algorithm and want to make it less complex without changing its output. What type of function should
Mariulka [41]

Algorithm analysis is an important part of computational complexities. The complexity theory provides the theoretical estimates for the resources needed by an algorithm to solve any computational task. Analysis of the algorithm is the process of analyzing the problem-solving capability of the algorithm in terms of the time and size required

3 0
3 years ago
Other questions:
  • Given a Scanner reference variable named input that has been associated with an input source consisting of a sequence of strings
    5·2 answers
  • Integrated circuits are made up of _____ and carry an electrical current
    14·1 answer
  • Binary data is written in hexadecimal. For example, when creating a graphic for a website, colors are represented by six hexadec
    12·1 answer
  • Do yall play games..............................................................................................................
    8·2 answers
  • Escribe, en los siguientes cuadros, los conceptos que correspondan
    10·1 answer
  • One interesting application of computers is to display graphs and bar charts. Write an application that reads five numbers betwe
    5·1 answer
  • ____ refers to the order in which values are used with operators.
    9·1 answer
  • An individual posing as an online gamer accesses information stored in an unsuspecting user’s computer by placing a program in h
    11·1 answer
  • .13 LAB: Library book sorting Two sorted lists have been created, one implemented using a linked list (LinkedListLibrary linkedL
    14·1 answer
  • Why not to use settimeout in angular.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!