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.:- M9718580

Have any Question?


Related Questions in Computer Engineering

Clientserver model please respond to the followingimagine

"Client/Server Model" Please respond to the following: Imagine that you are a lead developer for social media company and that one of your responsibilities is to help mentor junior developers. The junior developer that y ...

A string in c is simply an array of characters with the

A string in C++ is simply an array of characters with the null character(\0) used to mark the end of the string. C++ provides a set of string handling function in as well as I/O functions in . With the addition of the ST ...

What strategies might help redirect a disruptive student

What strategies might help redirect a disruptive student? What strategies might help an unmotivated student?

Given the following table keynbspand fdsnbspnbsprepair

Given the following table, key and FDs,   REPAIR (RepairInvoiceNumber, RepairDate, RepairCost, RepairEmployeeName, RepairEmployeePhone, SerialNumber, Type, TankCapacity) Candidate Keys: RepairInvoiceNumber, and (RepairDa ...

What is asymmetric information and how does it affect the

What is asymmetric information and how does it affect the consumer or buyer?

Subnetting1 as system administrator you need to create 10

Subnetting 1) As system administrator, you need to create 10 subnets for the Network Address: 192.168.1.0 with a minimum of 10 hosts per subnet. Room for future expansion to more subnets is desirable. Create a table with ...

1 what would be the purpose for a user to protect a

1. What would be the purpose for a user to protect a file from "read" or "write" access by other users? 2. Is there a reason why it would be safer for administrators to use two different accounts when working with a comp ...

Suppose there is a relation ra b c with a b-tree index with

Suppose there is a relation R(A, B, C) with a B+-tree index with search keys (A, B). 1. What is the worst-case cost of finding records satisfying 10 2. What is the worst-case cost of finding records satisfying 10 3. Unde ...

Espn pays the nfl 11 billion per year for 8 yrs for the

ESPN pays the NFL $1.1 Billion per year for 8 yrs for the right to exclusively televise football. What is the NPV of the investment if the parent Disney CO has an opportunity interest rate that is equal to the cost of ca ...

Systems analysis chapter 6 please answer the four questions

Systems analysis chapter 6: Please answer the four questions at the tasks section Campus Bikes is a popular bicycle shop located near a major university. The business has grown and the owner, Mark Turner, wants to instal ...

  • 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