Everything2
Near Matches
Ignore Exact
Full Text
Everything2

fencepost error

created by markadm

(idea) by Jargon (1.8 y) (print)   ?   (I like it!) Thu Jul 19 2001 at 8:34:01

fence = F = fiber-seeking backhoe

fencepost error n.

1. [common] A problem with the discrete equivalent of a boundary condition, often exhibited in programs by iterative loops. From the following problem: "If you build a fence 100 feet long with posts 10 feet apart, how many posts do you need?" (Either 9 or 11 is a better answer than the obvious 10.) For example, suppose you have a long list or array of items, and want to process items m through n; how many items are there? The obvious answer is n - m, but that is off by one; the right answer is n - m + 1. A program that used the `obvious' formula would have a fencepost error in it. See also zeroth and off-by-one error, and note that not all off-by-one errors are fencepost errors. The game of Musical Chairs involves a catastrophic off-by-one error where N people try to sit in N - 1 chairs, but it's not a fencepost error. Fencepost errors come from counting things rather than the spaces between them, or vice versa, or by neglecting to consider whether one should count one or both ends of a row. 2. [rare] An error induced by unexpected regularities in input values, which can (for instance) completely thwart a theoretically efficient binary tree or hash table implementation. (The error here involves the difference between expected and worst case behaviors of an algorithm.)

--The Jargon File version 4.3.1, ed. ESR, autonoded by rescdsk.


printable version
chaos

fiber-seeking backhoe zeroth off-by-one error feeping creaturism
banana problem fence Fidonet Existentialism
Seinfeld Seroquel =A= June 3, 2002
Array indexes as measure of a language's analness Brain Teaser Slop The Modern Lovers
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Look at this mess the Death Borg made!
Old Chestnut
Glossary of Genetics terms
The Amityville Horror
root log: February 2001
Collateral
Polish pronunciation
chocolate sorbet
Miss American Pie: A Century of Pizza in America
B-tree
The Ten Commandments Judge
Einstein-Podolsky-Rosen paradox
Inferiority complex
Paul Simon
New Writeups
Glowing Fish
Tualatin River(place)
The Jacket
Words of Advice(idea)
keepinitreal
Why buy the cow when you can get the milk for free?(idea)
John_Fox
Good Intentions Gone Wrong(person)
Cuckowski
Slavonic Princess(poetry)
Heitah
Posthumous Oscar(thing)
ignis_glaciesque
University of South Florida(place)
ignis_glaciesque
Flogstaskriket(idea)
liveforever
Caesar's last breath(idea)
dagnyswaggart
she wants to believe(personal)
antigravpussy
he doesn't know, but her eyes widen too far(thing)
dagnyswaggart
Wild tides guard her secrets(poetry)
Lord Brawl
Caesar's last breath(poetry)
locke baron
Forgotten things in space(fiction)
sitaraika
Colours(idea)
Everything 2 is brought to you by the letter C and The Everything Development Company