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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

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

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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