This project implements core linear data structures in C++ using separate header and source files. It covers singly linked lists, stacks, and queues with both array-based and linked-list-based implementations where required.
- Singly Linked List
- Array-Based Stack
- Linked-List Stack
- Circular Array Queue
- Linked-List Queue
-
Node.h
Shared node structure used by linked-list-based structures. -
LinkedList.h/LinkedList.cpp
Singly linked list interface and implementation. -
Stack.h/Stack.cpp
Array stack and linked-list stack interfaces and implementations. -
Queue.h/Queue.cpp
Circular array queue and linked-list queue interfaces and implementations. -
main.cpp
Driver program used to test all data structures.
The assignment requires the project to compile with:
g++ main.cpp LinkedList.cpp Stack.cpp Queue.cpp -o dsa_testRun the program with:
./dsa_testOn Windows, the executable may be named dsa_test.exe:
dsa_test.exeInstall g++ if it is not already available:
sudo apt update
sudo apt install g++Compile:
g++ main.cpp LinkedList.cpp Stack.cpp Queue.cpp -o dsa_testRun:
./dsa_testInstall a Windows g++ toolchain such as MinGW-w64 or MSYS2, then make sure g++ is available from the terminal:
g++ --versionCompile:
g++ main.cpp LinkedList.cpp Stack.cpp Queue.cpp -o dsa_test.exeRun:
dsa_test.exeOpen "Developer Command Prompt for VS 2022" from the Start menu.
Compile with Microsoft C++:
cl /EHsc main.cpp LinkedList.cpp Stack.cpp Queue.cpp /Fe:dsa_test.exeRun:
dsa_test.exeOpen the project folder in VS Code. If using the terminal inside VS Code, compile with the same g++ command shown above.
If g++ is not recognized on Windows, install MinGW-w64 or MSYS2 and add the compiler's bin directory to the system PATH.
The project can be opened as a folder, or the source files can be added to an empty C++ console project. Make sure these files are included:
main.cppLinkedList.cppStack.cppQueue.cppNode.hLinkedList.hStack.hQueue.h
Open the project folder and configure the compiler toolchain if prompted. If CLion asks for a build configuration, create one that compiles:
main.cpp LinkedList.cpp Stack.cpp Queue.cppIf the compiler says a header file cannot be found, make sure all source and header files are in the same project folder.
If Windows says g++ is not recognized, the compiler is either not installed or not added to PATH.
If the program compiles but does not run from PowerShell, run it with:
.\dsa_test.exeIf Visual Studio reports errors related to unsafe functions or precompiled headers, create a plain empty C++ console project and disable precompiled headers for this assignment.