Question

There are four steps to algorithm methodology. 1. Design: Identify the problem and thoroughly understand it....

There are four steps to algorithm methodology.

1. Design: Identify the problem and thoroughly understand it.

2. Analyze how efficient the code is in solving the problem

3. Implement: Writing and coding the algorithm.

4. Experiment with different variables in the algorithm.

- Use Python3 to create your own SHORT algorithm to complete a computing task.

Discuss your algorithm design in relation to these four steps and describe how you went through each step of the methodology to create your algorithm.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Design: The problem is to sort a unsorted array, this can be done in either compare each element of the array to the other elements of the array and placing them in the right place but it will take lots of time as two loops will be required for it. So efficient algo can be:

  1. Take a array
  2. for i=0 to array length
  3. key <= arr[i]
  4. j <= i-1
  5. while (j >= 0 && arr[j] > key)
  6. arr[j + 1] = arr[j];
  7. j <= j - 1;
  8. end
  9. arr[j+1]=key
  10. end

Analyse: O(n^2)

Implement:

def sort(arr):
   for i in range(1, len(arr)):
       key = arr[i]
       j = i-1
       while j >= 0 and key < arr[j] :
               arr[j + 1] = arr[j]
               j = j-1
       arr[j + 1] = key

Add a comment
Know the answer?
Add Answer to:
There are four steps to algorithm methodology. 1. Design: Identify the problem and thoroughly understand it....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT