Font size
WorksheetsBasic Data Structures - Intro to CS
Total questions: 15
Worksheet time: 16mins
What is the output of the following program?
[1, 3, 4, 5]
2
[1, 2, 3]
[4, 5]
[1, 2, 4, 5]
3
[3, 4, 5]
[4, 5]
In the following array:
var groceries = ["milk", "eggs", "bread", "cookies"];
Which of the following statements will change "bread" to "coffee"?
groceries.push("coffee");
groceries[2] = "coffee";
groceries["bread"] = "coffee";
groceries[3] = "coffee";
Suppose we have a list schoolList shown below:
var schoolList = ["Richland", "Hanford", "Pasco"];
We want to write a function addSchool that will take a school list and an item as a parameter and add the item on to the end of the school list.
Which of the following is the correct implementation of addSchool?
What does the following function bombers do?
Returns a copy of the list list, and does not modify the contents of the list.
Returns a copy of the list list, and leaves list empty.
Returns a new list containing the elements of the list list in reverse order, and leaves list empty.
Returns a new list contatining the elements of the list list in reverse order, and does not modify the contents of the list.
What is the output of the following program?
-1
1
0
2
What elements can be stored in data structures?
Any kind of objects (anything you can store in a variable)
Strings of text and numerical values
Strings of text, numerical values, and booleans
numerical values
How do we add 6 on the end of this array?
var nums = [1, 2, 3, 4, 5];
nums (a)
How do we remove the last item from the end of this array and store it in a variable called value?
var number = [1, 1, 2, 3, 5];
(a)
How can you find the length of an array named arr?
(a)
The (a) method lets us find the index of a particular element in an array.
I can create an empty list by typing (a)
Pop
To remove the item in the last position from an array
Push
To add an item to a list or array
List
A data structure that holds a collection of values in a particular order
Data Structure
A particular way of organizing data in our programs.
Simulation
A animated model that represents a real-life thing, process, or situation.
Array Index
The position of an element in an array.
Indexing into an array
Getting a value at a particular index in an array.
array[index]
Accesses an element in the array to either update or retrieve.
remove[index]
This function removes an element from the given index position.
Looking at the following array:
var arr = ["dog", "cat", "fish", "unicorn"];
The array[index] = (a) lives at indices 3.
Looking at the following array:
var arr = ["dog", "cat", "fish", "unicorn"];
The array[index] = "dog" lives at indices (a)
