1. What is a data structure?
Data structure refers to the organization of data in computer memory space or disk; data structures include arrays, linked lists, stacks, binary trees, hash tables, and so on.
2. Characteristics of different data structures
data structure | advantage | shortcoming |
array | Insert is fast, if you know the subscript, you can access very quickly | Find slow, delete slow, fixed size |
sorted array | faster than unordered array lookup | Deletes and inserts are slow, fixed size |
stack | Provides LIFO access | Accessing other items is slow |
queue | Provides first-in, first-out access | Accessing other items is slow |
linked list | Insert and delete fast | lookup slow |
binary tree | Fast lookups, deletions, and insertions (if the tree is balanced) | The deletion algorithm is complex |
red-black tree | Find, delete, insert fast. Trees are always balanced | Algorithms are complex |
2-3-4 tree | Find, delete, insert fast. Trees are always balanced. Similar trees are useful for disk storage | Algorithms are complex |
hash table | Very fast access if the key is known. Insert fast | Deleting is slow, if you do not know the keyword, the access is very slow, and the storage space is not fully used |
heap | Fast insertion and deletion, fast storage of the largest data item | Slow access to other data items |
picture | Model the real world | Some algorithms are slow and complex |
3. What is an algorithm?
An algorithm is a process that accomplishes a specific task. Perform various processing on the data in these structures; for example: find or delete a specific data item; sort the data, etc.