Node (computer science)
Encyclopedia
A node is a record
consisting of one or more fields that are links to other nodes, and a data
field. The link and data fields are often implemented by pointer
s or reference
s although it is also quite common for the data to be embedded directly in the node. Nodes are used to build linked, often hierarchical, data structure
s such as linked list
s, trees, and graphs
. Large and complex data structures can be formed from groups of interlinked nodes. Nodes are conceptually similar to vertices
, which are elements of a graph
. Software is said to have a node graph architecture
when its organization consists of interlinked nodes.
record
SinglyLinkedNode {
next, // A reference
to the next node
data // Data or reference to data
}
Here, three such nodes form a singly linked list of length 3:
A node containing two node reference fields.
record DoublyLinkedNode {
previous, // A reference
to the previous node
next, // A reference to the next node
data // Data or reference to data
}
Here three such nodes form a doubly linked list of length 3:
Also common is a binary tree node containing references to left and right child nodes, and a reference to a parent node.
record BinaryNode {
parent, // A reference
to the parent node
left_child, // A reference to the left child node
right_child, // A reference to the right child node
data // Data or reference to data
}
Record (computer science)
In computer science, a record is an instance of a product of primitive data types called a tuple. In C it is the compound data in a struct. Records are among the simplest data structures. A record is a value that contains other values, typically in fixed number and sequence and typically indexed...
consisting of one or more fields that are links to other nodes, and a data
Data
The term data refers to qualitative or quantitative attributes of a variable or set of variables. Data are typically the results of measurements and can be the basis of graphs, images, or observations of a set of variables. Data are often viewed as the lowest level of abstraction from which...
field. The link and data fields are often implemented by pointer
Data pointer
In computer science, a pointer is a programming language data type whose value refers directly to another value stored elsewhere in the computer memory using its address...
s or reference
Reference (computer science)
In computer science, a reference is a value that enables a program to indirectly access a particular data item, such as a variable or a record, in the computer's memory or in some other storage device. The reference is said to refer to the data item, and accessing those data is called...
s although it is also quite common for the data to be embedded directly in the node. Nodes are used to build linked, often hierarchical, data structure
Data structure
In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks...
s such as linked list
Linked list
In computer science, a linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of a datum and a reference to the next node in the sequence; more complex variants add additional links...
s, trees, and graphs
Graph (data structure)
In computer science, a graph is an abstract data structure that is meant to implement the graph and hypergraph concepts from mathematics.A graph data structure consists of a finite set of ordered pairs, called edges or arcs, of certain entities called nodes or vertices...
. Large and complex data structures can be formed from groups of interlinked nodes. Nodes are conceptually similar to vertices
Vertex (graph theory)
In graph theory, a vertex or node is the fundamental unit out of which graphs are formed: an undirected graph consists of a set of vertices and a set of edges , while a directed graph consists of a set of vertices and a set of arcs...
, which are elements of a graph
Graph (mathematics)
In mathematics, a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected objects are represented by mathematical abstractions called vertices, and the links that connect some pairs of vertices are called edges...
. Software is said to have a node graph architecture
Node graph architecture
Node graph architecture is a type of software design which builds around modular node components which can be connected together to form a graph. Often the software's underlying node graph architecture is also exposed to the end user as a 2 dimensional visualization of the node graph...
when its organization consists of interlinked nodes.
Pseudocode implementation examples
A node containing a single node reference field.record
Record (computer science)
In computer science, a record is an instance of a product of primitive data types called a tuple. In C it is the compound data in a struct. Records are among the simplest data structures. A record is a value that contains other values, typically in fixed number and sequence and typically indexed...
SinglyLinkedNode {
next, // A reference
Reference (computer science)
In computer science, a reference is a value that enables a program to indirectly access a particular data item, such as a variable or a record, in the computer's memory or in some other storage device. The reference is said to refer to the data item, and accessing those data is called...
to the next node
data // Data or reference to data
}
Here, three such nodes form a singly linked list of length 3:
A node containing two node reference fields.
record DoublyLinkedNode {
previous, // A reference
Reference (computer science)
In computer science, a reference is a value that enables a program to indirectly access a particular data item, such as a variable or a record, in the computer's memory or in some other storage device. The reference is said to refer to the data item, and accessing those data is called...
to the previous node
next, // A reference to the next node
data // Data or reference to data
}
Here three such nodes form a doubly linked list of length 3:
Also common is a binary tree node containing references to left and right child nodes, and a reference to a parent node.
record BinaryNode {
parent, // A reference
Reference (computer science)
In computer science, a reference is a value that enables a program to indirectly access a particular data item, such as a variable or a record, in the computer's memory or in some other storage device. The reference is said to refer to the data item, and accessing those data is called...
to the parent node
left_child, // A reference to the left child node
right_child, // A reference to the right child node
data // Data or reference to data
}