Week 6 - Data, References, Arrays & Searching Flashcards
How do we use ASCII and UTF in Ruby?
Assign the variable, then puts it out using encode
Eg:
delta = (ASCII character)
puts delta.encode(“utf-8”)
What’s the difference between dynamic and static arrays?
Dynamic arrays have no fixed size, whereas in static arrays we can assign the number of things inside an array.
What’s the difference between dynamic and static memory?
Dynamic memory has no fixed size, whereas in static memory it’s fixed.
What are lists used for?
Sometimes it’s better to use lists vs arrays because of the operations that they allow.
What are some operations for lists?
- Adding items
- Taking the head of the list
- Asking if the list includes x
- Applying an operation to all items (doubling items)
- Inserting items into a point (cheese near the milk)
Reject List Operation
Used to take something ff the list.
This is done by creating a new list with the thing removed.
Each List Operation
Applies an operation to each item if a certain condition is met.
How can we search an array?
We search through an array using a while loop.
This allows us to check if there are certain items/elements inside of an array.
Instead of returning an index, can we return the item of the index itself?
No we can’t do this.
This is because you wouldn’t be able to tell whether or not the item is found, if there aren’t any values in the list, and if we wanted to change an item. Overall, things are easier with the index.
What’s the difference between arrays and lists?
- Lists are a set of operators that apply to an array.
- Lists can be stored in an array.
List
A type of data structure.