Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Data Structures

Total questions: 10

Worksheet time: 7mins

Name
Class
Date
1.

Which of these inserts elements into a Queue? Select all that apply.

a)

push()

b)

offer()

c)

add()

d)

insert()

2.

Which of these inserts elements into a Stack? Select all that apply.

a)

push()

b)

offer()

c)

add()

d)

insert()

3.

Which of these inserts elements into a Deque? Select all that apply.

a)

pushFirst()

b)

offerFirst()

c)

addFirst()

d)

insertFirst()

4.

Which of these removes elements from a Queue? Select all that apply.

a)

pop()

b)

poll()

c)

peek()

d)

remove()

5.

Which of these removes elements from a Stack? Select all that apply.

a)

pop()

b)

poll()

c)

peek()

d)

remove()

6.

Which of these removes elements from a Deque? Select all that apply.

a)

popFirst()

b)

pollFirst()

c)

peekFirst()

d)

removeFirst()

7.

Deque<Integer> d = [1,2,3].

d.offerLast(d.pollFirst());


What is the value of d?

a)

[1,2,3]

b)

[2,3,1]

c)

[3,1,2]

d)

[3,2,1]

8.

Deque<Integer> d = [1,2,3].

d.offerFirst(d.pollLast());


What is the value of d?

a)

[1,2,3]

b)

[2,3,1]

c)

[3,1,2]

d)

[3,2,1]

9.

Consider two Deques with the same element type, A and B, and let B be empty.


To move everything from A to B and preserve order, which of these can be used in a loop? Select all that apply.

a)

B.offerFirst(A.pollFirst());

b)

B.offerFirst(A.pollLast());

c)

B.offerLast(A.pollFirst());

d)

B.offerLast(A.pollLast());

10.

Consider two Deques with the same element type, A and B, and let B be empty.


To move everything from A to B and reverse order, which of these can be used in a loop? Select all that apply.

a)

B.offerFirst(A.pollFirst());

b)

B.offerFirst(A.pollLast());

c)

B.offerLast(A.pollFirst());

d)

B.offerLast(A.pollLast());