What does the data structure and algorithm do?
A data structure is a form of organization in a computer's memory space or disk. Data structures include arrays, linked lists, stacks, binary trees, hash tables, and so on. The algorithm handles the data in these structures in various ways, such as finding a particular item of data or sorting the data.
Overview of data structures
| Data |
Advantages |
Disadvantages |
| Array |
Insert fast, and if you know the subscript, you can access it very quickly |
Find slow, delete slow, fixed size |
| Ordered array |
Faster than unordered array lookups |
Delete and insert slow, fixed size |
| Stack |
Provide last-in, first-out mode access |
Access to other items is slow |
| Queue |
Provides first-in, out-of-the-way access |
Access to other items is slow |
| Linked list |
Insert Fast, delete fast |
Find Slow |
| Two-fork Tree |
Find, INSERT, delete fast (such as fruit trees maintain balance) |
Delete Algorithm Complex |
| Red-Haishi |
Find, insert, delete are quick. The tree is always balanced. |
Algorithmic complexity |
| 2-3-4 Tree |
Find, insert, delete are quick. The tree is always balanced. |
Algorithmic complexity |
| Hash table |
If the keyword is known, access is extremely fast. Insert Fast |
Delete slow, if you do not know the keyword access is slow, the use of storage space is not sufficient |
| Heap |
Insert, delete fast, access to the largest data items quickly |
Slow access to other data items |
| Figure |
Modeling the real World |
Some algorithms are slow and complex |
An overview of the algorithm
Many of the algorithms that will be discussed apply directly to some special data structures. For most data structures, you need to know how to
- Insert a new item of data
- Looking for a particular item of data
- Delete a specific item of data
You also need to know how to iterate through the data items in a data structure for display or other operations. Another important category of algorithms is sequencing, which has a number of algorithms, which will be discussed later. The concept of recursion is important when designing certain algorithms. Recursion means that a method calls itself.
Java Data structures and algorithms (i): an overview