DEV Community

PiePirates
PiePirates

Posted on

FindFood program

https://github.com/PiePirates/FindFood

This program I made allows you to search for restaurants based on the type of restaurants.

I accomplished runtime of O(n/2) by using a maxheap and a heapsort function. I used the ord() function along with the string's of the types to sort the list of types in alphabetical order. I then used a search algorithm that iterates backwards through a list if its ord() value is greater than the ord() value at the middle index, and vice versa.

my user input function grabs the users input, and if the user misspells a type it'll give the user a list of types that are somewhat similar to what they originally inputted.

lastly once you get the users input it returns a nicely formatted list of restaurants.

In closing, this program runs smoother thanks to the initial heapsort, and would save heaps of time thanks to the program only having to perform (n/2) computations for each search as compared to the standard (n) for a basic search algorithm. The program's runtime could be improved further if the data was structured in a tree where a greedy algorithm could be implemented.

Top comments (0)