HIGHER EDUCATION COURSEWARE: INTRODUCTION TO COMPUTER SCIENCE
HIGHER EDUCATION OPEN COURSEWARE
CHAPTER 4: FUNDAMENTAL LINEAR DATA STRUCTURES
A Technical Overview of Arrays, Linked Lists, Stacks, and Queues
1. Learning Objectives
By studying this framework, students will acquire the knowledge to:
• Analyze the operational and architectural differences between contiguous and non-contiguous memory
allocations.
• Implement and execute fundamental operations on Stacks (LIFO) and Queues (FIFO).
• Evaluate the Time Complexity (Big O Notation) for search, insertion, and deletion algorithms across linear
structures.
2. Abstract Data Types vs. Physical Storage
In computer science, managing memory efficiently is critical to algorithm performance. Data structures
serve as the physical implementation of Abstract Data Types (ADTs), defining how computational data is
organized, stored, and modified within memory cells.
2.1. Arrays vs. Linked Lists
An Array is a collection of elements stored in contiguous memory locations. It allows direct, random
access to elements using an index, yielding an efficient time complexity of O(1). However, its static nature means
its size must be predetermined, leading to potential memory waste or overflow.
Conversely, a Linked List is a dynamic structure composed of nodes, where each node contains a data
field and a reference pointer pointing to the next node in the sequence. While it provides flexible, runtime
allocation of memory, accessing an element requires sequential traversal from the head node, resulting in a time
complexity of O(N).
ALGORITHMIC EFFICIENCY MATRIX (BIG O NOTATION)
Data Structure
Access Time
Search Time
Insertion (At Head)
Deletion (At Head)
Static Array
O(1)
O(N)
O(N) - requiring shifts
O(N) - requiring shifts
Singly Linked List
O(N)
O(N)
O(1)
O(1)
Page 1
HIGHER EDUCATION COURSEWARE: INTRODUCTION TO COMPUTER SCIENCE
3. Restricted Linear Structures: Stacks and Queues
Certain dynamic computing paradigms require restricting data interaction access points to maintain specific
sequential order integrity.
3.1. The Stack Structure (Last-In, First-Out)
A Stack is a linear structure that adheres strictly to the LIFO principle. Elements are added and removed
from the exact same interface location, known as the Top of the stack. The primary primitive operations are defined
as:
void push(Data item); // Inserts an element onto the top
Data pop(); // Removes and returns the top element
3.2. The Queue Structure (First-In, First-Out)
A Queue operates under the FIFO principle, closely resembling a real-world waiting line. Elements enter
the structure from one end, designated as the Rear or Tail, and are removed from the opposite end, called the Front
or Head.
void enqueue(Data item); // Inserts an element at the rear
Data dequeue(); // Removes and returns the front element
System Execution Case Study: The Call Stack in Compilers
Whenever a multi-layered software application executes functions, the compiler generates an internal systemlevel Call Stack to manage execution flow. When function main() invokes function calculate(), the
current execution state and localized variables are wrapped into an activation record and pushed onto the
stack. Once calculate() fulfills its execution blocks and returns a value, its record is popped from the
stack, allowing the system to seamlessly resume context execution at the exact previous address in main().
4. Technical Review Questions
Question 1 (Algorithmic Analysis): Suppose you are tasked with designing an undo-redo history tracker
mechanism for a modern text editor program. Which linear data structure (Array, Linked List, Stack, or Queue) is
mathematically optimal for managing this behavioral functionality? Justify your choice.
Question 2 (Multiple Choice): If a circular queue implementation utilizes an array of fixed size 8, what happens to
the internal pointer alignments when an enqueue operation is successfully performed on an element while the
Rear index is currently positioned at index 7?
A. An index out-of-bounds runtime exception is thrown immediately.
B. The Rear pointer wraps around to index 0 using a modulo mathematical operation.
Page 2
HIGHER EDUCATION COURSEWARE: INTRODUCTION TO COMPUTER SCIENCE
C. The array dynamically doubles its allocation size to 16 blocks.
D. The Front pointer is forced to increment to prevent memory corruption.
Page 3