- #1
Sunwoo Bae
- 61
- 4
- Homework Statement
- Take as input a list of integers A and find the sum of three maximum numbers
- Relevant Equations
- .
I just learned about pseudocode, and I am confused about how I should use/write it.
For the question,
1: sum ← 0
2: For i in range (3) do:
3: sum ← sum +max(A)
4: remove max(A) from list A
5: return sum
The following is the kind of pseudocode I want to write.
I have several questions:
Is using functions like max() okay when writing pseudocode?
Would it be right to say that the above code can be described by T(n) = an + b and will thus have time complexity of Θ(n), as there is no nested loop?
Is using informal language like the fourth line (remove max(A) from list A) okay?
Thank you ahead!
For the question,
1: sum ← 0
2: For i in range (3) do:
3: sum ← sum +max(A)
4: remove max(A) from list A
5: return sum
The following is the kind of pseudocode I want to write.
I have several questions:
Is using functions like max() okay when writing pseudocode?
Would it be right to say that the above code can be described by T(n) = an + b and will thus have time complexity of Θ(n), as there is no nested loop?
Is using informal language like the fourth line (remove max(A) from list A) okay?
Thank you ahead!