PCAP 31 03 PCAP Certified Associate Python Programmer · Free Practice Question Easy
Question 50
Q571 - Data Aggregates
A data structure described as LIFO is actually a:
-
A
heap
-
B
list
-
C
stack
-
D
tree
Reveal correct answer
Correct answer: C
Explanation
Topic: LIFO stack
Explanation:
Read about it here:
https://en.wikipedia.org/wiki/Stack_(abstract_data_type)
Q571 (Please refer to this number, if you want to write me about this question.)
A. A heap is a specialized tree-based data structure that satisfies the heap property, which is different from the LIFO behavior of a stack. Heaps are commonly used for priority queues and do not follow the Last-In-First-Out principle like a stack.
B. A list is a data structure that does not strictly adhere to the LIFO principle. Lists in Python are ordered collections of items, where elements can be accessed by index and can be inserted or removed at any position. It does not have the characteristic of LIFO behavior like a stack.
C. A stack is a data structure that follows the Last-In-First-Out (LIFO) principle, where the last element added to the stack is the first one to be removed. This makes it suitable for implementing operations like push (add element) and pop (remove element) in a sequential manner.
D. A tree is a hierarchical data structure where each node has a parent-child relationship. Trees are used to represent hierarchical relationships, such as file systems or organization structures, and do not have the LIFO characteristic of a stack.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
