WGU C949 Data Structures and Algorithms I OA 2026 |
150 Practice Questions with Answers & Rationales
+ 2 Mock Exams | Complete Study Guide.
1. Which abstract data type (ADT) operates on a First-In, First-Out (FIFO) basis?
A) Stack
B) Queue
C) Binary Tree
D) Graph
Answer: B
Rationale: A queue is a FIFO data structure where the first element added is the
first one to be removed. In contrast, a stack is LIFO (Last-In, First-Out).
2. Which data structure allows inserting and deleting elements at both the front
and the rear?
A) Trees
B) Deques
C) Stacks
D) Queues
Answer: B
Rationale: A deque (double-ended queue) allows insertion and deletion at both
the front and back ends. A queue is restricted to one end for insertion and the
other for deletion, while a stack only operates on one end.
3. What is the most efficient data type to use for a data set of a fixed size in
Java?
a = [0, 0, 1, 4, 7, 16, 31, 64, 127]
A) List
B) Tuple
C) Array
D) Dictionary
Answer: C
,Rationale: An array is appropriate for a fixed-size collection of elements of the
same type and provides direct indexed access.
4. Which abstract data type (ADT) has elements of the same type so that
elements can be retrieved based on their index or position?
A) List
B) Bag
C) Stack
D) Queue
Answer: A
Rationale: A list is an ADT that stores elements in a specific order, allowing access
by position (index). A bag is an unordered collection.
5. Which ADT is an unordered collection that allows duplicate elements without
positional access?
A) List
B) Bag
C) Stack
D) Queue
Answer: B
Rationale: A bag is a collection where order does not matter and duplicate items
are allowed. It does not support positional access like a list.
6. Which data structure would you use to efficiently implement "undo"
functionality in an application?
A) Queue
B) Stack
C) List
D) Bag
Answer: B
Rationale: A stack's LIFO (Last-In, First-Out) behavior makes it ideal for undo
operations. Each action is "pushed" onto the stack, and an undo "pops" the most
recent action off.
,7. Which data structure allows elements to be inserted and deleted from one
end and provides no direct access to the other end?
A) List
B) Deque
C) Stack
D) Queue
Answer: C
Rationale: A stack restricts all insertions (push) and deletions (pop) to the same
end, known as the top.
8. In a stack, what is the result of a pop() operation on an empty stack?
A) Stack Reset
B) Stack Underflow
C) Stack Overflow
D) A zero value is returned
Answer: B
Rationale: Attempting to remove an item from an empty stack is an error
condition known as "stack underflow."
9. What is the time complexity of the peek() operation on a stack?
A) O(1)
B) O(log n)
C) O(n)
D) O(n²)
Answer: A
Rationale: The peek operation returns the top element without removing it. This
is a constant-time operation as it directly accesses the top of the stack.
10. Which operation is used to add an item to the back of a queue?
A) Push
B) Pop
C) Enqueue
D) Peek
Answer: C
, Rationale: In a queue, enqueue is the operation to add an item to the back (rear),
and dequeue removes an item from the front.
11. A dequeue operation removes an item from which end of a queue?
A) Front
B) Back
C) Top
D) Middle
Answer: A
Rationale: The dequeue operation removes items from the front of the queue,
following the FIFO principle.
12. What is an Abstract Data Type (ADT)?
A) A specific implementation of a data structure
B) A blueprint for a class
C) A mathematical model for data types defined by the operations that can be
performed on it
D) A collection of algorithms
Answer: C
Rationale: An ADT is defined by its behavior (operations) from the user's
perspective, not by its implementation details. It abstracts the underlying data
representation.
13. What does hash(object) do in the following pseudocode clip?
text
h = hash(key)
for pair in d:
if h == pair[0]:
return pair[1]
A) Converts the key into an integer index for faster lookups
B) Compares the key to the first element in the dictionary
C) Returns the value of the key-value pair
150 Practice Questions with Answers & Rationales
+ 2 Mock Exams | Complete Study Guide.
1. Which abstract data type (ADT) operates on a First-In, First-Out (FIFO) basis?
A) Stack
B) Queue
C) Binary Tree
D) Graph
Answer: B
Rationale: A queue is a FIFO data structure where the first element added is the
first one to be removed. In contrast, a stack is LIFO (Last-In, First-Out).
2. Which data structure allows inserting and deleting elements at both the front
and the rear?
A) Trees
B) Deques
C) Stacks
D) Queues
Answer: B
Rationale: A deque (double-ended queue) allows insertion and deletion at both
the front and back ends. A queue is restricted to one end for insertion and the
other for deletion, while a stack only operates on one end.
3. What is the most efficient data type to use for a data set of a fixed size in
Java?
a = [0, 0, 1, 4, 7, 16, 31, 64, 127]
A) List
B) Tuple
C) Array
D) Dictionary
Answer: C
,Rationale: An array is appropriate for a fixed-size collection of elements of the
same type and provides direct indexed access.
4. Which abstract data type (ADT) has elements of the same type so that
elements can be retrieved based on their index or position?
A) List
B) Bag
C) Stack
D) Queue
Answer: A
Rationale: A list is an ADT that stores elements in a specific order, allowing access
by position (index). A bag is an unordered collection.
5. Which ADT is an unordered collection that allows duplicate elements without
positional access?
A) List
B) Bag
C) Stack
D) Queue
Answer: B
Rationale: A bag is a collection where order does not matter and duplicate items
are allowed. It does not support positional access like a list.
6. Which data structure would you use to efficiently implement "undo"
functionality in an application?
A) Queue
B) Stack
C) List
D) Bag
Answer: B
Rationale: A stack's LIFO (Last-In, First-Out) behavior makes it ideal for undo
operations. Each action is "pushed" onto the stack, and an undo "pops" the most
recent action off.
,7. Which data structure allows elements to be inserted and deleted from one
end and provides no direct access to the other end?
A) List
B) Deque
C) Stack
D) Queue
Answer: C
Rationale: A stack restricts all insertions (push) and deletions (pop) to the same
end, known as the top.
8. In a stack, what is the result of a pop() operation on an empty stack?
A) Stack Reset
B) Stack Underflow
C) Stack Overflow
D) A zero value is returned
Answer: B
Rationale: Attempting to remove an item from an empty stack is an error
condition known as "stack underflow."
9. What is the time complexity of the peek() operation on a stack?
A) O(1)
B) O(log n)
C) O(n)
D) O(n²)
Answer: A
Rationale: The peek operation returns the top element without removing it. This
is a constant-time operation as it directly accesses the top of the stack.
10. Which operation is used to add an item to the back of a queue?
A) Push
B) Pop
C) Enqueue
D) Peek
Answer: C
, Rationale: In a queue, enqueue is the operation to add an item to the back (rear),
and dequeue removes an item from the front.
11. A dequeue operation removes an item from which end of a queue?
A) Front
B) Back
C) Top
D) Middle
Answer: A
Rationale: The dequeue operation removes items from the front of the queue,
following the FIFO principle.
12. What is an Abstract Data Type (ADT)?
A) A specific implementation of a data structure
B) A blueprint for a class
C) A mathematical model for data types defined by the operations that can be
performed on it
D) A collection of algorithms
Answer: C
Rationale: An ADT is defined by its behavior (operations) from the user's
perspective, not by its implementation details. It abstracts the underlying data
representation.
13. What does hash(object) do in the following pseudocode clip?
text
h = hash(key)
for pair in d:
if h == pair[0]:
return pair[1]
A) Converts the key into an integer index for faster lookups
B) Compares the key to the first element in the dictionary
C) Returns the value of the key-value pair