Skip to content

ports - sav#16

Open
qqdipps wants to merge 1 commit intoAda-C11:masterfrom
qqdipps:master
Open

ports - sav#16
qqdipps wants to merge 1 commit intoAda-C11:masterfrom
qqdipps:master

Conversation

@qqdipps
Copy link
Copy Markdown

@qqdipps qqdipps commented May 28, 2019

No description provided.

Copy link
Copy Markdown

@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.

Outstanding, you had nearly all the methods done in ideal time complexity and had pretty accurate Big-O predictions. You hit all learning goals.

Comment thread lib/recursive-methods.rb
def reverse(s)
raise NotImplementedError, "Method not implemented"
return "" if s.empty?
return s[-1] << reverse(s[0...-1])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Technically s[0...-1] creates a new string of length n-1, so this algorithm is actually n^2

Comment thread lib/recursive-methods.rb
# Space complexity: ?
def reverse_inplace(s)
raise NotImplementedError, "Method not implemented"
# Time complexity: O(n) where is the number of chars in the string
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/recursive-methods.rb
def nested(s, left = 0, right = nil)
right ||= s.length - 1
return true if left >= right
return false if s.length.odd? || s[right] == s[left]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

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