Join Patrick Royal for an in-depth discussion in this video My solution: Designing an efficient algorithm, part of Code Clinic: Java.
-[Voiceover] So far when I've discussed the algorithm…that I used to solve this problem, I've implied…that we are searching every possible image placement…and comparing the different scores as applied…to every possible pixel.…However, some quick calculation will show that this is…an extremely inefficient method of searching.…For instance, if I let image one be in pixels by in pixels…and image two be in pixels by in pixels,…then the brute force algorithm will operate as follows.…First it loops over all n minus m starting positions…for the sub-image, both horizontally and vertically…for a total of n minus m squared test.…
Then for each test, it must calculate the different score…which requires n times m which is m squared comparisons.…Overall then, this algorithm takes n-m squared…times m squared which is n squared m squared…minus two nm cubed plus m to the fourth.…Now the key term here is the m to the fourth power.…This means that the algorithm will scale up in complexity…incredibly quickly as the image resolution gets larger.…
Patrick introduces challenges and provide an overview of his solutions in Java. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, PHP, Python, and Ruby.
Skill Level Intermediate
Problem One: Exploring Lake Pend Oreille
Problem Two: Image Analysis
Problem Three: Eight Queens
Problem Four: Accessing Peripherals
Problem Five: Recursion and Directories
Problem Six: Building the Web
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.