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
To insert a new slide in an existing presentation, what menu should you select?
Lelechka [254]
You would select add slide if you where using keynote! 
3 0
3 years ago
Read 2 more answers
Manuel owns a small business. He needs to calculate the amount each employee owes in Federal taxes. Manuel should
liraira [26]
I think a database because if he’s calculating then he won’t need a printer or email
6 0
3 years ago
Read 2 more answers
A password checking system that disallows user passwords that are proper names or words that are normally included in a dictiona
nikdorinn [45]
The answer is control
7 0
3 years ago
MLB The Show 17, which simulates professional baseball games, and Madden Football, which simulates professional football games,
insens350 [35]

Answer:

Sports game

Explanation:

5 0
3 years ago
You are tasked with securing a small network for a client in which the following requirements must be met: If a user on the priv
nalin [4]

ANSWER:

E

EXPLANATION:

myHostname = window.location.hostname;

var myTLD = "." + myHostname.substring(myHostname.indexOf("wupload") + "wupload.".length).split(".")[0];

function afterLoad() {

 return

}

ieFixForFileSelectionOnChangeEventTimer = null;

function ieFixForFileSelectionOnChangeEvent(a) {

 $("#siteName").toggle();

 if ($("#inputFileSelection").val() == "") {

   ieFixForFileSelectionOnChangeEventTimer = setTimeout("ieFixForFileSelectionOnChangeEvent()", 200)

 } else {

   $("body")[0].focus()

 }

}

function urlencode(a) {

 return escape(a.toString().replace(/%/g, "%25").replace(/\+/g, "%2B")).replace(/%25/g, "%")

}

$(document).ajaxStart(function() {

 $("body").addClass("ajaxLoading")

});

$(document).ajaxStop(function() {

 $("body").removeClass("ajaxLoading")

});

$(document).ajaxError(function(d, c, a, b) {

 CMApplication.Widgets.Dialog.close();

 CMApplication.Widgets.Dialog.displayMessage(c.responseText, CMApplication.Widgets.Dialog.Types.exception)

});

jQuery.setCookie = function(b, c, a) {

 var d = new Date();

 d.setDate(d.getDate() + a);

 cookieDomain = ".wupload" + myTLD;

 document.cookie = b + "=" + escape(c) + ((a == null) ? "" : ";expires=" + d.toUTCString() + "; path=/;domain=" + cookieDomain + ";")

};

jQuery.getCookie = function(a)

4 0
4 years ago
Other questions:
  • Laura is photographing her son’s baseball game. What ISO setting should she use?
    11·1 answer
  • 1. How does inertia affect a person who is not wearing a seatbelt during a collision? 
    14·2 answers
  • What important information is added to the TCP/IP transport layer header to ensure communication and connectivity with a remote
    13·1 answer
  • In an oligopolistic market, consumer choice is?
    12·2 answers
  • write a program that reads in the length and the width of a rectangular yard . your program should compute the time required ( i
    5·1 answer
  • Which of the following attacks seeks to introduce erroneous or malicious entries into a server's hostname-to-IP address cache or
    5·1 answer
  • Code: ckg-jbqp-hki<br>only girls join❤️​
    11·2 answers
  • Explain different types of networking-based attacks
    5·1 answer
  • What are 3 customizations that can be done using the header/footer section in the customize reports tray?.
    14·1 answer
  • What is communication ????<br>​
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!