Hello everyone, I am May.
foreword
In the past, many noobs have come to ask about the content of data structures. The questions are basically how to learn about linked lists, stacks, queues, and trees.
On the one hand, I agree, but on the other hand, I feel that they really don't know much about data structures.
I told them that the first structure to learn is neither a linked list nor a stack queue, but:
Linear table!
The most basic data structure
The linear list is the simplest and most commonly used data structure, so that the most commonly heard linked lists, circular linked lists, and static linked lists are also derived from linear lists.
Logical structure of linear table
An ordered sequence consisting of n (n>0) data elements (also known as nodes) of the same data type.
Features:
Data elements are ordered and limited.
structure:
The first data element (first node) is unique and has no predecessor, the last data element is unique and has no successor (tail node), and the remaining data elements have only one direct predecessor and one direct successor.
The general appearance of a linear table
advantage:
flexible and simple
Can be lengthened/shortened
Data elements can be accessed, inserted, deleted, etc.
Nine basic operations
initialization
Premise: The linear table has not been initialized
Result : Initialized as an empty table
Determine whether it is an empty table
Premise: Linear table exists
Result : Empty table returns true, non-empty table returns false
get table length
Premise: Linear table exists
Result : Return 0 for an empty table, and return the number of elements for a non-empty table
get element
Premise: the linear table exists
Result : return the i-th element value
insert element
Premise: The linear table exists and the elements are valid
Result : The data element is inserted successfully, length +1
delete element
Premise: The linear table is a non-empty table
Result : Data elements are successfully deleted, length -1
positioning element position
Premise: The linear table exists and the elements are valid
Result : Return the position number of the element
destroy
Prerequisite: The linear table exists
Result : The linear table is successfully destroyed
empty
Premise: the linear table exists
Result : the linear table is set as an empty table
How to implement the above nine operations depends on which storage structure the linear table adopts.
storage structure
That's right, different storage structures correspond to different implementations.
There are 2 storage structures:
sequential storage
Linear table + sequential storage = sequential table
chain storage
Linear list + linked storage = linked list
Let's go here first, and continue next time.
summary
This time, I briefly said that the linear list is the starting point of all structures, and some of its characteristics. Later, I will focus on the sequential list and linked list, as well as the code implementation of the nine major operations.
If you can’t wait, you can take the complete learning materials of data structure and algorithms if you want, for personal study only, I wish you progress in your studies:
Data Structures and Algorithms Full Version Learning Materials
Hope the above content is helpful to you.
I wish you all the best in your studies.