w2d5 Flashcards
What does the Comparable module do?
Allows objects of the same type to be compared using standard comparison operators
What module allows you to compare objects of the same type?
Comparable
How do you return an array of objects when you need to loop over an array?
Array#map
How do you iterate an array over a particular range (style issue)?
arr[start_i..end_i].each { … }
What is linearithmic time?
n * log(n)
How do you describe the time complexity of n * log(n) ?
Linearithmic
Log-linear
CSS: How do you target elements with specific attributes? Say, input with type radio?
input[type=”radio”] { … }
What is a css reset used for?
To overwrite the browser’s built-in user style sheet.
What’s a css state selector? How would you select one while hovering over a button?
A selector that will selectively apply based on the item’s current state.
button:hover { … }
How do you select every other instance of an element?
element:nth-of-type(2n) { … }
How do you select every other instance of an element, starting with the 2nd element?
element:nth-of-type(2n + 1) { … }
How do you select all siblings that follow a particular element?
Example: all p’s that follow a div
div ~ p { … }
How do you select the first child and only the first child?
Example: first img within a header
header img:first-child { … }
What’s the difference between these two selectors:
div p { … }
div > p { … }
The first applies to all descendants.
The second applies only to children. Not to grandchildren, etc.
How does a Set obtain O(1) access time? When would the access time be more?
It mods each element into buckets.
If all elements are divisible by the same modulus, access will not be O(1), but O(n).