Skip to content

The Agile Data Processor is an advanced C programming project that demonstrates the ability to handle and manipulate dynamic datasets efficiently. With a focus on real-time data processing, memory management, and algorithmic performance, this project showcases practical problem-solving and system design techniques.

Notifications You must be signed in to change notification settings

C-Coding-Assignments/Agile-Data-Processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Agile Data Processor πŸš€

The Agile Data Processor is an advanced C programming project that demonstrates the ability to handle and manipulate dynamic datasets efficiently. With a focus on real-time data processing, memory management, and algorithmic performance, this project showcases practical problem-solving and system design techniques.

How to Run the Code

To make it easy for you to run the code, I’ve created an account on Online GDB, a convenient online compiler. Below are the login details:

  • Email: egarrett055@gmail.com
  • Password: tempUser

Follow these steps to run the program:

  1. Click here to open the project.
  2. Enter the login credentials provided above (email and password).
  3. On the left side of the page, click on "My Projects".
  4. Find and select the project titled "Agile Data Processor".
  5. Click on the "Agile Data Processor" project to open it.
  6. Inside the project, locate and click the file named "main.c".
  7. Click the "Run" button to execute the program.
  8. If prompted, select "C" from the "Language" dropdown near the top of the screen to proceed.
  9. The program’s output will appear at the bottom of the screen, allowing you to experience the results of my work.

Enjoy exploring the program!


Table of Contents πŸ“–

Overview πŸ“‹

The Agile Data Processor is a C-based program focused on efficiently processing dynamic data through three primary components:

  • Real-time Data Handler: Efficiently manages and processes incoming dynamic datasets with minimal delay.
  • Memory Manager: Implements dynamic memory allocation and deallocation to handle large datasets without memory wastage.
  • Algorithm Optimizer: Focuses on optimizing algorithms for performance, ensuring fast and scalable data processing even with large-scale inputs.

Key Features βœ”οΈ

  • Dynamic Memory Management: Uses dynamic memory allocation to handle large datasets without performance issues.
  • Real-time Data Processing: Capable of processing and manipulating data as it is received, with real-time results.
  • Modular Design: Clean, reusable code with distinct modules for handling data, optimizing performance, and managing memory.
  • Scalability: Designed to scale efficiently, processing increasing amounts of data with minimal performance degradation.
  • Error Handling: Incorporates robust error detection, handling invalid inputs and memory errors gracefully.

Structure Explanations πŸ—οΈ

1. struct Student

This structure defines the attributes of an individual student. It contains:

  • name: A string that stores the student's name (up to MAX_LENGTH characters).
  • netID: A string that stores the student's network ID (up to MAX_LENGTH characters).
  • copGrade: A character that stores the student's grade in the COP 2510 course.
  • gpa: A double that stores the student's GPA (Grade Point Average).
  • attempts: An integer that stores the number of times the student has attempted the course.
  • next: A pointer to the next student in the doubly linked list of students.
  • previous: A pointer to the previous student in the doubly linked list of students.

2. struct Trie

This structure defines a trie node. It contains:

  • children: An array of pointers to child nodes, with size ALPHABET_SIZE.
  • isEndOfWord: A boolean value indicating if the current node represents the end of a word.

3. struct TrieManager

This structure manages operations on a trie using function pointers. It contains:

  • getNodePtr: A pointer to a function that initializes a new trie node.
  • insertPtr: A pointer to a function that inserts a string into the trie.
  • searchPtr: A pointer to a function that searches for a string in the trie.
  • trieIndexFinderPtr: A pointer to a function that determines the index of a character in the alphabet.
  • freeTriePtr: A pointer to a function that frees all dynamically allocated nodes in the trie.

4. struct ListManager

This structure defines the function pointers used to modify and manage the doubly linked list of students. It contains:

  • addPtr: A function pointer that points to a function responsible for adding a student to the list.
  • deletePtr: A function pointer that points to a function responsible for deleting a specified student from the list.
  • printListPtr: A function pointer that points to a function responsible for printing the list of students.
  • deleteAllPtr: A function pointer that points to a function responsible for deleting all students in the list.
  • sortPtr: A function pointer that points to a function responsible for sorting the student list based on certain criteria.
  • sortLogicPtr: A function pointer that points to a function responsible for sorting the student list based on custom logic.
  • swapPtr: A function pointer that points to a function responsible for swapping two student nodes in the list.
  • reversePtr: A function pointer that points to a function responsible for reversing the student list.

5. struct MenuManager

