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

  Prepare a japplet with a jbutton

Prepare a JApplet with a JButton labeled Who is number one and when the user clicks on button, display your favorite sports team. Save the document as JNumberOne.java.

  Benefits of dynamic over static arrays

Discuss the benefits of dynamic over-static arrays. Under what conditions will you choose dynamic arrays?

  Show the brute-force attack against single des

Your task is to show that breaking the scheme is approximately as difficult as a brute-force attack against single DES.

  Write a program to load an array

Write a program to load an array

  Design an algorithm to determine best route for passenger

Consider the following problem: Design an algorithm to determine the best route for a subway passenger to take from one designated station to another in a typical urban subway system similar to those in San Francisco and New York

  Function to swap all the left-right subtrees of binary tree

Write a function, swapSubTrees, that swaps all of the left and right subtrees of a binary tree. write a method singleParent, that returns the number of nodes in a binary tree that have only one child.

  What are digital downloads and digital compression

What can be digitally downloaded and compressed?

  Conversion with unnormalized relation

Nazca Cinemas is a tiny movie theater that would like you to create a movie scheduling database system for them. The theater has 4-screens. Each screens has its own unique ID

  Your implementation of an algorithm has a running time of

your implementation of an algorithm has a running time of 9n3 5n2 -7n 10. your computer scientist contractor says the

  Implement the priorityq class using a heap instead

Implement the PriorityQ class using a heap instead of an array

  Design an adt for a two-color

Design an ADT for a two-color, double-stack ADT that consists of two stacks one "red" and one "blue" and has as its operations color-coded versions of the regular stack ADT operations.

  Discrete perceptron learning algorithm

Implement a classifier for characters L and I using the discrete perceptron learning algorithm. You may use any implementation, Specifications: Use a 3 x 3 binary matrix representation

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