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

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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