Exponential Search Visualizer using PyQt5
In this article we will see how we can make a PyQt5 application which will visualize the Exponential search algorithm.
Exponential search can also be used to search in bounded lists. Exponential search can even out-perform more traditional searches for bounded lists, such as binary search, when the element being searched for is near the beginning of the array. This is because exponential search will run in O(log i) time, where i is the index of the element being searched for in the list, whereas binary search would run in O(log n) time, where n is the number of elements in the list.
GUI implementation steps :
1. Create a list of label according to the given list of numbers
2. Set their text, border, color and geometry with the respective gap from each other
3. Each label height should be proportional to the value of each number
4. Create a start and pause push button to start the searching and pause the searching
5. Create a result label to show the searching status
Back end implementation steps :
1. Create label list corresponding to the given numbers
2. Create variable for the index used by exponential search and other variable used by binary search index and flag for searching and flag for binary and exponential search.
3. Add action to the push button their action should change the flag status i.e start action should make flag true and pause action should make flag false.
4. Create timer object which calls a method after every specific time
5. Inside the timer method check for the flag is flag is true begin the exponential search algorithm
6. Check if value lies within the range if not show output as not found else continue
7. Start finding value at index if found stop the search and show result else double the index value
8. Find the range in which value would be and start binary search and set the lower and upper value of binary search
9. Show result with the help of binary search
Below is the implementation
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course