Questiona nonempty slice of integers l p q is unimodal if

Assignment Help Computer Engineering
Reference no: EM13348963

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

 

Reference no: EM13348963

Questions Cloud

Question1 a microprocessor is clocked at a rate of 5 ghza : question1. a microprocessor is clocked at a rate of 5 ghz.a. how long is a clock cycle?b. what is duration of a
Questionyou are asked to make an employee class with enough : questionyou are asked to make an employee class with enough numbers of data members to store employee data of following
Questionwrite down a script that finds the smallest of : questionwrite down a script that finds the smallest of several nonnegative integers. suppose that the first value read
Question1 date consists of a month day and year frequently : question1. date consists of a month day and year. frequently we represent each of these items as integers. such as july
Questiona nonempty slice of integers l p q is unimodal if : questiona nonempty slice of integers l p q is unimodal if there is some number m isin n such that p le m lt q l p m1 is
Question1 classify two benefits of separating application : question1. classify two benefits of separating application software from database management system.2. classify the
Questionpart 1-study and analyze the principles of : questionpart 1-study and analyze the principles of inheritance. take this term and describe it. examples have to be
Questionsteve smith is a restaurant owner who wants to : questionsteve smith is a restaurant owner who wants to expend his 10000 to modernize his restaurant by adapting it more
Question1 create 15 or more decomposed work packages into 4 : question1. create 15 or more decomposed work packages into 4 levels that are assigned to 5 or extra main tasks 75 line

Reviews

Write a Review

Computer Engineering Questions & Answers

  Pros and cons of chen and crow''s feet notations

What are the pros and cons of Chen and Crow's feet notations.

  Make a set of powerpoint slides

make a set of PowerPoint slides.

  Differences between the unix and window traceroute

Write down the differences between UNIX (or Linux) and Window Traceroute.

  Is snort an hids or an nids

What kind of file is Snort output (logging info) stored in? 7. Can you use Snort with network switches? With hubs? 8. What operating system(s) does Snort run on?

  Explain how css are used in developing websites

explain how CSS are used in developing websites.

  A number of lossless text compression algorithms exist

A number of lossless text compression algorithms exist, though , none of these methods is able to consistently reach its theoretical best-case compression ratio.

  Write a java program that prints all real solutions

make a class QuadraticEquation whose constructor receives the coefficients a, b, c of the quadratic equation. Supply methods getSolution1 and getSolution2 that get the solutions, using the quadratic formula, or 0 if no solution exists. The getSolu..

  Reviewing and reporting microsoft security procedures

For every operating system, review the securities procedure involving, password protection, user account setting, files and folders privacy, and the network protection (this may not be a part of the operating system)

  Program to display a bouncing blue ball inside a jpanel

Write down a program to display a bouncing blue ball inside a JPanel. The ball should begin when the mouse is clicked inside the window. The ball will continue until the window is closed.

  Declare amdahls law

Declare Amdahl's law

  Write a non-recursive version of the process fibonacci

Write a non-recursive version of the process Fibonacci

  Write down a concise summary

Write down a concise summary of what you have learned about physical tamper-resistant devices.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd