WGU C949 DATA STRUCTURES AND ALGORITHMS I OBJECTIVE ASSESSMENT EXAM
QUESTIONS AND CORRECT DETAILED ANSWERS WITH RATIONALES (VERIFIED
ANSWERS) |A+ GRADE ASSURED!!!
Question 1
Which statement accurately describes a queue data structure?
A) It is a sequence of elements in which insertion and deletion take place at one end (LIFO).
B) It is a sequence of elements in which insertion and deletion take place at both ends.
C) It is a sequence of elements in which insertion can take place anywhere and deletion takes
place only at the front.
D) It is a sequence of elements in which insertions take place only at the back end and deletions
take place only at the front end.
E) It is a hierarchical structure where elements are stored in nodes with parent-child
relationships.
Correct Answer: D) It is a sequence of elements in which insertions can take place only at
the back end and deletions can take place only at the front end.
Rationale: A queue follows the First-In, First-Out (FIFO) principle. This means the first
element added to the queue will be the first one to be removed. In computer science
terminology, we "enqueue" at the rear (back) and "dequeue" from the front.
Question 2
Which data structure allows for inserting and deleting data elements at both the front and the
rear?
A) Trees
B) Deques
C) Stacks
D) Queues
E) Binary Search Trees
Correct Answer: B) Deques
Rationale: The term "Deque" stands for "Double-Ended Queue." Unlike a standard queue
(FIFO) or a stack (LIFO), a deque provides the flexibility to add or remove elements from
either the front or the back ends in 𝑂(1)
time.
Question 3
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
E) Array
Correct Answer: C) Stack
Rationale: A stack is a linear data structure that follows the Last-In, First-Out (LIFO)
, 2
principle. All operations (push and pop) occur at the "top" of the stack, meaning the most
recently added item is the first to be removed.
Question 4
What are the official indexes for the list list01 given the following declaration: int[ ] list01 = {0,
2, 4, 6, 8, 10};?
A) 0, 1, 2, 3, 4, 5
B) 0, 2, 4, 6, 8, 10
C) 1, 2, 3, 4, 5, 6
D) 2, 4, 6, 8, 10, 12
E) -1, 0, 1, 2, 3, 4
Correct Answer: A) 0, 1, 2, 3, 4, 5
Rationale: In almost all modern programming languages (including Java, C++, and
Python), arrays and lists use zero-based indexing. Since there are 6 elements in this array,
the indexes range from 0 to 5.
Question 5
Which Abstract Data Type (ADT) consists of elements of the same type such that elements can
be retrieved based on their specific index or position?
A) List
B) Bag
C) Stack
D) Queue
E) Priority Queue
Correct Answer: A) List
Rationale: A List ADT is an ordered collection of elements where each element has a specific
position (index). This distinguishes it from a "Bag," which is an unordered collection, or
Stacks/Queues, which restrict access to specific ends.
Question 6
Which data structure allows insertion and removal from only one end of the data structure?
A) List
B) Queue
C) Stack
D) Deque
E) Linked List
Correct Answer: C) Stack
Rationale: By definition, a stack restricts its operations to the "top" end. This creates the
LIFO behavior required for tasks like function call management (the call stack) or undo
mechanisms in software.
, 3
Question 7
Which data type does the following mystery function return?
return_type mystery (int R) { int NumUnits = R; return NumUnits * 3.14; }
A) Byte
B) String
C) Double
D) Boolean
E) Integer
Correct Answer: C) Double
Rationale: The function returns the result of an integer multiplied by 3.14. Because 3.14 is a
floating-point literal, the resulting product will be a floating-point number. In languages
like Java or C++, a "double" or "float" is required to hold decimal values.
Question 8
Which category of data does ("FB", 75.00, 75.03, 74.90) represent in the following pseudocode?
mid_value, date = middle(("FB", 75.00, 75.03, 74.90), datetime.date(2014, 10, 31))
A) List
B) Float
C) Tuple
D) Operator
E) Dictionary
Correct Answer: C) Tuple
Rationale: In Python, a sequence of values enclosed in parentheses () is a Tuple. Tuples are
immutable, meaning their contents cannot be changed after creation, making them ideal
for representing fixed records like stock data.
Question 9
Which value is appropriate for Test1 given the expression char Test1;?
A) 'L'
B) 77
C) 6.5
D) "value"
E) True
Correct Answer: A) 'L'
Rationale: A char data type is used to store a single character. In programming, character
literals are typically enclosed in single quotes (e.g., 'L'). Option B is an integer, C is a float,
and D is a string.
Question 10
Which value is appropriate for the variable middle given this pseudocode segment?
string last; string first; char middle; int phone; float rate;
, 4
A) 'D'
B) 'Da'
C) "david"
D) "David"
E) 555
Correct Answer: A) 'D'
Rationale: The variable middle is declared as a char. A char can only hold one character.
"Da", "david", and "David" are strings (collections of characters), while 'D' is a proper
character literal.
Question 11
Which type of operation is represented in the pseudocode int x,y,z; x=y=z=100;?
A) Ternary
B) Assignment
C) Comparison
D) Equality
E) Logical
Correct Answer: B) Assignment
Rationale: The = operator is the assignment operator. This specific line is a chained
assignment where the value 100 is being assigned to variables z, y, and x.
Question 12
What is the most efficient data type to use for the data set a = [0, 0, 1, 4, 7, 16, 31, 64, 127] of a
fixed size in Java?
A) List
B) Tuple
C) Array
D) Dictionary
E) Set
Correct Answer: C) Array
Rationale: When a data set has a fixed size and elements are of the same type, an Array is
the most efficient choice. Arrays provide 𝑂(1) access time and have less memory overhead
than dynamic structures like a List.
Question 13
Which data type is appropriate for an array storing the data a = ["AF", "71", "BC", "157", "BA",
"253"]?
A) Byte
B) Char
C) Short
D) String
QUESTIONS AND CORRECT DETAILED ANSWERS WITH RATIONALES (VERIFIED
ANSWERS) |A+ GRADE ASSURED!!!
Question 1
Which statement accurately describes a queue data structure?
A) It is a sequence of elements in which insertion and deletion take place at one end (LIFO).
B) It is a sequence of elements in which insertion and deletion take place at both ends.
C) It is a sequence of elements in which insertion can take place anywhere and deletion takes
place only at the front.
D) It is a sequence of elements in which insertions take place only at the back end and deletions
take place only at the front end.
E) It is a hierarchical structure where elements are stored in nodes with parent-child
relationships.
Correct Answer: D) It is a sequence of elements in which insertions can take place only at
the back end and deletions can take place only at the front end.
Rationale: A queue follows the First-In, First-Out (FIFO) principle. This means the first
element added to the queue will be the first one to be removed. In computer science
terminology, we "enqueue" at the rear (back) and "dequeue" from the front.
Question 2
Which data structure allows for inserting and deleting data elements at both the front and the
rear?
A) Trees
B) Deques
C) Stacks
D) Queues
E) Binary Search Trees
Correct Answer: B) Deques
Rationale: The term "Deque" stands for "Double-Ended Queue." Unlike a standard queue
(FIFO) or a stack (LIFO), a deque provides the flexibility to add or remove elements from
either the front or the back ends in 𝑂(1)
time.
Question 3
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
E) Array
Correct Answer: C) Stack
Rationale: A stack is a linear data structure that follows the Last-In, First-Out (LIFO)
, 2
principle. All operations (push and pop) occur at the "top" of the stack, meaning the most
recently added item is the first to be removed.
Question 4
What are the official indexes for the list list01 given the following declaration: int[ ] list01 = {0,
2, 4, 6, 8, 10};?
A) 0, 1, 2, 3, 4, 5
B) 0, 2, 4, 6, 8, 10
C) 1, 2, 3, 4, 5, 6
D) 2, 4, 6, 8, 10, 12
E) -1, 0, 1, 2, 3, 4
Correct Answer: A) 0, 1, 2, 3, 4, 5
Rationale: In almost all modern programming languages (including Java, C++, and
Python), arrays and lists use zero-based indexing. Since there are 6 elements in this array,
the indexes range from 0 to 5.
Question 5
Which Abstract Data Type (ADT) consists of elements of the same type such that elements can
be retrieved based on their specific index or position?
A) List
B) Bag
C) Stack
D) Queue
E) Priority Queue
Correct Answer: A) List
Rationale: A List ADT is an ordered collection of elements where each element has a specific
position (index). This distinguishes it from a "Bag," which is an unordered collection, or
Stacks/Queues, which restrict access to specific ends.
Question 6
Which data structure allows insertion and removal from only one end of the data structure?
A) List
B) Queue
C) Stack
D) Deque
E) Linked List
Correct Answer: C) Stack
Rationale: By definition, a stack restricts its operations to the "top" end. This creates the
LIFO behavior required for tasks like function call management (the call stack) or undo
mechanisms in software.
, 3
Question 7
Which data type does the following mystery function return?
return_type mystery (int R) { int NumUnits = R; return NumUnits * 3.14; }
A) Byte
B) String
C) Double
D) Boolean
E) Integer
Correct Answer: C) Double
Rationale: The function returns the result of an integer multiplied by 3.14. Because 3.14 is a
floating-point literal, the resulting product will be a floating-point number. In languages
like Java or C++, a "double" or "float" is required to hold decimal values.
Question 8
Which category of data does ("FB", 75.00, 75.03, 74.90) represent in the following pseudocode?
mid_value, date = middle(("FB", 75.00, 75.03, 74.90), datetime.date(2014, 10, 31))
A) List
B) Float
C) Tuple
D) Operator
E) Dictionary
Correct Answer: C) Tuple
Rationale: In Python, a sequence of values enclosed in parentheses () is a Tuple. Tuples are
immutable, meaning their contents cannot be changed after creation, making them ideal
for representing fixed records like stock data.
Question 9
Which value is appropriate for Test1 given the expression char Test1;?
A) 'L'
B) 77
C) 6.5
D) "value"
E) True
Correct Answer: A) 'L'
Rationale: A char data type is used to store a single character. In programming, character
literals are typically enclosed in single quotes (e.g., 'L'). Option B is an integer, C is a float,
and D is a string.
Question 10
Which value is appropriate for the variable middle given this pseudocode segment?
string last; string first; char middle; int phone; float rate;
, 4
A) 'D'
B) 'Da'
C) "david"
D) "David"
E) 555
Correct Answer: A) 'D'
Rationale: The variable middle is declared as a char. A char can only hold one character.
"Da", "david", and "David" are strings (collections of characters), while 'D' is a proper
character literal.
Question 11
Which type of operation is represented in the pseudocode int x,y,z; x=y=z=100;?
A) Ternary
B) Assignment
C) Comparison
D) Equality
E) Logical
Correct Answer: B) Assignment
Rationale: The = operator is the assignment operator. This specific line is a chained
assignment where the value 100 is being assigned to variables z, y, and x.
Question 12
What is the most efficient data type to use for the data set a = [0, 0, 1, 4, 7, 16, 31, 64, 127] of a
fixed size in Java?
A) List
B) Tuple
C) Array
D) Dictionary
E) Set
Correct Answer: C) Array
Rationale: When a data set has a fixed size and elements are of the same type, an Array is
the most efficient choice. Arrays provide 𝑂(1) access time and have less memory overhead
than dynamic structures like a List.
Question 13
Which data type is appropriate for an array storing the data a = ["AF", "71", "BC", "157", "BA",
"253"]?
A) Byte
B) Char
C) Short
D) String