Prove correctness of the given algorithm

Assignment Help Data Structure & Algorithms
Reference no: EM13974755

Prove correctness of the following algorithm which is used to determine if a list numbers is a part of other list of numbers. For example for inputs List1=[1,2,3] and List2=[5,6,1,7,2,5,6,3], the algorithm will return "List1 is part of List2" and list of positions [2,4,7]. Algorithm in Python:

def sublist(List1, List2, l1, l2):
if l1 == 0 or l2==0:
print ("List1 is not part of List2")
j=0
i=0
positions=[]
while j
if List1[j] == List2[i]:
positions.append(i)
j+=1
else:
i+=1
if len(positions)==0:
return print ("List1 is not part of List2")
else:
return print ("List1 is part of List2 "+str(positions))

Reference no: EM13974755

Questions Cloud

Examine the budgetary constraints : Examine the budgetary constraints that correctional officials work with as they operate correctional facilities. Determine the major trade-offs made between the policy for proper funding and the practice of proper funding to prevent recidivism. Pr..
Company interest expense for the year : Income Statement (EBIT) was $6 million, and the company pays a 40 percent tax rate. What was the company's interest expense for the year? [Hint: Divide $3 million by (1 - T) = 0.6 to find taxable income.]
Calculate the price elasticity of demand for type b : Calculate the price elasticity of demand for Type B consumers at the monopolist's profit maximizing price.
Interest on outstanding balances paid monthly : As a jewelry store manager, you want to offer credit, with interest on outstanding balances paid monthly. To carry receivables, you must borrow funds from your bank at a nominal 6%, monthly compounding.
Prove correctness of the given algorithm : Prove correctness of the following algorithm which is used to determine if a list numbers is a part of other list of numbers. For example for inputs List1=[1,2,3] and List2=[5,6,1,7,2,5,6,3], the algorithm will return "List1 is part of List2" and ..
Account balances at december : The trial balance for K and J Nursery, Inc., listed the following account balances at December 31, 2016, the end of its fiscal year: cash, $19,000; accounts receivable, $14,000; inventories, $28,000; equipment (net), $83,000; accounts payable, $17..
Assessing risk over the past several years : How effective do you think quantitative tools have been at measuring and assessing risk over the past several years? Why?
Difference between complicity and vicarious liability : Discuss the difference between complicity and vicarious liability. Describe which crimes might involve complicity and which crimes might involve vicarious liability
Indifferent to purchasing the stock : Suppose that, the president, receives a proposal for a new stock. The investment needed to take a position in the stock is $50 million, it will have an expected return of 15 percent, and its estimated beta coefficient is 2.0. Shouldthe new stock b..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Dependency diagram reflects a table that is in

dependency diagram reflects a table that is in

  Describe the osi reference model and tcpip protocol

in this assignment you will be in the role of dave baker the senior system administrator from minnesota consulting

  Multiple choice - high school excel 2003

Cell E23 has a date value and you want to place that date on an invoice prefaced with the text located in B15. Determine the command to do that?

  Prepare a flowchart chart to print the largest number

Write a flow chart to print the largest of any three numbers - Prepare a flowchart chart to print the largest number.

  Clerical office placement setting

Determine what other databases would be known to benefit a clerical or job placement organization using databases?

  Prove that there can be at most 13 distinct common entries

Tyrell-III has n replicants and each has a particular model specification. There are many models. Unfortunately, there was an insurgency on the planet and some of the replicants destroyed a critical database that held replicant data.

  Create a decision tree diagram for selection of a cell phone

Use Microsoft Visio, PowerPoint, or Word to create a decision tree diagram for the selection of a cell phone. Address risk in your decision tree

  True or false about networking

2- A print queue must be set up for every printer on the network served by a print server. True False

  Perform an insertion sort on the file pointed

Using only the local data already supplied in FileSort, perform an insertion sort on the file pointed to by fd. Use lseeks for this; do not try to create any sort of array or list. An array-based version of insertion is supplied for your reference.

  Design an algorithm to find the selling price of item sold

To make a profit, the prices of the items sold in a furniture store are marked up by 60%. Design an algorithm to find the selling price of an item sold at the furniture store. What information do you need to find the selling price?

  Topics to cover in your written reportbull lan bull wan

topics to cover in your written reportbull lan bull wan bull leased circuits private business circuits rented from a

  Evaluate the reliability of the data mining algorithms

the development of complex algorithms that can mine mounds of data that have been collected from people and digital

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