This structure defines the function pointers used to manage the menu and various actions related to the students in the list. It contains:

  • menuPtr: A function pointer that points to the function responsible for displaying the menu options to the user.
  • addStudentPtr: A function pointer that points to a function responsible for adding a student to the list.
  • removeStudentPtr: A function pointer that points to a function responsible for removing a student from the list.
  • modifyStudentPtr: A function pointer that points to a function responsible for modifying a student's details in the list.
  • printStudentPtr: A function pointer that points to a function responsible for printing the details of a specific student.
  • printMinGpaPtr: A function pointer that points to a function responsible for printing the student(s) with the minimum GPA in the list.
  • printMinGradePtr: A function pointer that points to a function responsible for printing the student(s) with the minimum grade in the list.

Function Definitions πŸ§‘β€πŸ’»

void initializeTrieManager(struct TrieManager *manager)

Description: This function initializes the function pointers in a TrieManager structure to handle trie operations such as insertion, search, and memory management.

Parameters:

  • manager (struct TrieManager*): A pointer to the TrieManager structure to be initialized.

Returns: This function does not return a value.

struct Trie *getNode()

Description: This function dynamically allocates memory for a new trie node, initializes its children to NULL, and sets isEndOfWord to false.

Parameters: This function does not take any parameters.

Returns: A pointer to the newly created trie node (struct Trie*).

void insert(struct Trie *root, const char *string, const struct TrieManager *manager)

Description: This function inserts a string into the trie structure by creating new nodes as needed and marking the end of the string.

Parameters:

  • root (struct Trie*): A pointer to the root of the trie.
  • string (const char*): The string to be added to the trie.
  • manager (const struct TrieManager*): A pointer to the trie manager, containing function pointers for trie operations.

Returns: This function does not return a value.

bool search(struct Trie *root, const char *string, const struct TrieManager *manager)

Description: This function searches for a string in the trie structure and determines if it is a valid word in the trie.

Parameters:

  • root (struct Trie*): A pointer to the root of the trie.
  • string (const char*): The string to be searched in the trie.
  • manager (const struct TrieManager*): A pointer to the trie manager, containing function pointers for trie operations.

Returns: A boolean value (true or false) indicating whether the string exists in the trie.

int trieIndexFinder(const char *ptr)

Description: This function calculates the index of a character in the trie based on its ASCII value or specific punctuation rules.

Parameters:

  • ptr (const char*): A pointer to the character to be indexed.

Returns: An integer representing the index of the character in the trie.

void menu()

Description: This function displays the main menu to the user with various options for managing the student queue.

Parameters:

  • None.

Returns: Nothing (void).

void initializeListManager(struct ListManager *listManager)

Description: Initializes the list manager with function pointers to manage the student queue (add, delete, print, sort, etc.).

Parameters:

  • listManager (struct ListManager*): A pointer to the list manager structure to be initialized.

Returns: Nothing (void).

void initializeMenuManager(struct MenuManager *menuManager)

Description: Initializes the menu manager with function pointers for displaying and interacting with the menu options.

Parameters:

  • menuManager (struct MenuManager*): A pointer to the menu manager structure to be initialized.

Returns: Nothing (void).

void addMenu()

Description: This function prints the menu for adding a new student to the queue, prompting the user for the student's information.

Parameters:

  • None.

Returns: Nothing (void).

void removeNewline(char *string)

Description: This function removes newline characters found within the string and replaces them with the null-character.

Parameters:

  • string (char*): The string in which newline characters are to be removed.

Returns: Nothing (void).

struct Student *addStudent(struct Student *head, const struct ListManager *manager, struct Trie *root, const struct TrieManager *trieManager)

Description: This function adds a new student to the queue by dynamically allocating memory for a new student, collecting the student's information, and inserting their netID into the trie structure. The student is then added to the linked list representing the queue.

Parameters:

  • head (struct Student*): A pointer to the head of the student queue.
  • manager (const struct ListManager*): A pointer to the list manager containing function pointers for managing the linked list.
  • root (struct Trie*): A pointer to the root of the trie structure where student netID values are stored.
  • trieManager (const struct TrieManager*): A pointer to the trie manager containing function pointers for managing the trie structure.

Returns: A pointer to the updated student queue (struct Student*).

void getName(char *name)

Description: This function prompts the user to enter the name of the new student, ensuring that the name is not empty and removing any newline characters from the input.

Parameters:

  • name (char*): A pointer to the string where the student's name will be stored.

Returns: Nothing (void).

void getNetID(char *netID)

Description: This function prompts the user to enter the Net ID of the new student, ensuring that the input is not empty and removing any newline characters.

Parameters:

  • netID (char*): A pointer to the string where the student's Net ID will be stored.

Returns: Nothing (void).

void getGrade(char *letter)

Description: This function gets the new student's COP 2510 grade from the user and removes any new-line characters from the input.

