wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basic Data Structures - Intro to CS

Total questions: 15

Worksheet time: 16mins

Name
Class
Date
1.

What is the output of the following program?

a)

[1, 3, 4, 5]

2

b)

[1, 2, 3]

[4, 5]

c)

[1, 2, 4, 5]

3

d)

[3, 4, 5]

[4, 5]

2.

In the following array:

var groceries = ["milk", "eggs", "bread", "cookies"];

Which of the following statements will change "bread" to "coffee"?

a)

groceries.push("coffee");

b)

groceries[2] = "coffee";

c)

groceries["bread"] = "coffee";

d)

groceries[3] = "coffee";

3.

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?

a)

b)

c)

d)

4.

What does the following function bombers do?

a)

Returns a copy of the list list, and does not modify the contents of the list.

b)

Returns a copy of the list list, and leaves list empty.

c)

Returns a new list containing the elements of the list list in reverse order, and leaves list empty.

d)

Returns a new list contatining the elements of the list list in reverse order, and does not modify the contents of the list.

5.

What is the output of the following program?

a)

-1

b)

1

c)

0

d)

2

6.

What elements can be stored in data structures?

a)

Any kind of objects (anything you can store in a variable)

b)

Strings of text and numerical values

c)

Strings of text, numerical values, and booleans

d)

numerical values

7.

How do we add 6 on the end of this array?

var nums = [1, 2, 3, 4, 5];

nums​ (a)  

Choose from the below words
.push(6);
.push(5);
.pop(6);
.pop(5);
nums[0] = 6;
[3] = 6;
8.

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)  

9.

How can you find the length of an array named arr?

(a)  

10.

The ​ ​ (a)   method lets us find the index of a particular element in an array.

Choose from the below words
indexOf
find
findElement
index
pop
11.

I can create an empty list by typing ​ (a)  

Choose from the below words
arrList = [ ];
arrList = 0;
arrList = [0];
arrList = " ";
12.

Match the following

a)

Pop

1.

To remove the item in the last position from an array

b)

Push

2.

To add an item to a list or array

c)

List

3.

A data structure that holds a collection of values in a particular order

d)

Data Structure

4.

A particular way of organizing data in our programs.

e)

Simulation

5.

A animated model that represents a real-life thing, process, or situation.

13.

Match the following

a)

Array Index

1.

The position of an element in an array.

b)

Indexing into an array

2.

Getting a value at a particular index in an array.

c)

array[index]

3.

Accesses an element in the array to either update or retrieve.

d)

remove[index]

4.

This function removes an element from the given index position.

14.

Looking at the following array:

var arr = ["dog", "cat", "fish", "unicorn"];

The array[index] = ​ (a)   lives at indices 3.

Choose from the below words
unicorn
fish
dog
cat
15.

Looking at the following array:

var arr = ["dog", "cat", "fish", "unicorn"];

The array[index] = ​"dog" lives at indices ​ (a)  

Choose from the below words
0
1
2
3
4