- 2073 Magh · 3+2 marks
What is a stack; linear or non-linear
Short answer
A stack is a linear LIFO data structure with insertion/deletion only at top. It is linear because elements form a sequence with at most one predecessor and successor.
What is a stack data structure? Is stack a linear or non linear data structure?
A stack is a linear data structure in which insertion (push) and deletion (pop) take place only at one end, called the top. The last element inserted is the first one removed, so it follows LIFO (Last In First Out).
Linear or non-linear?
A stack is a linear data structure. In a linear structure the elements form a sequence in which every element (except the first and last) has exactly one predecessor and one successor, and elements are accessed one after another in order. In a stack the items are arranged one above another in a line; the only difference from an array or list is that insertion and deletion are restricted to one end (the top).
push -> | 30 | <- top -> pop
| 20 |
| 10 | <- bottom
Non-linear structures such as trees and graphs allow an element to be linked to more than one next element, which is not the case here.
| Linear | Non-linear |
|---|---|
| One-to-one sequence between elements | One-to-many or many-to-many relation |
| Single level, traversed in one run | Multiple levels, branching |
| Stack, queue, array, linked list | Tree, graph |
A stack can be implemented using an array or a linked list, both of which are linear.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Primitive vs non-primitive data structure · Data Structure and Algorithm, chapter 1
- Data structure; primitive vs non-primitive · Data Structure and Algorithm, chapter 1
- Define data structure and its importance · Data Structure and Algorithm, chapter 1
- Data structure and basic operations · Data Structure and Algorithm, chapter 1
- Data structure types and operations · Data Structure and Algorithm, chapter 1
- Define data structure; explain ADT · Data Structure and Algorithm, chapter 1
- Linear homogeneous and non-homogeneous recurrence · Discrete Structure, chapter 3
- Elastic, inelastic, linear and non-linear behaviour · Theory of Structures I, chapter 1
- Stress-strain curves: linear and non-linear cases · Concrete Technology and Masonry Structure, chapter 4
- Non-linear kinematic wave discharge at 1 km · Computational Techniques in Civil Engineering, chapter 5