n represents the most often executed statement in the entire algorithm, or comparing a character to another character...which is why this algorithm is O(n^2). n represents BOTH the length of the word AND the number of words in the database...hence the innermost statement will execute n^2 times, worst case.
however this performance can be improved to O(log^2 n) if a binary search or some other more intelligent search algorithm is implemented (course then the database has to be sorted).
Correction, it can be improved to O(n log n) with a binary search.
n represents the most often executed statement in the entire algorithm, or comparing a character to another character...which is why this algorithm is O(n^2). n represents BOTH the length of the word AND the number of words in the database...hence the innermost statement will execute n^2 times, worst case.
however this performance can be improved to O(log^2 n) if a binary search or some other more intelligent search algorithm is implemented (course then the database has to be sorted).
maybe what's really wrong is that your television only has 512 dots.