Concept of an Element (Node)

From

(Difference between revisions)
Jump to: navigation, search
(Created page with 'A node is the unit of reference in a data structure. It is an abstract'' encapsulation ''structure that contains the data element that is held in the container (da...')
(Examples of Abstract Node Implementation)
 
(9 intermediate revisions not shown)
Line 1: Line 1:
-
A node is the unit of reference in a data structure. It is an abstract'' encapsulation ''structure that contains the data element that is held in the container (data structure). Also known as a vertex in graphs and trees.  
+
<noinclude>
 +
{{CS2:BookNav|base=/|up=Contents: CS2|prev=Primitive and Composite Structures|next=Abstract Data Types}}
 +
</noinclude>
 +
<br/>
 +
A '''node''' is an abstract basic unit used to build linked data structures such as linked lists, trees, and graphs. Each node contains some data and possibly links to other nodes. Links between nodes are often implemented by pointers or references.
 +
<br/><br/>
 +
A node can be thought of as a logical placeholder for some data. It is a memory block which contains some data unit and perhaps references to other nodes, which in turn contain data and perhaps references to yet more nodes. By forming chains of interlinked nodes, very large and complex data structures can be formed.
 +
<br/><br/>
-
A node&nbsp;may&nbsp;encapsulate&nbsp;a&nbsp;collection of information or a singular value&nbsp;which represents a single concept or object.&nbsp; A node is a referenced element commonly implemented using pointers, arrays, records, structs, file records&nbsp;(external storage), or even as a concept in a DBMS system.
+
== Examples of Abstract Node Implementation ==
 +
A node containing a single reference field.
 +
  '''class''' ''Node'' {
 +
    data ''// The data being stored in the node''
 +
    next ''// A reference to the next node, null if last node''
 +
  }
-
(...need diagram here...)
+
Here three such nodes form a singly-linked list of length 3.
 +
<br>[[Image:Singly-linked-list.svg]]
 +
<br>
-
(...Java Example Link...)
+
A node containing two reference fields.
-
(...C++ Example Link...)&nbsp;
+
  '''class''' ''Node'' {
 +
    data ''// The data being stored in the node''
 +
    previous ''// A reference to the previous node, null if first node''
 +
    next ''// A reference to the next node, null if last node''
 +
  }
 +
Here three such nodes form a doubly-linked list of length 3.
 +
&nbsp;&nbsp;&nbsp; [[Image:Doubly-linked-list.svg]]
-
[[CS-2|Back to Data Structures]]
+
 
 +
----
 +
{{CS2/ChapNav}}
 +
----
 +
[[Category:CS2|{{SUBPAGENAME}}]]

Current revision as of 22:16, 9 April 2009

← Primitive and Composite Structures ↑ Contents: CS2 Abstract Data Types →


A node is an abstract basic unit used to build linked data structures such as linked lists, trees, and graphs. Each node contains some data and possibly links to other nodes. Links between nodes are often implemented by pointers or references.

A node can be thought of as a logical placeholder for some data. It is a memory block which contains some data unit and perhaps references to other nodes, which in turn contain data and perhaps references to yet more nodes. By forming chains of interlinked nodes, very large and complex data structures can be formed.

Examples of Abstract Node Implementation

A node containing a single reference field.

 class Node {
    data // The data being stored in the node
    next // A reference to the next node, null if last node
 }

Here three such nodes form a singly-linked list of length 3.


Image:Singly-linked-list.svg


A node containing two reference fields.

 class Node {
    data // The data being stored in the node
    previous // A reference to the previous node, null if first node
    next // A reference to the next node, null if last node
 }

Here three such nodes form a doubly-linked list of length 3.


    Image:Doubly-linked-list.svg



CS2: Data Structures
Theory of Computation - ADT Preliminaries
Linear ADTs - Tree ADTs - Graph ADTs - Unordered Collection ADTs


Personal tools
MediaWiki Appliance - Powered by TurnKey Linux