Write a python function that implements the algorithm

Assignment Help Computer Engineering
Reference no: EM132138194

A substring is a contiguous sequence of characters from a string. For example, "cde" is a substring of the string "abcdefg". We say that substring s1 is duplicated in string s if s1 shows us in s at least two times, without overlapping. For example, if s == "abcdefbcdgh" then there is a duplicated substring of length 3: "bcd". There is no duplicated substring of length 4 and higher.

a) Write an algorithm in pseudo-code (in file h2.doc) in a function find_dup_str(s, n) that determines whether a string s contains a duplicated substring of a given length n and that returns the first occurring substring of length n that is duplicated (if any) or the empty string, otherwise.

For the example above (s == "abcdefbcdgh") with substring length 3, the substring to be returned is "bcd". With length 2, the algorithm returns "bc", and not "cd". For this value of parameter s, if the length parameter is 4 or more, the algorithm returns "".

Write an algorithm, not a Python program. To get full credit make sure the algorithm has ALL the features required, as explained in the class
material.

b) Create a new file p2.py where you write a Python function find_dup_str(s, n) that implements the algorithm from part a). Parameter s is the original string and n is the length of the substring to look for.

Your implementation must use string slicing. In file p2.py write after the function definition some code that reads a string and a number from the terminal, and then calls find_dup_str(s, n) and prints the result. Use this for testing.

Reference no: EM132138194

Questions Cloud

Confidence interval of the proportion of people : What is the 95% confidence interval of the proportion of people not in favor of the nomination.
By what characteristic can you identify the stars : Project 2 - Cosmology Inquiry: Hubble Deep Field - By what characteristic can you identify the stars? How many stars can you find
Confidence interval for a population mean : If you are constructing a confidence interval for a population mean, for the same confidence level, the width of the confidence interval will
Confidence interval for the mean weight : What is the 99% confidence interval for the mean weight (in Kilograms) of all boys in 7th grade in that city?
Write a python function that implements the algorithm : Create a new file p2.py where you write a Python function find_dup_str(s, n) that implements the algorithm .
Service responsibilities of a cable company : An important part of the customer service responsibilities of a cable company relates to the speed with which trouble in service can be repaired.
What is the probability there is exactly one non-defective : What is the probability there is exactly one non-defective? (Hint: You have to use both Multiplication and Addition rules
Tell the name of the organizations acted as the idp : Provide an FIdM authentication system that you have used (being subjet to). Tell the name of the organizations acted as the IdP .
Find the probability that at least on of the chips : You have a bag containing poker chips. There are 18 total chips, consisting of 9 white chips, 6 blue chips, 2 red chips, and 1 green chip.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write a program that reads n positive numbers from keyboard

Write a program that reads N Positive numbers from keyboard

  Create a class that represents sales of sports equipment

A total sales function that returns the monetary amount of sales. Assume that each pair of skis is $800, each snowboard is $600, each tennis racquet is $400, and each baseball bat is $100.

  What is proficient by page buffering

What is proficient by page buffering

  Draw a control flowchart

Draw a control flowchart for this example using one statement for the selection of the type of a drink (use Visio Flowchart or similar graphical editor to draw it)

  Listing all the visual basic looping

Listing all the visual basic looping and decision constructs that you think you would need to write a program that sorts the grades for you. DO NOT write the program, simply list the constructs and justify the decision for choosing them.

  Products would have a fashion product life cycle curve

Which of the following products would have a fashion product life cycle curve?

  Questionthis is from my the essentials of computer

questionthis is from my the essentials of computer organization and architecture book its 3rd edition and website only

  Process of formulating an entry strategy

Describe the process of formulating an entry strategy. The answer requires to be at least 300 words. Also include any of the references.

  Write a program that reads three numbers

Write a program that reads three numbers and prints increasing if they are in increasing order, decreasing if they are in decreasing order.

  Design classes that define various courses in curriculum

Design and implement a set of classes that define various courses in your curriculum. Include information about each course such as the title, number.

  Discuss guidelines for security systems

Describe whether there any security system guidelines described in the text that could be eliminated without weakening the security system

  Create a ticket reservation class for issuing tickets

Create a ticket reservation class for issuing tickets to on-campus events such as plays, musicals, and home basketball games.

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