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

Yasmin- Leaves #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Yasmin- Leaves #34

wants to merge 1 commit into from

Conversation

YasminM11
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you pointed out you didn't get them all done, but most of what you have is pretty good. We'll go over the solutions in class. Let me know what questions you have.

# Time complexity: ?
# Space complexity: ?
# Time complexity: o(n)
# Space complexity: o(n)
def factorial(n)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if s.length <= 1
return s
else
return s[-1] + reverse(s[0..-2])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s[1..-1] creates a new array and copies all the individual elements over and so is O(n) by itself.

Comment on lines +16 to 18
# Time complexity: o(n^2)
# Space complexity: o(n^2)
def reverse(s)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct on the time/space complexities. Can you think of a way to do better?

# Time complexity: ?
# Space complexity: ?
# Time complexity:
# Space complexity:
def reverse_inplace(s)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll go over this in class.

# Space complexity: ?

# Time complexity: o(n)
# Space complexity: o(n)
def bunny(n)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

# Space complexity: ?

# Time complexity: o(n)
# Space complexity: o(n^2)
def nested(s)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Time complexity is also O(n^2) because of s[1...-1]

Comment on lines 60 to 62
# Time complexity: ?
# Space complexity: ?
def search(array, value)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Big-O is O(n^2) due to the repeated creation of new arrays.

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