Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Question

A nonempty slice of integers L [p: q] is unimodal if there is some number m ∈ N such that p ≤ m < q, L [p: m+1] is increasing, and L [m: q] is decreasing. Such a number m, if it exists, is called the mode of L [p: q].

Prove correctness for following -

Precondition: L is a list of integers, p,q ∈ N, and 0 ≤ p < q ≤ len(L).

Postcondition: Return the mode of L[p : q] if L[p : q] is unimodal; otherwise return -1.

Mode(L, p, q)

1) u = p ; v = q-1 ; w= 1
2) while w ?= 0 and u < v :
3) if L[u] < L [u+1]: u= v + 1
4) else if L[ v-1] >l[v]: v=v-1
5) else: w=0
6) if w ?= 0 : return u
7) else: return -1

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9133328

Have any Question?


Related Questions in Computer Engineering

Michelle walker is looking to invest in a three-year bond

Michelle Walker is looking to invest in a three-year bond that makes semi-annual coupon payments at a rate of 5.225 percent. If these bonds have a market price of $990.00, what yield to maturity can she expect to earn?  ...

The police lieutenant in charge of the traffic division

The police lieutenant in charge of the traffic division reviews the number of traffic citations issued by each of the police officers in his division. He finds that the mean number of citations written by each officer is ...

Closure and evaluationresearching for the closure checklist

Closure and EvaluationResearching for the closure checklist and project evaluation a. To prepare for this task, you will be required to provide an annotated bibliography. Write an Annotated Bibliography for three (3) rel ...

1 potassium metal is very reactive with liquid bromine the

1. Potassium metal is very reactive with liquid bromine. The result of the reaction is the formation of a white ionic solid. Explain what happens to these elements when they form an ionic compound and write the formula f ...

Research the fire at the federal aviation administration

Research the fire at the Federal Aviation Administration (FAA) facility in Chicago, Illinois (2014). Provide insight into the following: What went wrong? What went right? Would a risk assessment strategy if employed miti ...

Please respondexplain the properties and characteristics of

PLEASE RESPOND Explain the properties and characteristics of Transmission Control Protocol/Internet Protocol (TCP/IP).

If the annualized five-year rate of return is 15 and if the

If the annualized five-year rate of return is 15%, and if the first year's rate of return is 20%, and if the returns in all other years are equal, what are they? Provide the answer in % with four decimal places without r ...

Question suppose we want to build a b tree that has space

Question : Suppose we want to build a B+ tree that has space for 200,000 data entries in its leaf pages. Each data entry is made up of a key and its corresponding data value. Let us assume the following specifications. E ...

You are requested to design an information technology

You are requested to design an Information Technology Infrastructure for an international nonprofit organization. The organization has six offices, one each in Ohio, Kentucky, Toronto, Michigan, Chicago, and Indiana. Col ...

Question 1 identify the three main types of computer

Question: 1. Identify the three main types of computer software that were discussed in your unit lesson. Within the three main categories, give examples of each and a brief explanation of each. Each explanation/descripti ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As