Information About

One-pass Algorithm





Example problems solvable by one-pass algorithms

Given any list as an input:
  • Count the number of elements.

  • Find the ''n''th element (or report that the list has fewer than ''n'' elements).

  • Find the ''n''th element from the end (or report that the list has fewer than ''n'' elements).


Given a list of numbers:

Given a list of symbols from an alphabet of ''k'' symbols, given in advance.
  • Count the number of times each symbol appears in the input.

  • Find the most or least frequent elements.

  • Sort the list according to some order on the symbols (possible since the number of symbols is limited).

  • Find the maximum gap between two appearances of a given symbol.



Example problems not solvable by one-pass algorithms

Given any list as an input:
  • Find the middle element of the list.


Given a list of numbers:
  • Find the Median .

  • Find the Mode s (This is not the same is finding the most frequent symbol from a limited alphabet).

  • Sort the list.