Prove correctness for following

Assignment Help Computer Engineering
Reference no: EM132911

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: EM132911

Questions Cloud

What is the worst-case delay for acknowledging an interrupt : What is the worst-case delay for acknowledging an interrupt
Make an employee class with enough numbers of data members : Make an Employee class with enough numbers of data members
Modify compound interest program : Modify compound interest program
Write down a java implementation : Write down a Java implementation
Prove correctness for following : Prove correctness for following
Can a relation be stored as a sequential file : Can a relation be stored as a sequential file
Study and analyze the principles of inheritance : Study and analyze the principles of inheritance
How to develop a problem definition : How to develop a problem definition
Generate a work breakdown structure code : Generate a Work Breakdown Structure Code

Reviews

Write a Review

Computer Engineering Questions & Answers

  How to expand class linkedlisttype

Expand class linkedListType. Write down a function that returns the info of the kth element of the linked list. If no such factor exists, output an appropriate message.

  What are prospect trends for healthcare informatics

What are prospect trends for healthcare informatics.

  Examine how computer forensics investigations pertain to law

Examine how computer forensics investigations pertain to law

  Design a data structure which supports two operations

Design a data structure which supports two operations 1. Insert(S, x) inserts x into S. 2. Remove-Duplicates(S) removes from S all duplicated values.

  Intermediate programming

Design a program that reads in a text file with drawing commands and then outputs a bitmap with all the items drawn correctly

  Write proper sequence in design of a video rental database

Write proper sequence in design of a video rental database

  How to create the clients by service rep report

How to create the clients by service rep report create mailing label for client table

  Explain the averaging algorithm

Explain the averaging algorithm

  Explain how an enterprise would use 3g, 4g and wwan

Explain how an enterprise would use 3G, 4G and WWAN Use at least three quality resources in this project.

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Implementation of type data structures

How can string and word variable type data structures be implemented?

  How many address lines are needed to access memory

How many address lines are needed to access memory.

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