How to prioritize the generation of trees based on the depth and breadth of adjacency tables?

Updated on technology 2024-02-09
7 answers
  1. Anonymous users2024-02-06

    1. If the left and right subtrees of the node, the left link field lchild indicates its left child node (ltag = 0), otherwise, the left link field indicates its predecessor (ltag = 1). If the node has a right subtree, the right-linked field rchild indicates its right child node (rtag = 0), otherwise, the right-linked field indicates its successor (rtag = 1).

    2. Click to implement this process, set the pointer p to point to the current node, and pre always point to the node you just visited, i.e. p's predecessor, to modify the successor clues of pre and predecessor. p's thread accesses the current node p for threading algorithmic processing.

    3. The left pointer field of node p is empty, and then the flag position is set to 1, and p-> lchild points to the previous node in the middle order pre (i.e., the left thread);

    If the right pointer field of the pre node is empty, its flag position is set to 1 and the pre-> rchild points to the successor p of the intermediate order (i.e. the right thread); Point pre to the node p you just visited (i.e., pre=p), threading the right subtree of p.

  2. Anonymous users2024-02-05

    Draw a diagram, and then search for traversal edges according to depth priority or breadth priority, connect edges, if the vertices have been visited, then do not connect the two vertices of the edge, I will take depth priority as an example to demonstrate.

  3. Anonymous users2024-02-04

    This is the result of enumeration from large to small in deep search.

  4. Anonymous users2024-02-03

    1. First of all, if the node is a right-left subtree, then the left chain domain lchild indicates its left child (ltag=0), otherwise, the left chain domain indicates its precursor (ltag=1). If the node has a right subtree, the right-chain domain rchild indicates its right child (rtag=0), otherwise, the right-chain domain indicates its successor (rtag=1).

    3. If the left pointer domain of node p is empty at the last few points, then the flag position is 1, and p->lchild points to the middle order precursor node (i.e., left clues); If the right pointer domain of node pre is empty, the flag position is 1, and pre->rchild points to the intermediate sequence successor node p (i.e., right clue); Point pre to node p (i.e., pre=p) that has just been visited, and clue the right subtree of p.

  5. Anonymous users2024-02-02

    Depth-first spanning tree unique.

    If you give a diagram and start from a certain point, is there only one way to draw a depth-first spanning tree? That is, is there a difference between left and right in this spanning tree?

    This is not necessarily unique, most of the time it is not unique, if a vertex has multiple unvisited adjacency points, then choose a different next point, the result is different.

    However, for depth-first programs, the result is unique because the storage structure and algorithm steps have been defined.

  6. Anonymous users2024-02-01

    The adjacency table is shown in the following figure:

    The depth-first traversal process looks like this:

    0->1->4->8->5 (backtrack 8), 8->6->2->7 (backtrack 0), 0->3

    Breadth-first traversal.

    Here's how it goes:

    The above numbers are all indexes, and adding 1 corresponds to the node number in the graph you gave.

  7. Anonymous users2024-01-31

    Answer] The idea of the breadth-first traversal algorithm of the :d graph is that for a node, Pi Laola first traverses the node, and then traverses all the adjacent nodes with thick points, while in the hierarchical traversal of the burning tree, for a node, the node is first traversed, and then all its sub-nodes are traversed.

Related questions
5 answers2024-02-09

I would like to introduce you to Yan Weimin's textbook "Data Structure" (C language version), which is currently a classic textbook with a good reputation in China. >>>More

16 answers2024-02-09

Just o(n) scans it once, millions of arrays are not big, and c can be opened so big for global variables. >>>More

5 answers2024-02-09

The algorithm is similar, but the language description is different, C is the basic! However, the C++ language is relatively simple, so it's good to get used to which one!! The data structure is mostly used in C++, it depends on which version of the textbook you use, if you learn C++, then use the C++ version of the textbook, the problem is not very big!! >>>More

15 answers2024-02-09

First of all, think about what data is stored in memory and what data is stored in files. >>>More

7 answers2024-02-09

The Huffman tree is:

The weighted path length of a tree is the sum of the weighted path lengths of all leaf nodes in the tree, and the weighted path length of a node is the product of the path length from the node to the root node and the weights on the node. >>>More