This interactive application visualizes common sorting and graph algorithms. It's designed to help computer science students and enthusiasts understand how different algorithms work through step-by-step visualization.
-
Sorting Algorithm Visualizations:
- Bubble Sort
- Insertion Sort
- Selection Sort
- Merge Sort
- Quick Sort
-
Graph Algorithm Visualizations:
- Breadth-First Search (BFS)
- Depth-First Search (DFS)
- Dijkstra's Algorithm
-
Interactive Controls:
- Pause/Resume visualization
- Adjust array size and graph complexity
- Return to menu to select different algorithms
This project requires SDL2 and SDL2_ttf libraries.
Using Homebrew:
brew install sdl2 sdl2_ttfsudo apt-get install libsdl2-dev libsdl2-ttf-dev- Download SDL2 development libraries for MinGW from SDL2 website
- Download SDL2_ttf from SDL2_ttf website
- Extract both to a convenient location
- Add the bin directories to your PATH environment variable
- Clone the repository:
git clone https://github.com/ADJB1212/AlgorithmViz.git
cd AlgorithmViz- Build the project:
makeThis will compile the project and create an executable named algo.
- Run the application:
./algo-
Start the Application: Run the executable to launch the menu screen.
-
Select an Algorithm: Click on any of the available algorithms from the menu.
-
Customize Parameters: Adjust the array size or graph complexity using the slider.
-
Start Visualization: Click the "Start Visualization" button to begin.
-
Controls During Visualization:
Space: Pause/Resume the visualizationEsc: Return to the menu screen
The application requires the Arial font. Make sure arial.ttf is in the same directory as the executable, or modify the source code to use a different font.
- main.c: Entry point and application initialization
- visualizer.c: Core visualization logic
- algorithms.c: Implementation of all algorithms
- ui.c: User interface components
- graph.c: Graph data structure and rendering
The default Makefile is configured for macOS with Homebrew-installed SDL2. If your installation is in a different location, update the CFLAGS and LDFLAGS in the Makefile.
You might need to modify the Makefile:
CC = gcc
CFLAGS = -Wall -Wextra -I/usr/include/SDL2
LDFLAGS = -lSDL2 -lSDL2_ttf -lm
SRC = main.c visualizer.c algorithms.c ui.c graph.c
OBJ = $(SRC:.c=.o)
EXECUTABLE = algo
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJ)
$(CC) $(OBJ) -o $@ $(LDFLAGS)
rm -f $(OBJ)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJ) $(EXECUTABLE)
run: $(EXECUTABLE)
./$(EXECUTABLE)CC = gcc
CFLAGS = -Wall -Wextra -IC:/SDL2/include -IC:/SDL2_ttf/include
LDFLAGS = -LC:/SDL2/lib -LC:/SDL2_ttf/lib -lSDL2 -lSDL2_ttf -lm
SRC = main.c visualizer.c algorithms.c ui.c graph.c
OBJ = $(SRC:.c=.o)
EXECUTABLE = algo.exe
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJ)
$(CC) $(OBJ) -o $@ $(LDFLAGS)
rm -f $(OBJ)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJ) $(EXECUTABLE)
run: $(EXECUTABLE)
./$(EXECUTABLE)Replace C:/SDL2/ and C:/SDL2_ttf/ with your actual SDL2 installation paths.
- macOS: Verify SDL2 installation with
brew list sdl2 sdl2_ttf - Linux: Check installation with
ldconfig -p | grep SDL - Windows: Ensure SDL2 and SDL2_ttf DLLs are in your system PATH or in the same directory as the executable
- Check that all header files are correctly included
- Verify that SDL2 development libraries are properly installed
- Make sure the compiler can find the SDL2 headers (check CFLAGS)
- Font not found: Place
arial.ttfin the executable directory - Window creation failed: Check SDL initialization and video driver support
