<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wcipeg.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Linked_list</id>
		<title>Linked list - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wcipeg.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Linked_list"/>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Linked_list&amp;action=history"/>
		<updated>2026-04-26T17:37:06Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.25.2</generator>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Linked_list&amp;diff=1550&amp;oldid=prev</id>
		<title>Brian: + cons, snoc</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Linked_list&amp;diff=1550&amp;oldid=prev"/>
				<updated>2011-12-30T02:16:51Z</updated>
		
		<summary type="html">&lt;p&gt;+ cons, snoc&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 02:16, 30 December 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L2&quot; &gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Terminology==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Terminology==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each object stored in a linked list is known as an '''element''' or '''value'''. The address of the next value is known as a '''link''', as it &amp;quot;links&amp;quot; the element to the next one. A value and the corresponding link, stored together and taken collectively, are known as a '''node''' of the list. The '''size''' or '''length''' of a linked list is the number of elements or nodes it contains. A list may be empty if it contains no elements. If it is not empty, its first node is known as the '''head''', and the rest of its elements, which themselves form a linked list, are known as the '''tail'''. There are traditionally two functions on a linked list: one that returns the head, known as '''car''', and one that returns the tail, known as '''cdr'''.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each object stored in a linked list is known as an '''element''' or '''value'''. The address of the next value is known as a '''link''', as it &amp;quot;links&amp;quot; the element to the next one. A value and the corresponding link, stored together and taken collectively, are known as a '''node''' of the list. The '''size''' or '''length''' of a linked list is the number of elements or nodes it contains. A list may be empty if it contains no elements. If it is not empty, its first node is known as the '''head''', and the rest of its elements, which themselves form a linked list, are known as the '''tail'''. There are traditionally two functions on a linked list: one that returns the head, known as '''car''', and one that returns the tail, known as '''cdr&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''. Adding an element to the beginning of a list&amp;amp;mdash;thus making it the head and the original list the tail&amp;amp;mdash;is called '''cons''', and adding an element to the end, '''snoc&lt;/ins&gt;'''.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Implementation==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Implementation==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Brian</name></author>	</entry>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Linked_list&amp;diff=1549&amp;oldid=prev</id>
		<title>Brian at 01:18, 30 December 2011</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Linked_list&amp;diff=1549&amp;oldid=prev"/>
				<updated>2011-12-30T01:18:31Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 01:18, 30 December 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L20&quot; &gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Doubly linked lists===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Doubly linked lists===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In some lists, each node also contains a link that points to the ''previous'' node (except possibly the first node, which may or may not point back to the head node). Doubly linked lists may be efficiently traversed both forward and backward (if the head node contains a pointer to the last element), and allow ''erase'' to be implemented efficiently without foreknowledge of the address of the node preceding the one we wish to erase.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In some lists, each node also contains a link that points to the ''previous'' node (except possibly the first node, which may or may not point back to the head node). Doubly linked lists may be efficiently traversed both forward and backward (if the head node contains a pointer to the last element), and allow ''erase'' to be implemented efficiently without foreknowledge of the address of the node preceding the one we wish to erase.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Data structures]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Brian</name></author>	</entry>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Linked_list&amp;diff=1093&amp;oldid=prev</id>
		<title>Brian: Created page with &quot;The '''linked list''', often referred to simply as a ''list'', is a data structure that organizes a sequence of objects, all of the same type and size, in memory, so that eac...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Linked_list&amp;diff=1093&amp;oldid=prev"/>
				<updated>2011-03-05T23:12:52Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;The &amp;#039;&amp;#039;&amp;#039;linked list&amp;#039;&amp;#039;&amp;#039;, often referred to simply as a &amp;#039;&amp;#039;list&amp;#039;&amp;#039;, is a data structure that organizes a &lt;a href=&quot;/wiki/Sequence&quot; title=&quot;Sequence&quot;&gt;sequence&lt;/a&gt; of objects, all of the same type and size, in memory, so that eac...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The '''linked list''', often referred to simply as a ''list'', is a data structure that organizes a [[sequence]] of objects, all of the same type and size, in memory, so that each element except the last is stored along with the address of the next element. Here addresses are not required to occur in arithmetic progression, unlike in [[array]]s. Lists arise in a natural way in the [[lambda calculus]] and so they are fundamental to most [[functional programming language]]s.&lt;br /&gt;
&lt;br /&gt;
==Terminology==&lt;br /&gt;
Each object stored in a linked list is known as an '''element''' or '''value'''. The address of the next value is known as a '''link''', as it &amp;quot;links&amp;quot; the element to the next one. A value and the corresponding link, stored together and taken collectively, are known as a '''node''' of the list. The '''size''' or '''length''' of a linked list is the number of elements or nodes it contains. A list may be empty if it contains no elements. If it is not empty, its first node is known as the '''head''', and the rest of its elements, which themselves form a linked list, are known as the '''tail'''. There are traditionally two functions on a linked list: one that returns the head, known as '''car''', and one that returns the tail, known as '''cdr'''.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
In an [[imperative programming language]], a node of a linked list is typically represented using a record type that contains both the value and a [[pointer]] to the next node; the address of the next node can be recovered from the pointer. A sentinel value, such as a null pointer, is often used for the link field of the last node in the list.&lt;br /&gt;
&lt;br /&gt;
Because the list may be empty, we cannot assume that we can remember &amp;quot;where it is&amp;quot; using the address of its first node. Instead, a linked list usually has a ''head node'' that contains a pointer to the head of the actual list, which will be null when the list actually contains no first element at all. The head node may also store the length of the list and/or the address of the ''last'' element.&lt;br /&gt;
&lt;br /&gt;
===Operations on lists===&lt;br /&gt;
In the time bounds quoted below, &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; refers to the length of the list.&lt;br /&gt;
* Lists support efficient sequential traversal of their elements, also known as ''iteration''. For example, suppose we wanted to find the sum of all elements in the list. Then we would start at the first element, add its value to an accumulator, follow the link to the next element, and so on until reaching the end of the list, which gives &amp;lt;math&amp;gt;O(N)&amp;lt;/math&amp;gt; time.&lt;br /&gt;
* An element may be inserted into a list in &amp;lt;math&amp;gt;O(1)&amp;lt;/math&amp;gt; time. Suppose we wished to insert node '''b''' between nodes '''a''' and '''c'''. Then we would set the link of '''b''' to point to '''c''' and set the link of '''a''' to point to '''b''' (it formerly pointed to '''c'''). Contrast this with an array, which requires &amp;lt;math&amp;gt;O(N)&amp;lt;/math&amp;gt; time to do the same.&lt;br /&gt;
* An element may be deleted from a list in &amp;lt;math&amp;gt;O(1)&amp;lt;/math&amp;gt; time; all we have to do is make the link of the previous element point to the next element (this is like &amp;quot;skipping&amp;quot; that element). (A subtlety here, and in a few of the other operations, is that if we are only given the address of the element we wish to delete, we cannot efficiently determine the address of the previous element unless the list is doubly linked; see below.)&lt;br /&gt;
* ''Splicing'' refers to two operations. Given a list, a starting node, and an ending node within that list, we can easily remove all elements between the starting and ending node from the list, putting them into a separate list; this only requires changing a few links at the boundaries. We may also take a list and insert the entire thing between two adjacent nodes of another list; again, this only requires changing a few links at the boundaries. These operations both take &amp;lt;math&amp;gt;O(1)&amp;lt;/math&amp;gt; time.&lt;br /&gt;
:* Special case: Two lists can be concatenated in &amp;lt;math&amp;gt;O(1)&amp;lt;/math&amp;gt; time, if we know in advance the address of the last node of the first.&lt;br /&gt;
* Lists do ''not'' support efficient random access; if we need to find the 1000&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; element in a list, we will have to start at the first element and follow 999 links to get to the 1000&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt;. So random access takes &amp;lt;math&amp;gt;O(N)&amp;lt;/math&amp;gt; time. If efficient random access is important, it might be better to use an array; if efficient random access and efficient insertion and removal of elements are both important, it is advisable to use a [[Binary search tree|tree]].&lt;br /&gt;
&lt;br /&gt;
===Doubly linked lists===&lt;br /&gt;
In some lists, each node also contains a link that points to the ''previous'' node (except possibly the first node, which may or may not point back to the head node). Doubly linked lists may be efficiently traversed both forward and backward (if the head node contains a pointer to the last element), and allow ''erase'' to be implemented efficiently without foreknowledge of the address of the node preceding the one we wish to erase.&lt;/div&gt;</summary>
		<author><name>Brian</name></author>	</entry>

	</feed>