-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ports - Ngoc #30
base: master
Are you sure you want to change the base?
Ports - Ngoc #30
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job! I'd like to see a brief explanation of what n
is and why the algorithm is O(n)
time complexity.
Checklist
- Clean, working code
- Efficient code - give feedback as you would give to a peer on your team
- A detailed explanation of time and space complexity (explains what n stands for, explains why it would be a specific complexity, etc.)
- All test cases for the assignment should be passing.
@@ -1,6 +1,15 @@ | |||
# Computes factorial of the input number and returns it | |||
# Time complexity: ? | |||
# Space complexity: ? | |||
# Time complexity: O(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you provide time complexity, please explain in a few words what n
means. For example, in this case, is n
equal to the value of number
? Or is it equal to the number of things stored in number
(which would be 1)? Or might it have anything to do with the number of decimal digits needed to represent number
? It's important to define n
for every new problem, since the meaning can change from algorithm to algorithm.
raise ArgumentError | ||
end | ||
|
||
i = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm used to seeing i
used as a variable name only when the variable is used to iterate over a collection. This variable is actually being used to accumulate the product of numbers for the factorial calculation. I'd name this something more like product
in order to avoid confusion.
# Time complexity: ? | ||
# Space complexity: ? | ||
# Time complexity: O(n) | ||
# Space complexity: O(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also briefly explain why here.
No description provided.