---
title: "What is a stack; linear or non-linear"
subject: "Data Structure and Algorithm"
chapter: 2
key: "semester_4/data_structure_and_algorithm:stack-linear-or-nonlinear"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/stack-linear-or-nonlinear
site: BCT Engineering
---

# What is a stack; linear or non-linear

Data Structure and Algorithm · Chapter 2: The Stack and Queue

- Asked in: 2073 Magh, 3+2 marks
- Video: [Introduction to Data Structure | Linear & non-linear D.S | STACK |  Part 1](https://www.youtube.com/watch?v=e0tccwnTM9g) — Gate TaLkS
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/stack-linear-or-nonlinear
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-2

## Question

What is a stack data structure? Is stack a linear or non linear data structure?

## 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.

## Answer

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).

```text
   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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. In a stack, insertion and deletion take place at:
   A. Both ends
   B. Only one end called the top
   C. Any position
   D. The middle
   Answer: B. Push and pop both happen only at the top. (Key point: Stack definition)

2. Which element is removed first from a stack?
   A. The first inserted
   B. The largest
   C. The last inserted
   D. The smallest
   Answer: C. A stack is LIFO so the last pushed element pops first. (Key point: LIFO)

3. Why is a stack classified as a linear data structure?
   A. It is implemented only with arrays
   B. Its elements form a sequence with one predecessor and one successor each
   C. It has multiple levels
   D. It allows branching
   Answer: B. Elements are arranged one after another in a line; restriction to one end does not make it non-linear. (Key point: Why linear)

4. Which pair are non-linear structures?
   A. Stack and queue
   B. Array and linked list
   C. Tree and graph
   D. Stack and tree
   Answer: C. Trees and graphs link an element to more than one next element. (Key point: Non-linear examples)

## Related in Data Structure and Algorithm

- [Primitive vs non-primitive data structure](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aprimitive-vs-nonprimitive) — Data Structure and Algorithm, chapter 1
- [Data structure; primitive vs non-primitive](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adefine-ds-primitive-nonprimitive) — Data Structure and Algorithm, chapter 1
- [Define data structure and its importance](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adata-structure-importance) — Data Structure and Algorithm, chapter 1
- [Data structure and basic operations](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adata-structure-basic-operations) — Data Structure and Algorithm, chapter 1
- [Data structure types and operations](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adata-structure-types-operations) — Data Structure and Algorithm, chapter 1
- [Define data structure; explain ADT](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adata-structure-and-adt) — Data Structure and Algorithm, chapter 1

## Related in other subjects

- [Linear homogeneous and non-homogeneous recurrence](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Alinear-homogeneous-nonhomogeneous-recurrence) — Discrete Structure, chapter 3
- [Elastic, inelastic, linear and non-linear behaviour](https://www.bctengineer.com/question.md?key=semester_4%2Ftheory_of_structures_i%3Aelastic-inelastic-linear-nonlinear) — Theory of Structures I, chapter 1
- [Stress-strain curves: linear and non-linear cases](https://www.bctengineer.com/question.md?key=semester_5%2Fconcrete_technology_and_masonry_structure%3Astress-strain-nonlinear-cases) — Concrete Technology and Masonry Structure, chapter 4
- [Non-linear kinematic wave discharge at 1 km](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Akinematic-wave-implicit-numerical) — Computational Techniques in Civil Engineering, chapter 5
