UNIVERSITY of the EAST – MANILA
COLLEGE of COMPUTER STUDIES and SYSTEMS
BAUTISTA, GEM MATTHEW L. February 5, 2026
JUCO, JORGE HYVAN A. Midterm Assignment #1
CDS 1101 – ITCB
Question #1
Define and illustrate the different linear data structures.
Answer#1
- A linear data structure organizes and stores data so that elements are arranged in a
sequential order. In such structures, each element, except the first and last, has a unique
predecessor and successor, and elements are accessed in a linear sequence.
The primary linear data structures include:
1. Array
2. Linked List
3. Stack
4. Queue
1. Array
An array is a collection of elements of the same data type stored in contiguous memory
locations. Each element is identified by an index or subscript, which allows direct access.
Characteristics of Arrays
Homogeneous elements: All values in an array must be of the same data type.
Contiguous memory allocation: Elements are stored next to each other in memory,
enabling efficient access and traversal.
Random access: Any element can be accessed in constant time (O(1)) using its index.
Fixed or static size: In many programming languages, array size is determined at creation,
limiting flexibility. Dynamic arrays, such as Python lists, address this limitation by allowing
resizing while maintaining array-like behavior.
2. Linked List
A linked list consists of a sequence of nodes, each containing data and a pointer or reference to
the next node. Unlike arrays, linked lists store elements in non-contiguous memory locations.
Characteristics of Linked Lists
Dynamic size: The list can grow or shrink easily by allocating or deallocating nodes during
runtime.
Non-contiguous storage: Elements (nodes) can reside at arbitrary memory locations,
linked through pointers.
Sequential access: To access an element, traversal from the head node is required,
resulting in O(n) time in the worst case.
Efficient insertions/deletions: Adding or removing nodes (especially at the beginning)
occurs in constant time O(1) if the node reference is known.
3. Stack
A stack is a linear data structure that operates according to the Last-In, First-Out (LIFO) principle,
where the most recently added element is the first to be removed.
Characteristics of Stacks
LIFO order: Only the most recently added element (the top of the stack) can be accessed
or removed first.
Restricted access: Insertions (“push”) and removals (“pop”) occur only at one end (the top).
Abstract Data Type: Stack behavior is defined by its operations rather than its
implementation; it can be implemented using arrays or linked lists.
Constant-time operations: Push and pop can often be performed in O(1) time.
4. Queue
A queue is a linear data structure that adheres to the First-In, First-Out (FIFO) principle, ensuring
that the element added first is removed first.
Characteristics of Queues
FIFO order: Elements are added at the rear and removed from the front.
Sequential access: Access to elements must proceed in the order of insertion.
Common operations:
o enqueue(): Add element to rear.
o dequeue(): Remove element from front.
Question #2
What are the uses, advantages, and disadvantages of the linear data structures?
Answer #2
- Linear data structures provide a straightforward, organized approach to data management,
making them suitable for problems that require sequential processing and predictable access
patterns. Their widespread use is attributed to ease of implementation, comprehension, and
analysis, which renders them ideal for foundational algorithms and system operations. However,
these structures have limitations, including limited access methods, inefficient search or
modification, and potential memory overhead depending on the implementation.
The following discussion examines each major linear data structure, outlining its specific
uses, advantages, disadvantages, and practical examples.
1. Array
Uses
Arrays are commonly used in scenarios that require rapid storage and retrieval of data elements by
index. Typical applications include:
Implementing matrices for computations (e.g., image processing, graph representation).
Acting as buffers for data streams (e.g., network packets).
Supporting algorithms such as sorting and dynamic programming.
Advantages
Fast access: Direct indexing allows retrieving any element in constant time (O(1).
Memory efficiency: Contiguous memory allocation uses space compactly.
Versatility: Suitable for storing homogeneous data types and performing arithmetic or
logical operations.
Disadvantages
Fixed size: The array size must be known at creation and cannot grow dynamically without
reallocation.
Insertion/deletion cost: Adding or removing elements (except at the end) requires shifting
subsequent elements, which is inefficient.
Memory allocation issues: Large arrays may exhaust memory, particularly in constrained
environments.
2. Linked List
Uses
Linked lists are advantageous when the dataset size changes dynamically or when frequent
insertions and deletions are necessary. They also serve as foundational structures for
implementing stacks and queues.
Example:
A dynamic shopping list, where items are frequently added or removed, can be represented using
a linked list:
“Apples” → “Bread” → “Milk” → NULL
Advantages
Dynamic sizing: List grows or shrinks as needed without preallocating space.
Efficient insertion/deletion: Modifying nodes does not require shifting elements as in
arrays.
Supports other structures: Forms the basis for implementing stacks, queues, and
complex lists.
Disadvantages
Memory overhead: Each node stores an extra pointer/reference, increasing memory use.
Slow access time: Elements must be traversed sequentially, leading to O(n) access time.
Cache inefficiency: Non-contiguous allocation lacks locality, potentially slowing processing.
3. Stack
Uses
Stacks enforce the Last-In, First-Out (LIFO) order and are utilized in the following applications:
Function call management in program execution (call stack).
Undo mechanisms in applications.
Expression evaluation and parsing (e.g., converting infix to postfix).
Example:
A browser’s history list can be modeled as a stack, where the last page visited is the first to be
removed when the “back” button is pressed.
Advantages
LIFO order: Ensures the most recent element is processed first.
Simple operations: Push and pop operations are efficient and typically take constant time.
Supports nested processes: Useful in recursion and nested evaluations.
Disadvantages
Limited access: Only the top element is accessible; elements deeper in the stack cannot
be directly accessed.
Overflow/underflow: Fixed-capacity stacks may overflow; empty stacks cannot pop
elements.
No random access: Cannot efficiently search or retrieve arbitrary elements.
4. Queue
Uses
Queues follow the First-In, First-Out (FIFO) order. Typical applications include:s are executed in
the order they arrive.
Printer job management: Print jobs are served sequentially.
Breadth-first search (BFS) algorithms in graphs.
Example:
A customer service queue, in which the first customer to arrive is the first to be served.
Advantages
Order preservation: FIFO ensures fairness in processing tasks.
Efficient for scheduling: Works well in task scheduling and streaming data.
Simple to implement: Can be implemented via arrays or linked lists.
Disadvantages
Limited access: Only front or rear elements are accessible.
No random access: Cannot directly retrieve elements in the middle.
Overflow/underflow: Fixed-capacity implementations can overflow; empty queues cannot
dequeue.
Memory overhead: Dynamic queue implementations may consume additional memory due
to pointer overhead.
Reference(s):
Alam, A. (2025, August 11). What is Linear Data Structure? Intellipaat.
[Link]
GeeksforGeeks. (2026, February 3). Introduction to linear data structures. GeeksforGeeks.
[Link]
Goyal, S. (2024, July 3). What Is Linear Data Structure? Types, Uses & More Explained.
[Link]