Categories: Uncategorized

Data Structures and Algorthims

An arithmetic sequence is a sequence of numbers where the difference between successive terms, the sequence’s stride, is constant. For example, [8, 19, 30, 41] is an arithmetic sequence with stride 11 because 19–8 = 30–19 = 41–30 = 11.
Suppose that, given a list, you need to find a maximum arithmetic sequence that indexes strictly increasing terms. For instance, from the list [70,20,60,30,40,10,0,60], the values 20, 40, and 60 are three values in increasing order that are evenly spaced in the list (appearing at indices 1, 4, and 7), but there is no way to select four such terms. That means that [1, 4, 7] is a longest suitable arithmetic sequence of indices. This problem can be solved by exhaustive search.
Write python method find_longest_suitable_sequence so that it takes in a list of numbers and returns a maximum arithmetic sequence that indexes strictly increasing terms from that list. For example, for find_longest_suitable_sequence([70, 20, 60, 30, 40, 10, 0, 60]), [1, 4, 7] is a solution.
A na ̈ıve exhaustive search that considers every possible indexing by an arithmetic sequence will run slowly on most large inputs. Try to find a way to reduce the search space so that the algorithm uses far fewer array accesses on typical inputs. You will receive 5 bonus points if you incorporate these measures to improve the performance.

admin

Share
Published by
admin

Recent Posts

Childbirth

For this short paper activity, you will learn about the three delays model, which explains…

9 months ago

Literature

 This is a short essay that compares a common theme or motif in two works…

9 months ago

Hospital Adult Medical Surgical Collaboration Area

Topic : Hospital adult medical surgical collaboration area a. Current Menu Analysis (5 points/5%) Analyze…

9 months ago

Predictive and Qualitative Analysis Report

As a sales manager, you will use statistical methods to support actionable business decisions for Pastas R Us,…

9 months ago

Business Intelligence

Read the business intelligence articles: Getting to Know the World of Business Intelligence Business intelligence…

9 months ago

Alcohol Abuse

The behaviors of a population can put it at risk for specific health conditions. Studies…

9 months ago