data-structures

Definition

Linear Data Structure

A data structure is called linear if its elements are arranged sequentially, one after another, forming a chain where each element (except potentially the first and the last) has a defined predecessor and successor.

Examples

Array

Definition

Array

An array is a data structure consisting of a collection of elements (values or variables), each identified by at least one array index or key. An array is stored such that the position of each element can be computed from its index tuple by a mathematical formula.

In most low-level implementations, an array is a contiguous block of memory.

Link to original

Linked List

Definition

Singly Linked List

A singly linked list is a linear data structure consisting of a sequence of nodes, where each node contains:

  • Value: The data stored in the node.
  • Next: A pointer or reference to the subsequent node in the sequence, or null if it is the terminal node (tail).

Unlike an array, a linked list does not store elements in contiguous memory locations. Instead, nodes are linked using pointers, allowing for efficient insertions and deletions.

Link to original