-
Notifications
You must be signed in to change notification settings - Fork 31
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
Chantal's finished problems wk 1 #1
base: master
Are you sure you want to change the base?
Conversation
|
||
until array[i] > value_to_insert | ||
if array[i] == SPECIAL_VALUE | ||
return |
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.
In this case, you should be inserting at array[i] and replace SPECIAL_VALUE with value_to_insert.
next_val = array[i + 1] | ||
|
||
until i == length - 1 | ||
if array[i] == SPECIAL_VALUE |
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.
Same as above
temp = next_val | ||
next_val = array[i + 1] | ||
|
||
end |
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.
At some point, you should update array[insert_index] to have the value of value_to_insert before returning.
Looks good! A few comments to check on bugs. It may help to run your code and see the output to confirm if the values are what you expect to see. In sort, you'll return min instead of sorting the array inside the first loop. I don't think you intend to return min. If you don't return, after the first loop, you'd have found the min element. After the first loop, i will be length -1 and the second loop will never get entered. Think more throught sort - test out your method. In delete,
In find_largest, In insert_ascending, you're never changing any values in the array to have value_to_insert. If the array is [2, 3, 4, SPECIAL_VALUE] and the value_to_insert is 9, then you'll reach i = 3, where the value is SPECIAL_VALUE. In this case, you shouldn't be updating this value to be value_to_insert before returning. You are missing the updating value. |
Restricted Array
Congratulations! You're submitting your assignment.
Comprehension Questions
What is the time and space complexity for each method you implemented? Provide justification.