Content deleted Content added
No edit summary |
dasdas |
||
Line 5:
In competitive analysis, one imagines an "adversary" that deliberately chooses difficult data, to maximize the ratio of the cost of the algorithm being studied and some optimal algorithm. Adversaries range in power from the ''oblivious adversary'', which has no knowledge of the random choices made by the algorithm pitted against it, to the ''adaptive adversary'' that has full knowledge of how an algorithm works and its internal state at any point during its execution. Note that this distinction is only meaningful for randomized algorithms. For a deterministic algorithm, either adversary can simply compute what state that algorithm must have at any time in the future, and choose difficult data accordingly.
For example, the quicksort algorithm chooses one element, called the "pivot", that is, on average, not too far from the center
The classic on-line problem first analysed with competitive analysis {{harv|Sleator|Tarjan|1985}} is the [[List update problem]]: Given a list of items and a sequence of requests for the various items, minimize the cost of accessing the list where the elements closer to the front of the list cost less to access. (Typically, the cost of accessing an item is equal to its position in the list.) After an access, the list may be rearranged. Most rearrangements have a cost. The ''Move-To-Front algorithm'' simply moves the requested item to the front after the access, at no cost. The ''Transpose algorithm'' swaps the accessed item with the item immediately before it, also at no cost. Classical methods of analysis showed that Transpose is optimal in certain contexts. In practice, Move-To-Front performed much better. Competitive analysis was used to show that an adversary can make Transpose perform arbitrarily badly compared to an optimal algorithm, whereas Move-To-Front can never be made to incur more than twice the cost of an optimal algorithm.
|