1/22
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
What is an array?
An ordered collection used to store multiple values of the same type in a single data structure. Also called a "list"
An array is created like:
var arrayName = [12, 15, 19, 13];
![<p>var arrayName = [12, 15, 19, 13];</p>](https://assets.knowt.com/user-attachments/1d4c1325-6e33-45cc-aa37-93790be063d8.png)
An array's outer bounds are defined by:
square brackets

Each element in an array is separated by:
commas

Do arrays maintain order?
Yes. Arrays have numerical indexes. Indexes in arrays will ALWAYS start with 0.

An index in an array starts with the number
0

To assign "Sarah" to element 1 in an array would look like:
names[1] = 'Sarah';
![<p>names[1] = 'Sarah';</p>](https://assets.knowt.com/user-attachments/6d62ec4b-498f-4b6f-aabc-406593ca94d1.png)
What will the .length property of an array do?
The number of items in the array.

What does the arrays push( ) method do?
Adds a new item to the end of an array. To do this, add ".push" after the name of the array and inside parentheses, enter the name of the item you want to add.
We can add as many items as we want to an array using push. We can add them to in separate push method statements or the same statement.

What does the array pop( ) method do?
It removes the last element of an array. Write the name of the array and add .pop( );

What is an "object"?
A set of attributes (or characteristics) describing a construct.
What does AP Pseudocode array index start at?
1
Which of the following will, in AP Pseudocode, create an empty list?
aList
What method can we use to find the index of a particular element in an array?
.indexOf
var groceries = ["milk", "eggs", "bread", "cheese", "yogurt", "sugar"];
Given the above, what will be the result of groceries.indexOf("cake"); ?
-1
Consider the following AP Pseudocode segment:
arrList ← [17, "Karel", false, true, "hello"]
Which element can be found at index 2?
Karel
Traversing (or looping) through an array means to:
loop through an array and access each of the elements. Caution must be taken to avoid looping beyond the valid index values
heuristic
an approach to a problem that produces a solution that is not guaranteed to be optimal but may be used when techniques that are guaranteed to always find an optimal solution are impractical.
aka “rule of thumb”
splice() method
changes the contents of an array by removing or replacing existing elements and/or adding new elements.
algorithm efficiency
an estimation of the number of computational resources used by an algorithm. Efficiency is typically expressed as a function of the size of the input.
said to run in a “reasonable” amount of time:
Algorithms with a polynomial efficiency or slower (constant, linear, square, cube, etc.)
models
physical or virtual representations of an object.
simulations
test a hypothesis of a situation using a model.