Skip to content

Kimberley Mackenzie - Carets#16

Open
kimberleyamackenzie wants to merge 1 commit into
Ada-C8:masterfrom
kimberleyamackenzie:master
Open

Kimberley Mackenzie - Carets#16
kimberleyamackenzie wants to merge 1 commit into
Ada-C8:masterfrom
kimberleyamackenzie:master

Conversation

@kimberleyamackenzie

Copy link
Copy Markdown

String Manipulation Practice Exercises

Congratulations! You're submitting your assignment.

Comprehension Questions

What is the time and space complexity for each method you implemented? Provide justification.

Question Answer
What is the time complexity of the string_reverse method? Provide justification. O(n) because the time will grow based on the size of the string input.
What is the space complexity of the string_reverse method? Provide justification. O(1) because it is constant - the same three variables always exist.
What is the time complexity of the reverse_words method? Provide justification. O(n), a constant amount of variables no matter the size of the input.
What is the space complexity of the reverse_words method? Provide justification. Is this O(log n)? It doesn't quite grow linearly or O(n2), because the growth isn't consistently increasing with each increment(letter) of the string - but instead depending on how many spaces there are, it takes up different amounts of time & go through multiple algorithms, so if there was a sentence with two spaces and 50 characters, that would take less time than a sentence with 10 spaces and 50 characters.
What is the time complexity of the reverse_sentence method? Provide justification. O(n), using the same constant amount of variables from both of the above algorithms, regardless of the size.
What is the space complexity of the reverse_sentence method? Provide justification. Since this uses both of the above algorithms, and takes the worst case, it would be O(log n), if the reverse_words method space complexity is O(log n).
What is the time complexity of the palindrome_check method? Provide justification. O(1), because there is a constant amount of variables, no matter the size of the input.
What is the space complexity of the palindrome_check method? Provide justification. O(n), because it grows linearly depending on the size of the input.
What is the time complexity of the encode_repeating method? Provide justification.
What is the space complexity of the encode_repeating method? Provide justification.

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.

1 participant