The charm of data structures convinced me

     Some guys are meant to be loved and hated!

      Data structure may not be unfamiliar in the eyes of most computer professionals. I don’t know how other people felt when they first came into contact with it. I was really stumped by it. Since then, data structure has become a part of my computer learning journey. shadow. I remember that at the beginning of my sophomore year, I still had a limited understanding of the C language, and the course that suddenly opened made me crazy - it was completely incomprehensible (it felt like I was listening to a book from heaven), and the teacher at the time didn't talk to us either. After talking about what this data structure can do and what it is useful for, I just finished the course in a daze, and I have no impression of it after finishing the exam. At that time, I thought that after the exam, I would completely get rid of the torture of data structure, but gradually I realized that the computer is destined to have data structure as a companion.

       There is a saying that the big cows say - you can be a programmer without learning data structures, but you must learn data structures if you want to be called a promising programmer. It can be understood that the depth of your understanding of the data structure determines the length and width of our technical road. So what is it that makes its status and influence so high, I will talk about my own experience and views.

       I didn't have much experience before going to graduate school, because I usually study various professional basic courses, some of which are completely independent, and some are related, but because of less application, I feel quite shallow. Even the final graduation project is just a simple management system that combines all the knowledge learned. In the four years of study experience, due to my low understanding and no teacher's guidance and guidance, the knowledge I have learned is only at the level of literacy and simple application. But later, due to the needs of the project, it is necessary to contact some algorithms. These algorithms use data structures to process data. For example, in the algorithm of two-dimensional images in image processing, trees may be used to divide the image into regions. At the stage of three-dimensional image processing More advanced octrees are used again. If you are not familiar with data structures at this point, it is another helpless pain. Another is that I was reviewing Java recently. When I saw the collection, I was really convinced by the data structure. How practical the container in Java is in actual development, the benefits it brings to development are indescribable, but they are The underlying implementation is the data structure used.

      These experiences suddenly made me want to take the initiative to get close to this tormenting guy, maybe this is its charm. Having said that, I have a small suggestion, if you are in college and you are going to take this course, don't be like me, you should study hard, even if you force yourself. And if you, like me, are suddenly attracted by its charm and decide to explore it, then I hope you can write more about your learning experience and share it with you, so that we can learn together.

------------------------------------------------------------------------      

Below is a brief summary of what is a data structure?

      Organize a batch of data according to a certain logical relationship, and then use computer language to store them in the computer's memory according to a certain storage method, and define a set of operations (search, delete, insert, modify) on these data. So the data structure actually contains the logical structure + storage structure.

1. The logical structure of data is usually divided into four types

  • Sets: The elements in a set are only in the same set and have no other relationship.
  • Linear Structure: Describes a one-to-one relationship between data elements.
  • Tree structure: Describes a one-to-many relationship between data elements.
  • Graph structure: Describes the many-to-many relationship of data elements.

2. Four storage methods in data structures

  • Sequential storage (for linear data structures): Logically adjacent nodes are stored in physically adjacent storage units, and the logical relationship between nodes is reflected by the adjacency of storage units. Storing data in this way forms a sequential storage structure - an array description in a high-level language .
  • Linked storage: It is not required that logically adjacent nodes are also adjacent in physical position, and the logical relationship between nodes is represented by additional pointers. The result is a chained storage structure (which makes efficient use of memory). Chained storage structures - described by pointers in high-level languages .
  • Index storage: Create an additional index table while storing nodes. Each item in the index table is called an index item (keyword id, address). If each node has an index entry in the index table, the index is called a dense index; if there is only one index entry in the index table of a group of nodes, it is called a sparse index (the index address points to this group of nodes). the starting storage location of the point). Useful for quick queries.
  • Hash storage: directly calculate the storage address of the node according to the key of the node.

3. What the data structure contains

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 fast, delete fast lookup slow
binary tree Fast lookups, insertions, deletions (if the tree is balanced) The deletion algorithm is complex
red-black tree Find, insert, delete fast. Trees are always balanced Algorithms are complex
2-3-4 tree Find, insert, delete 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

Delete is slow, if you don't know the keyword, the access is very slow, and the storage is empty

insufficient use of time

heap


picture

Fast insertion and deletion, fast access to the largest data item


Model the real world

Slow access to other data items


Some algorithms are slow and complex

-------------------------------------------------- --------
Then let's learn data structure together. I hope readers can actively share their own experiences and learning methods. If there is anything wrong with my summary in the future, I hope you can point it out.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325944728&siteId=291194637