Graphical Binary Search Program

I wrote this program near the end of grade 11. The visual binary search program prints an ordered list of numbers located in a file onto the screen in rows (in fact it prints each ‘number’ as its own JLabel and the JLabels are printed in rows). A dialog box opens requesting a number and offering two radio buttons to select the search type: brute force or binary search. After the user inputs a number and search method the program executes the search in 0.3s intervals, briefly ‘flashing’ (making the font bold and red) the number it is ‘analyzing.’

The GUI when the program first starts

The GUI when the program first starts

The program either finds the number, highlights it and prints 'Target found at index - ' or prints 'Target not found'

The program either finds the number, highlights it and prints ‘Target found at index – ‘ or prints ‘Target not found’

I consider this program is a design accomplishment because it is the first full program I independently designed and wrote and at the time it was a huge challenge and even bigger accomplishment for me. It was not a school project so there was no guideline, I simply had a list of objectives: visually represent an algorithm, have it be informative and enlightening. It was my job to figure out how to accomplish these tasks.

The first step was to identify stakeholders. The stakeholders were my class and the teacher (to whom I would present). Next, it follows that the objectives would have be easy to read and easy to see and follow (as the program runs). I researched methods of visually depicting including 3D graphics, JLabels and actual 2D Graphics. I gauged my time and resolved to use JLabels which were easier to understand and use. In addition, they would fufill my objectives and although they may have lacked in criteria, the criteria of ‘fastest implementation’ had a larger weight. This was the critique and compare process. I had compared designs using 3D graphics, 2D Graphics and JLabels. These examples and tutorials I consider ‘reference designs.’ I mimicked the reference designs and did many small tests and examples to test my understanding. These were prototypes. Finally, I refined my design, removing all bugs and finding specific shades of red and proper font. I ran tests on the projector picking out which font was easy to see while still allowing a large number of numbers to be displayed on the screen.

But more importantly, this program represents the program design principles I learned in cs106a (Stanford University’s Introduction to Computer Science: Programming Methodology), namely, ‘Top-Down design.’ I considered the big idea and the ‘big steps’ and gradually broke it down into steps and sub-steps forming a tree like pattern. I literally wrote down a tree and below I outlined pseudo-code to accomplish each of the leaves of the tree. I am very proud of this program because it was my first real program and I believe it was very elegantly written. It was very clean code. The second reason this program is a design accomplishment is because I had to independently learn a lot of 2D graphics. This required research, reading tutorials and most importantly scanning and understanding documentation.

Three classes: The array searcher which implements the searching algorithms, the prompt gui and the main gui (holding the numbers). Array searcher also has the main method which creates the gui

Three classes: The array searcher which implements the searching algorithms, the prompt gui and the main gui (holding the numbers).
Array searcher also has the main method which creates the gui

The 'Prompt' class.

The ‘Prompt’ class. This program was my first real use of ‘objects’

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s