w1d5 Flashcards
High-level: Binary Search
base case:
return nil if empty array
gen case:
probe mid element with probe_index
return index if probe == target
bsearch(left) if target < probe
if target > probe
answer = bsearch(right)
answer.nil? ? nil : probe_index + 1 + answer
Why do sorts always take a proc?
To control the sort order (and to sort objects by attribute values).
How do you move selected text up/down/left/right in Atom?
cmd + ctrl + arrows
What does cmd + ctrl + arrows do in Atom?
moves selected text around
Methods that do not reference an instance variable should be written as what type of method?
Class method
Outline basic 4-step git workflow
new file in working dir git add file file now in staging git commit file now in repo git push file now in remote repo
What’s a more condensed version of git log?
git log –oneline
What does git log –oneline do?
Shows a more condensed version of the git log
What’s a shortcut to create and switch into a new branch?
git checkout -b newbranch
How to see the diff before merging a branch?
git checkout branch
git diff branch-to-merge
How do bring a remote repo locally
git clone url
What are some abstract data types?
7: 5 star
5-6: 4 star
1-4: 1 star
set map queue tree binary tree ternary tree nary-tree/polytree
What is a map ADT?
a set of key/value pairs
What two ops exist within a Queue ADT?
High-level: how would you implement one?
enqueue, dequeue
Array
unshift and pop
Elegant way to explain the depth of a tree?
Longest path to a leaf node