Parameters:

  • letter: A pointer to a character array where the grade will be stored.

Returns: Nothing (void).

double getGpa(char *gpaStr)

Description: This function gets the new student's GPA from the user and removes any new-line characters from the input. It ensures the GPA is between 0 and 4.0 and returns the validated GPA.

Parameters:

  • gpaStr: A pointer to a character array where the user's GPA will be stored as a string.

Returns: A double representing the validated GPA entered by the user (within the range of 0.0 to 4.0).

int getAttempts(char *attemptsStr)

Description: This function gets the new student's number of previous attempts in COP 2510 from the user and removes any new-line characters from the input. It ensures the input is a positive integer and returns the validated number of attempts.

Parameters:

  • attemptsStr: A pointer to a character array where the user's input for the number of attempts will be stored as a string.

Returns: An int representing the validated number of attempts entered by the user (must be a positive integer).

struct Student *removeStudent(struct Student *head, const struct ListManager *manager)

Description: This function removes a specified student from the linked list based on their Net ID. It asks the user for the Net ID of the student to remove and then searches the list for a matching student. If found, it calls a delete function to remove the student.

Parameters:

  • head: A pointer to the first student in the list.
  • manager: A pointer to the ListManager struct which contains the delete function for removing a student from the list.

Returns: A pointer to the head of the list after the student has been removed (if the student was found).

void modifyStudent(struct Student *head, const struct ListManager *listManager, const struct MenuManager *menuManager, struct Trie *root, const struct TrieManager *trieManager)

Description: This function modifies the attributes of a student in the linked list based on user input. It identifies the student using their netID, verifies their existence using a trie, and allows modification of their name, attempts, GPA, or grade. Optionally, the user can sort the list after modifications.

Parameters:

  • head (struct Student*): A pointer to the head of the student queue.
  • listManager (const struct ListManager*): A pointer to the list manager containing function pointers for managing the linked list.
  • menuManager (const struct MenuManager*): A pointer to the menu manager used to display and handle menu options.
  • root (struct Trie*): A pointer to the root of the trie structure used for searching student netID values.
  • trieManager (const struct TrieManager*): A pointer to the trie manager containing function pointers for managing the trie structure.

Returns: This function does not return a value but modifies the linked list and trie structure directly.

void printList(const struct Student *head, const struct MenuManager *manager)

Description: This function prints the information of all students in the linked list. It checks if the list is empty and displays an appropriate message if no students are present. If the list contains students, it iterates through the list and prints each student's information using the provided manager's `printStudentPtr` function.

Parameters:

  • head: A pointer to the first student in the linked list.
  • manager: A pointer to the MenuManager struct that provides the `printStudentPtr` function to display each student's information.

Returns: This function does not return a value. It prints the list of students to the console.

void printStudent(const struct Student *ptr)

Description: This function prints a student's information in a formatted, tabular layout. It displays the student's name, Net ID, COP 2510 grade, GPA, and number of attempts in the COP 2510 course. The grade is converted to uppercase before printing.

Parameters:

  • ptr: A pointer to the student whose information is to be printed.

Returns: This function does not return a value. It prints the student's information to the console in a neatly formatted manner.

void printMinGpa(const struct Student *head, const struct MenuManager *manager)

Description: This function prints the information of students whose GPA is greater than or equal to the minimum GPA specified by the user. It prompts the user for the minimum GPA, validates the input, and then iterates through the linked list to print the students who meet the GPA requirement.

Parameters:

  • head: A pointer to the head of the linked list of students.
  • manager: A pointer to the MenuManager structure that contains functions for printing student information.

Returns: This function does not return a value. It prints the information of the students whose GPA meets or exceeds the specified threshold.

void printMinGrade(const struct Student *head, const struct MenuManager *manager)

Description: This function prints the students whose COP 2510 grade is greater than or equal to the minimum grade specified by the user. It prompts the user for the minimum grade, validates the input, and then iterates through the linked list to print the students who meet the grade requirement.

Parameters:

  • head: A pointer to the head of the linked list of students.
  • manager: A pointer to the MenuManager structure that contains functions for printing student information.

Returns: This function does not return a value. It prints the information of the students whose COP 2510 grade meets or exceeds the specified threshold.

void sortMenu()

Description: This function displays a menu to the user for selecting various sorting options for the student list. It includes options to sort by name, GPA, attempts, or reverse the list. The user is prompted to select an option, and the menu will reappear if the selection is invalid.

Returns: This function does not return a value. It simply prints the sorting menu to the screen and waits for the user input.

struct Student *sort(struct Student *head, const struct ListManager *manager)

