Sorted Arrays Flashcards
1
Q
How do you know if an array is sorted?
A
Its components are in ascending order
2
Q
How does “greater than” work with Objects?
A
Using Comparable objects, which allows ordering to be defined over objects
3
Q
How does “binary search” work with a sorted array? (3)
A
- Check middle element
- Greater than, equal to, or less than target
- If not found, search again in upper or lower half