A linear table is a common data structure, which is characterized by a one-to-one linear relationship between data elements. According to the storage method and implementation method of the linear table, the linear table mainly has the following types:
1. Sequential List:
- Usually implemented using an array.
- Elements are stored contiguously in memory.
- Insertion and deletion operations may require the movement of large numbers of elements.
- Accessing an element at a specific index is very fast.
2. Linked List:
- Connect its elements according to pointers or links.
- According to the type of link, it can be subdivided into:
- Singly Linked List: Each element has only one pointer to the next element.
- Doubly Linked List: Each element has two pointers, one pointing to the previous element and the other pointing to the next element.
- Circular Linked List: The last element points to the first element.
3. Stack (Stack):
- Operates on the principle of last in first out (LIFO).
- Can be implemented using an array or a linked list.
- The main operations include push (insert) and pop (delete).
4. Queue:
- Operates on the principle of first in first out (FIFO).
- Can be implemented using an array or a linked list.
- The main operations include enqueue (insert) and dequeue (delete).
- Special queues:
- Double-ended queue (Deque): Allows insertion and deletion operations on both the front end and the back end.
- Circular Queue: It is a queue implementation that connects arrays end to end.
5. String (String):
- It is a special linear table whose elements are characters.
- Usually implemented using an array.