Euclidean geometry In Euclidean geometry, length is measured along
straight lines unless otherwise specified and refers to
segments on them.
Pythagoras's theorem relating the length of the sides of a
right triangle is one of many applications in Euclidean geometry. Length may also be measured along other types of curves and is referred to as
arclength. In a
triangle, the length of an
altitude, a line segment drawn from a vertex
perpendicular to the side not passing through the vertex (referred to as a
base of the triangle), is called the height of the triangle. The
area of a
rectangle is defined to be length × width of the rectangle. If a long thin rectangle is stood up on its short side then its area could also be described as its height × width. The
volume of a
solid rectangular box (such as a
plank of wood) is often described as length × height × depth. The
perimeter of a
polygon is the sum of the lengths of its
sides. The
circumference of a circular
disk is the length of the
boundary (a
circle) of that disk.
Other geometries In other geometries, length may be measured along possibly curved paths, called
geodesics. The
Riemannian geometry used in
general relativity is an example of such a geometry. In
spherical geometry, length is measured along the
great circles on the sphere and the distance between two points on the sphere is the shorter of the two lengths on the great circle, which is determined by the plane through the two points and the center of the sphere.
Graph theory In an
unweighted graph, the length of a
cycle,
path, or
walk is the number of
edges it uses. In a
weighted graph, it may instead be the sum of the weights of the edges that it uses. Length is used to define the
shortest path,
girth (shortest cycle length), and
longest path between two
vertices in a graph.
Measure theory In measure theory, length is most often generalised to general sets of \mathbb{R}^n via the
Lebesgue measure. In the one-dimensional case, the Lebesgue outer measure of a set is defined in terms of the lengths of open intervals. Concretely, the length of an
open interval is first defined as : \ell(\{x\in\mathbb R\mid a so that the Lebesgue outer measure \mu^*(E) of a general set E may then be defined as : \mu^*(E)=\inf\left\{\sum_k \ell(I_k):I_k\text{ is a sequence of open intervals such that }E\subseteq\bigcup_k I_k\right\}.
Computer science In
computer science, the length of a
string is the number of
characters that comprise the string. For example, the
bit string \texttt{10010100001} has length 11. Many
programming languages have a string data type with a method for
length to retrieve the length of a string. String s = "Hello, world!"; int len = s.length(); // len = 13 The "length" of a
sequential data structure, such as a
dynamic array, can be described as the number of elements contained in it. import java.util.List; int[] a = {1, 2, 3, 4, 5}; int len = a.length; // len = 5 List list = List.of(1, 2, 3, 4, 5, 6, 7, 8); int len = list.size(); // len = 8 == Units ==