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...')
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.  
+
A '''node''' is an abstract basic unit used to build linked [[data structure]]s such as [[tree data structure|trees]], [[linked list]]s, and computer-based representations of [[graph (data structure)|graphs]]. Each node contains some [[data]] and possibly links to other nodes. Links between nodes are often implemented by [[Data pointer|pointer]]s or [[Reference (computer science)|reference]]s.
 +
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.
 +
Nodes are conceptually similar to [[vertex (graph theory)|vertices]], which are elements of a [[Graph (mathematics)|graph]].
-
A node may encapsulate a collection of information or a singular value which represents a single concept or object.  A node is a referenced element commonly implemented using pointers, arrays, records, structs, file records (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 (computer science)|reference]] to the next node, null if last node''
 +
  }
 +
Here three such nodes form a singly-linked list of length 3.
-
(...need diagram here...)
+
[[Image:Node chain.svg]]
-
(...Java Example Link...)
+
A node containing two reference fields.
 +
  '''class''' ''Node'' {
 +
    data ''// The data being stored in the node''
 +
    previous ''// A [[Reference (computer science)|reference]] to the previous node, null if first node''
 +
    next ''// A [[Reference (computer science)|reference]] to the next node, null if last node''
 +
  }
-
(...C++ Example Link...) 
+
Here two such nodes form a doubly-linked list of length 2.
 +
[[Image:node chain.svg]]
 +
[[Category:Linked lists]]
 +
[[Category:Trees (structure)]]
 +
[[Category:Graph data structures]]
 +
 +
 +
 +
 +
(...Java Example Link...)
 +
 +
(...C++ Example Link...) 
 +
<br>
 +
<br>
-
[[CS-2|Back to Data Structures]]
+
[[/index.php/CS-2|Back to Data Structures]]

Revision as of 16:48, 25 March 2009

A node is an abstract basic unit used to build linked data structures such as trees, linked lists, and computer-based representations of 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.

Nodes are conceptually similar to vertices, which are elements of a graph.

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.


File:Node chain.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 two such nodes form a doubly-linked list of length 2.

File:Node chain.svg



(...Java Example Link...)

(...C++ Example Link...) 



Back to Data Structures

Personal tools
MediaWiki Appliance - Powered by TurnKey Linux