I'm revisiting materials on Algorithms and finding below book very useful.
The first 2 chapters are very impressive in setting a base, actively working through the rest of book.
A "problem" can be defined as collection of data processed by the program to create a solution for the data. Though its difficult to establish a standard problem
definition for real world scenarios, its can help if data inputs & data properties (encoding) are well understood.
When choosing an algorithm using abstraction on rate of growth, ex. evaluating a value in an set of number, the estimated average evaluations needed can be formulated
mathematically. Typically for high growth rate problems, the constants in formulation can be ignored. But care needs to be taken for scenarios like small growth or small number set,
as algorithm application changes. As a principle, the choice for algorithm depends on type of problem and distribution of elements in problem. There is no optimal algorithm for
problem of a given nature.
Methodology for choosing an algorithm:
Perform 3 case analysis viz. worst-case, average-case and best-case
The performance families in terms of decreasing efficiency are viz.
constant O(n)
logarithmic
sublinear
linear = eg. addition
nlog(n)
quadratic eg. multiplication
exponential
The author did lose me during the mathematical analysis and formulation of Big O notations for each member of performance family. Its a to do to check the reference section and build skills sets in those.
The graphical patterns of performance family definitely gives a visual clue as what type of operation is the algorithm using. very nice.
A side note about distribution:
binary tree distribution: works well during search when items are equally or roughly equally distributed(red-black tree) in a binary tree
ordered distribution : n/2 items need be compared on an average to search for an item
No comments:
Post a Comment