Data Structure
DSC 212: Introduction to Data Structures
• Course and Term: University of Hafr Al-Batin, College
of Computer Science and Engineering, Course: DSC 212
– Introduction to Data Structures, Term 223
• Project Report: An in-depth look at data structures
through team-based projects.
• Team Members: Leader: [Name], Email: [Email]
Member 2: [Name], Email: [Email] Member 3: [Name],
Email: [Email] Member 4: [Name], Email: [Email]
Member 5: [Name], Email: [Email]
Photo by Amélie Mourichon on Unsplash
Student Name
3
Task #1: CircularBuffer Python Program
• CircularBuffer Class: A custom data structure designed
to manage elements in a circular queue fashion, enabling
efficient front and rear operations.
• Core Operations: - **enqueue(item)**: Adds an item at
the rear if not full. - **dequeue()**: Removes an item
from the front if not empty. - **is_empty()**: Checks if
the buffer is empty. - **is_full()**: Checks if the buffer
is full.
• Exception Handling: Implements error handling for
overflow (full buffer) and underflow (empty buffer)
conditions. Photo by Tiago Spike Rosa on Unsplash
Task #1: Analysis
• Initialization: - **Time Complexity: O(1)** Set up a
fixed-size list and initialize indices.
• Enqueuing Elements: - **Time Complexity: O(n)**
Linear complexity as each operation adjusts the rear and
may modify the front.
• Dequeuing Elements: - **Time Complexity: O(n)**
Each operation involves adjusting the front and
accessing elements linearly.
• Handling Full/Empty States: - **Time Complexity:
O(1)** Constant time checks for buffer's full or empty Photo by Walls.io on Unsplash
state.
Task #2: SinglyLinkedList Python Program
• SinglyLinkedList Class: A basic data structure for
managing a list of elements in a sequence, where each
element points to the next.
• Core Operations: - **append(value)**: Adds a new
element to the end of the list. - **remove(value)**:
Removes an element by value from the list. -
**display()**: Returns a string representation of the list.
• Implementation Details: Utilizes nodes with a value
and a pointer to the next node, allowing dynamic list
management.
Photo by Sigmund on Unsplash
Task #2: Analysis
• Adding Elements (Append): - **Time Complexity:
O(1) to O(n)** Initial append is O(1); subsequent
appends require traversing the list, making it O(n).
• Removing Elements (Remove): - **Time Complexity:
O(n)** Requires traversing the list to find and remove
the specified element.
• Displaying the List (Display): - **Time Complexity:
O(n)** Traversing the list to construct a string
representation of all elements.
Photo by Hans Hubert on Unsplash