This project implements a Sorted Linked List that maintains its elements in sorted order using insertion sort logic. The list supports insertion, deletion, overloaded operators, and proper memory management.
- Insertion (
insert(n)): Addsnwhile keeping the list sorted. - Deletion (
remove(n)): Removes the element at indexn(0-based index). Ifnis out of bounds, no changes occur. - Overloaded Operators:
<<(Output Operator): Prints the linked list in a formatted way.[](Index Operator): Returns the element at a given index. If out of bounds, an exception is thrown.
- Memory Management: Ensures proper deallocation of memory when deleting nodes or destroying the list.
L.insert(5); // L = [5]
L.insert(8); // L = [5, 8]
L.insert(7); // L = [5, 7, 8]
L.insert(6); // L = [5, 6, 7, 8]
L.insert(6); // L = [5, 6, 6, 7, 8]
cout << L; // Output: [5, 6, 6, 7, 8]cout << L[2]; // Output: 6
cout << L[10]; // Throws out_of_range exception // Starting List: L = [5, 6, 6, 7, 8]
L.remove(0); // L = [6, 6, 7, 8]
cout << L;
// Output: [6, 6, 7, 8]
L.remove(100); // No change (out of bounds)
cout << L;
// Output: [6, 6, 7, 8]
L.remove(2); // L = [6, 6, 8]
cout << L;
// Output: [6, 6, 8]
L.remove(2); // L = [6, 6]
cout << L;
// Output: [6, 6] Contributions are welcome! Feel free to fork the repo and submit a pull request.
- Esraa Emary Abd El-Salam: GitHub - LinkedIn
- Mariam Badr Yehia: GitHub - LinkedIn
- George Malak Magdy: GitHub - LinkedIn
- John Ayman Demian: GitHub - LinkedIn
- Mohammed Atef Abd El-Kader: GitHub - LinkedIn
This project is licensed under the MIT License.
✨ Developed with ❤️ in C++ ✨