Description: This function sorts a linked list of students based on a selected criteria (name, GPA, attempts, or reversed list). It first displays a sorting menu, gets the user's selection, and then sorts the linked list accordingly. If no sorting is done, the list remains unchanged. The function uses a helper function `sortLogicPtr` to perform the sorting logic and `reversePtr` to reverse the list if needed.

Parameters:

  • head: A pointer to the head of the linked list of students.
  • manager: A pointer to the ListManager structure, which contains the logic for sorting and reversing the linked list.

Returns: The updated head pointer of the linked list after sorting or reversing the list. If no sorting is performed, the head pointer remains unchanged.

struct Student *sortLogic(struct Student *head, const int *logic, const struct ListManager *manager)

Description: This function provides the sorting functionality for the doubly linked list of students based on various criteria. It uses two nested loops to iterate over the list and compare each pair of students. The sorting logic is controlled by the value of logic, which determines whether nodes are swapped based on the comparison of student attributes such as their grade, GPA, or name. The function also makes use of a helper function swapPtr to swap nodes when necessary.

Parameters:

  • head: A pointer to the head of the linked list of students.
  • logic: A pointer to an integer controlling the sorting behavior. If the value is positive, nodes are swapped based on a general sorting criterion. If the value is 0, sorting is based on a custom comparison of grade, GPA, and name.
  • manager: A pointer to the ListManager structure that contains helper functions for managing the linked list, including the swapPtr function.

Returns: The updated head pointer of the linked list after sorting the nodes based on the specified criteria.

void swap(struct Student *head, struct Student *ptr, struct Student *ptr2)

Description: This function swaps the data of two student nodes in the doubly linked list. It uses a temporary structure to hold the data of one student while swapping the data between the nodes ptr and ptr2. After the swap, the student data in both nodes is exchanged, ensuring that the student details are correctly swapped in the list.

Parameters:

  • head: A pointer to the head of the linked list of students.
  • ptr: A pointer to the first student node to be swapped.
  • ptr2: A pointer to the second student node to be swapped with ptr.

Returns: This function does not return a value. It modifies the student nodes by swapping their data.

struct Student *reverse(struct Student *head, const struct ListManager *manager)

Description: This function reverses the order of the nodes in the doubly linked list of students. It first counts the number of nodes in the list, then uses two pointers ptr and ptr2 to iterate through the list from both ends, swapping the nodes using the swapPtr function. The process continues until the two pointers meet in the middle of the list, effectively reversing the order of the students.

Parameters:

  • head: A pointer to the head of the doubly linked list of students.
  • manager: A pointer to the ListManager structure containing the helper function swapPtr, which is used to swap nodes in the list.

Returns: The updated head pointer of the reversed linked list.

struct Student *delete(struct Student *head, struct Student *remove)

Description: This function deletes a specified node from the doubly linked list of students. It iterates through the list to find the node to remove, then updates the pointers accordingly. If the node to be removed is the head of the list, the head pointer is updated to the next node. If the node is found, it is freed, and a success message is printed. If the node is not found, an error message is displayed.

Parameters:

  • head: A pointer to the head of the linked list of students.
  • remove: A pointer to the student node to be deleted from the list.

Returns: The updated head pointer of the linked list after the node is deleted. If the node is not found, the head pointer remains unchanged.

struct Student *deleteAll(struct Student *head)

Description: This function deletes all nodes in the doubly linked list of students. It iterates through the list, freeing each student node one by one until the list is empty. After all nodes have been freed, the function returns a NULL pointer, indicating the list is empty.

Parameters:

  • head: A pointer to the head of the doubly linked list of students.

Returns: A NULL pointer, indicating that the list has been cleared and is now empty.

void writeStudents(FILE *fptr, const struct Student *head)

Description: This function writes the list of students to a file. It checks if the list is empty, and if so, it writes a message indicating that no students are in the list. If the list is not empty, it iterates through the students and writes their information, including name, Net ID, grade, GPA, and attempts, to the specified file.

Parameters:

  • fptr: A pointer to the file where the student information will be written.
  • head: A pointer to the head of the linked list of students.

Returns: This function does not return any value.

void freeTrie(struct Trie *trie)

Description: This function recursively frees the dynamically allocated memory used for the creation of the trie structure, ensuring no memory leaks occur.

Parameters:

  • trie (struct Trie*): A pointer to the root of the trie structure to be freed.

Returns: This function does not return a value.


Usage πŸš€

1. Compile the Program:

make

2. Run the Program:

./main

About

The Agile Data Processor is an advanced C programming project that demonstrates the ability to handle and manipulate dynamic datasets efficiently. With a focus on real-time data processing, memory management, and algorithmic performance, this project showcases practical problem-solving and system design techniques.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published