Skip to content

pmarangone/Sorting-Visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sorting Visualizer in C++

This is my Capstone Project for the Udacity C++ Nanodegree. After launching the program you can choose (with your mouse) between Merge Sort, QuickSort, and Bubble Sort. When the sorting is done, you can generate a new array and pick another algorithm. To exit, press ESC.

alt text

Project Structure

button.h/button.cpp: Contains a class Button that is responsible for creating places in the screen where it is responsive to clicks.

layout.h/layout.cpp: Contains a class Layout that was written with the goal of easy portability. You can place it in a SDL application and add text to it with ease. Here, it display the sorting algorithm names and the project name.

quickSort.h/mergeSort.h: Contains both the functions that operate in the array and the functions that are responsible for the update of the screen and display of the sorting algorithm.

main.h/main.cpp: Contains the initialization of SDL and SDL_TFF. The text and buttons are inicialized afterwards. The first loop keeps checking for input of the user (through the buttons in the screen and keys) and a second loop is started only if the user choose a sorting algorithm and inicialize it. A condition variable is then used with a mutex to restrict changes in the array until the end of the sorting.

Dependencies for Running Locally (extended from here)

Basic Build Instructions

  1. Clone this repo.
  2. Make a build directory in the top level directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./Visualizer.

Basic Instructions

  • Rightwards arrow ( → ) increments array size
  • Leftwards arrow ( ← ) decrements array size

References for SDL: