|
-
March 3rd, 2012, 04:22 PM
#1
[RESOLVED] Number of steps and Complexity
Hi, I'm new to this forum 
I'm studying computer science at uni and can't quite figure out this question.
What is the number of steps required when the input list size is 5?
What is the number of steps required with input list size n?
what is the complexity class of the algorithm?
Algorithm:
Code:
For list [L1,….,Ln].
1. Put m=27, i=1.
2. While i < n
For j = i+1 to n
If distance(Li,Lj) < m then m = distance(Li,Lj)
i = i+1
3. Return m.
In the algorithm, the function distance(α,β) is given by the absolute difference
between the position in the alphabet of α and β. For example, distance(b, f) = 4 and
distance(y, p) = 9.
If you could tell me how its worked out and what the answers are it would help me greatly.
Thanks in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|