Course: Computer Science - First Year
Topic: Data Structures Classification (C Programming)
This assignment demonstrates the fundamental data structures in C programming language:
- Primitive Type Declaration - Basic data types
- Linear Static Structure - Array
- Linear Dynamic Structure - Singly Linked List
- Non-Linear Structure - Binary Tree
All code is written without comments as requested, using simple variable names like val, arr, node1, etc.
| File | Description | Lines of Code |
|---|---|---|
primitive_type.c |
Primitive data types (int, float, char) | 14 |
linear_static_array.c |
Static array implementation | 15 |
linear_dynamic_linked_list.c |
Singly linked list implementation | 35 |
nonlinear_binary_tree.c |
Binary tree implementation | 38 |
ASSIGNMENT_DOCUMENTATION.md |
Complete explanations and research | Full guide |
README.md |
This file - project overview | - |
gcc primitive_type.c -o primitive_type
./primitive_typeOutput:
Integer: 42
Float: 99.99
Character: A
gcc linear_static_array.c -o linear_static_array
./linear_static_arrayOutput:
Array elements:
arr[0] = 10
arr[1] = 20
arr[2] = 30
arr[3] = 40
arr[4] = 50
gcc linear_dynamic_linked_list.c -o linear_dynamic_linked_list
./linear_dynamic_linked_listOutput:
Linked List elements:
100 -> 200 -> 300 -> NULL
gcc nonlinear_binary_tree.c -o nonlinear_binary_tree
./nonlinear_binary_treeOutput:
Binary Tree Structure:
Root: 50
Left Child: 30
Right Child: 70
- Classification: Basic building blocks
- Memory: Contiguous
- Example: int, float, char
- Classification: Linear Static
- Memory: Contiguous (all elements next to each other)
- Size: Fixed at compile time
- Use Case: Student grades, days of the week
- Classification: Linear Dynamic
- Memory: Non-Contiguous (nodes scattered in memory)
- Size: Flexible (can grow/shrink)
- Use Case: Browser history, music playlist
- Classification: Non-Linear
- Memory: Non-Contiguous (hierarchical structure)
- Size: Flexible (can grow)
- Use Case: File systems, organization charts
Contiguous (Array):
Memory: [10][20][30][40][50] ← All together
Address: 1000, 1004, 1008, 1012, 1016
Non-Contiguous (Linked List):
Node1 at 2000 → Node2 at 5040 → Node3 at 7200
Connected by pointers, not physical location
Static (Array):
- Size decided when you write code
- Cannot change during program execution
- Like a parking lot with painted spaces
Dynamic (Linked List/Tree):
- Size can change while program runs
- Can add or remove elements anytime
- Like a line at a store - people join/leave
- Student ID lists (fixed class size)
- Monthly sales data (12 months)
- Seat numbers in a theater
- Browser undo/redo history
- Music playlist
- Image viewer (next/previous)
- File system folders
- Organization charts
- Family trees
- Decision making systems
| Operation | Array | Linked List | Binary Tree |
|---|---|---|---|
| Access element | O(1) Fast | O(n) Slow | O(log n) Medium |
| Insert/Delete | O(n) Slow | O(1) Fast | O(log n) Medium |
| Search | O(n) | O(n) | O(log n) |
100 elements:
- Array: 400 bytes (just data)
- Linked List: 1200 bytes (data + pointers)
- Binary Tree: 2000 bytes (data + 2 pointers)
Rule: More flexibility = More memory usage
- ✅ Understand primitive data types in C
- ✅ Implement linear static structure (array)
- ✅ Implement linear dynamic structure (linked list)
- ✅ Implement non-linear structure (binary tree)
- ✅ Explain contiguous vs non-contiguous memory
- ✅ Identify real-world applications
- ✅ Understand data structures and algorithms relationship
For complete explanations, classifications, and detailed analysis, see:
ASSIGNMENT_DOCUMENTATION.md
This document includes:
- Detailed classification of each structure
- Memory characteristics
- Real-world applications
- Advantages and disadvantages
- How data structures and algorithms work together
- Speed and memory trade-offs
- Choosing the right structure for different scenarios
- Language: C (gcc compiler)
- Style: Beginner-friendly, no comments in code
- Variable Names: Simple (val, arr, node1, root, etc.)
- Memory Management: Proper malloc/free usage
- Code Quality: Clean, tested, and working
This assignment demonstrates fundamental understanding of:
- Data structure classification hierarchy
- Memory allocation (stack vs heap)
- Pointer usage in C
- Trade-offs between different structures
- Practical applications in real systems