Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Ports - Ngoc #30

wants to merge 2 commits into from

Conversation

lebaongoc
Copy link

No description provided.

Copy link

@mmcknett mmcknett left a 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)

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

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)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants