CHAPTER 10: DATA TYPES AND STRUCTURES
10.1 DATA TYPES
10.1.1 Primitive Data Types
10.1.2 Records
Definition: A structure that holds a set of data of different types under one identifier.
Purpose:
Example:
<TEXT>
10.2 ARRAYS
10.2.1 One-Dimensional Arrays
Definition: A collection of elements of the same type accessed by index.
Terms:
- Index: Position of element
- Lower bound: First index (usually 0 or 1)
- Upper bound: Last index
Declaration:
<TEXT>
Access:
<TEXT>
10.2.2 Two-Dimensional Arrays
Definition: Array of arrays; elements accessed by row and column.
Declaration:
<TEXT>
10.2.3 Array Operations
Linear Search:
- Check each element sequentially
- Works on unsorted data
- O(n) time complexity
Bubble Sort:
- Compare adjacent elements
- Swap if in wrong order
- Repeat until sorted
- O(n²) time complexity
10.3 FILES
10.3.1 File Need
- Store data permanently
- Large amounts of data
- Data persistence between program runs
10.3.2 File Operations
Opening:
<TEXT>
Reading:
<TEXT>
Writing:
<TEXT>
Closing:
<TEXT>
10.4 ABSTRACT DATA TYPES (ADT)
10.4.1 Stack
Characteristics:
- LIFO (Last In, First Out)
- Add to top (push)
- Remove from top (pop)
Operations:
- Push: Add item to top
- Pop: Remove item from top
- Peek: View top item without removing
10.4.2 Queue
Characteristics:
- FIFO (First In, First Out)
- Add to rear (enqueue)
- Remove from front (dequeue)
10.4.3 Linked List
Characteristics:
- Dynamic structure
- Nodes contain data and pointer to next node
- Can grow/shrink easily
Operations:
- Add node
- Delete node
- Search