Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93125659

Have any Question?


Related Questions in Computer Engineering

The sample distribution on individual iq scores raw scores

The sample distribution on individual IQ scores (raw scores) has a sample mean of 100 and a standard deviation of 16. What proportion of the sample mean will fall at or above a mean of 102.56? Round the answers to no mor ...

Question please read this instruction and section 5 and 6

Question: Please read this instruction, and section 5 and 6 in particular, CAREFULLY as it affects all future programming assignments. 1. Setup Android Studio Development Environment 1.1 Download necessary packages using ...

Question do you support the development and implementation

Question : Do you support the development and implementation of biometric optical surveillance system (BOSS) as a crowd surveillance tool for police departments? The response must be typed, single spaced, must be in time ...

Systems analysis project personal trainer inc owns and

Systems analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

Discuss the importance of metadata and some of the various

Discuss the importance of metadata and some of the various ways (Microsoft) SQL Server allows you to expose that information. References welcomed to learn where to find obscure IT information (books, articles, websites)

Can someone help me identify how intrustion detection

Can someone help me identify how Intrustion detection system and intrusion prevent system can help protect confidentiality, integrity and availability

Question 500-700 wordsoperations management involves

Question: 500-700 words Operations management involves various activities, such as process design, selection, management of information technology, work systems, planning and development, and quality assurance (Slack, Ch ...

Question draw a map labeling every aspect which represents

Question: Draw a map, labeling every aspect, which represents how IP addressing works with DNS servers to process a request for a web page from your computer that returns the web page.Using tracert from your terminal ent ...

Question suppose that your uncle is a real estate agent and

Question : Suppose that your uncle is a real estate agent and he decided to have a web-site to list his available real estate properties. And use a laptop computer to show clients these properties. What hardware is neede ...

Need help with a java program that takes two arrays a and b

Need help with a Java program that takes two arrays a and b of length 5 storing int values, and returns the dot product of a and b. That is, it returns an array c of length n such that c[i]=a[i]*b[i].

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As