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

  Large programming team and perhaps work on multiple projects

You wonder how large programming teams be sure that they use the same naming conventions and that their programs work together even though they are created independently. You research the Internet and any resources at your disposal for information..

  Determine the term enterprise system and how can this

write a 200- to 300-word short answer response that addresses the followingwhat is an enterprise system and how can

  Advantages to using oop as compared to using only pp

Identify at least two (2) advantages to using OOP as compared to using only PP. Describe at least one (1) feature of object-oriented programming that Visual Logic lacks

  Write three overloaded methods that calculate averages

The first method takes two integer parameters, the second takes three integer parameters, and the third takes four integer parameters.

  Plot the heat flux at all points along the plate length

Repeat Prob. but let the surface temperature vary sinusoidally from 40°C at the leading and trailing edges to BO°C at the centerline.

  Give the assembly language code of microcontroller

For each of the logic statements, give the assembly language code of your microcontroller to set the condition code register and to branch to the ELSE.

  What safe equivalent function should they use to prevent

They see the function, strcpy being called. What safe equivalent function should they use to prevent a buffer overflow?

  How a two-bit selector may be used per branch

Discuss in brief the difference between local and global branch prediction strategies, and how a two-bit selector may be used per branch to select between two.

  Design the hardware and software driver

Design the hardware and software driver that will implement a byte-wide data transfer from your processor to a peripheral device. Each transfer has to accompany by a strobe to deskew the data.

  Determine the data required for a new patient.

Design an input source document that will be used to capture the patient's data and a data entry screen to enter the information into the system.

  Write a program that creates three identical arrays

Write a program that creates three identical arrays, list1, list2, and list3 of 5000 elements. The program then sorts list1 using bubble sort, list2 using selection sort, and list3 using insertion sort and outputs the number of comparisons and it..

  Calculate the average number of packets in the queue

The average length of the packets is 1024 bits. The packets switch needs to transmit this data over a 56-kbs WAN circuit.

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