C How to traverse the data structure C Implement the data structure of the buffer pool

Updated on technology 2024-04-11
8 answers
  1. Anonymous users2024-02-07

    What do you mean by this? There are countless kinds of data structures, anyone can design a suitable data structure according to their own needs, as for traversal, the method should also be designed according to the specific structure, there are several commonly used traversals: traversal of sequential containers, traversal of trees and traversal of graphs (networks).

    Sequential traversal is easy to think of, starting from the first node and accessing sequentially until the last node, the traversal of the tree and the traversal of the graph can basically be divided into two kinds, one is depth priority, and the other is breadth priority. The main idea of depth first is that for the current node, if there are neighbors that have not been visited, then select them to access, and then iteratively access the node until all the neighbors of the current node have been visited, then return to its previous node to continue iterative execution, which is not easy to understand. For example, take a maze and when you come across a junction (which can be a fork, an intersection, or more branches), choose one of them and keep going until you reach a dead end, then go back to the last intersection you encountered.

    The principle of breadth priority is that for the current node, all of its unvisited neighbors are accessed in a certain order, and then these nodes are iteratively accessed in turn. For example, if you walk the maze and encounter an intersection, then send a doppelganger to each branch route to continue until you encounter the next intersection, and then branch visit the intersection at the same time, if you don't understand, I recommend you to read the book on data structures, I personally recommend the best book is Introduction to Algorithms, a must-read book for programmers. It's well explained.

    As for the data structure traversal in C you mentioned, I guess you're talking about the stl container, right? In fact, basically, only the sequential container has an interface for traversal, which is implemented by an iterator, and the specific meaning of the iterator will not be detailed, but a short paragraph ** to illustrate.

    .//code

    listlist;Create a list container.

    for(int i=0;i<10;i++)

    Inserts ten elements, each with its designator.

    At this point, there are ten elements in the list.

    Here's the traversal.

    for(list::iterator iter=;iter!=;iter++)

    is the location of the first element in the list. What is returned is the next position of the list element.

    Cout<<(iter) "I don't know if it's written like this, if you want to use a specific container, just look for msdn, it's very clear.

    .//code

  2. Anonymous users2024-02-06

    c Probably don't need to think about custom data structures, right? Wouldn't it be nice to use ready-made data structures such as hash tables or lists, stacks, queues, memory serialization, etc., and then store an array of size 512?

    And sometimes it's better not to do a buffer pool, because you have to implement the aging of the buffer pool data, synchronization and fast loading and other problems yourself. So I don't care too much about buffering for local data in general, unless it's remote data.

  3. Anonymous users2024-02-05

    Do you know the principles and applications of specific data structures? You know what kind of love dao zhi is in

    In this case, what kind of special structure should be used to reduce the cost of other structures? Data structures are not just structures for storing data, but more importantly for them to have their own uses and characteristics...

    Don't be a utility worker ... That kind of person can come out of high school training for a few months... The most important thing is that you need to be able to design tools, and even design rules...

  4. Anonymous users2024-02-04

    I'm a junior in college, and I also calculate a copy computer, so you can learn C first. Learning C is mainly about learning calculations.

    Method, not calculation method. Learn the calculation method well. Let's learn C++ again. The lessons you mentioned are based on my programming experience. It's pure, sweat first, I don't know why we have to learn this, let's look at C first and then look at C++.

  5. Anonymous users2024-02-03

    I don't know how you know how data structures work and how they work. If you don't learn it, it will be difficult to apply it to the corresponding data structure when you encounter practical problems.

  6. Anonymous users2024-02-02

    Important 1. There are so many data structures, you must at least know how to use them and where to use them.

    2. There are so many data structures that are not available, as long as the data that you want the value to pass can be a structure.

  7. Anonymous users2024-02-01

    The so-called stable sorting is two equal numbers, what is the order before the sorting, and what is the order after the sorting.

    For example, a=1, b=3, c=1, a, b, c, these 3 numbers are sorted, a is originally in front of c, if you can ensure that after sorting, a is still in front of c, it is a stable sorting, otherwise it is an unstable sorting.

    Stable sorting includes: bubbling sorting, inserting sorting, merging sorting, and cardinality sorting.

    Unstable sorting includes: selection sorting, quick sorting, Hill sorting (shell), and heap sorting.

  8. Anonymous users2024-01-31

    Stable sort means:

    If two elements are encountered to be equal during the sorting process, they do not swap the order.

    Such as 1, 2, 2, 4, 3

    The 2nd element and every 3 elements are equal when performing the sorting, but they do not swap the order.

    Unstable ordering means that the order of exchange is not the same.

Related questions
9 answers2024-04-11

A hash table (also known as a hash table) is a data structure that is directly accessed based on the key value. That is, it accesses records by mapping key values to a location in the table to speed up lookups. This mapping function is called a hash function, and the array that holds the records is called a hash table. >>>More

3 answers2024-04-11

I have the same issue.

12 answers2024-04-11

C++ Data Structures and Programming", Translated Edition, Robert LKruuse and Alexander Jby Ryba. >>>More

9 answers2024-04-11

Answer: c. The storage structure with a binary linked list is also the storage structure of the left child and the right brother. >>>More

8 answers2024-04-11

The double buffer on the Internet refers to the program of the graphic mode,You are in character mode,If you want to brush fast,Not with double buffer,But to write the screen directly。