Explore BrainMass
Share

Describing Algorithms

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Suppose you are given a list of n integers in random order. Describe an algorithm that will determine whether the numbers would be an arithmetic progression if they were sorted. Note: An arithmetic progression is a set of numbers of the form {a + bj | j = 0, 1, 2, ... n - 1} where a and b are both integers. To get any marks your algorithm must run in O(n) time.

Please show me detailed processes, thank you.

© BrainMass Inc. brainmass.com March 21, 2019, 3:48 pm ad1c9bdddf
https://brainmass.com/computer-science/sorting/describing-algorithms-164173

Solution Preview

1. Enter the n numbers one at a time in a "for loop" construct (O(n)).
2. The numbers are sorted in the numerical order using any O(n) algorithm, and the sorted sequence is stored in an array.
3. An arithmetic progression is a sequence of ...

Solution Summary

This solution provides a step by step method for describing an algorithm.

$2.19