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

Cynthia Cobb - Restricted Array #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added comment for insert ascending
cynthiacd authored Aug 23, 2017
commit 9a5ec8407def3084b8e8a360bf4c7b041d60ac1d
1 change: 1 addition & 0 deletions using_restricted_array.rb
Original file line number Diff line number Diff line change
@@ -108,6 +108,7 @@ def find_largest(array, length)
# Restricted arrays cannot be resized. Insert only if there is space in the array.
# (Hint: if there are NO elements with 'SPECIAL_VALUE', there is no room to insert)
# All subsequent elements will need to be moved forward by one index.
## GOOD IDEA TO USE BINARY SORT WHEN YOU KNOW ARRAY IS SORTED - WILL IMPROVE TIME COMPLEX
def insert_ascending(array, length, value_to_insert)
if search(array, length, SPECIAL_VALUE)