how to construct a tree using root tree’s code?

The Question is if we are given a binary code how construct a tree using that code? There was a question as follows:

By root tree’s 000101001111 code, reconstruct that tree.

and the complete answer: answer

The problem is i could not understand the answer. so could you please guide me or clear up the problem or introduce some refs. (because i could not find any)

Any help will be greatly appreciated.

How to solve following tree problem with number assigned to each node?

I have a tree whose nodes have numbers assigned to them initially. A series of $ Q$ queries are asked from $ n=0$ to $ n=Q-1$ seconds. During end of each second numbers on a node (which are not leaf) are removed and gets transferred to each direct child node. Numbers on leaf node remain as it is and number coming from parent gets added to them. At each query it is possible that new number is added to a node. How to solve this efficiently?

Example: Suppose I have a tree 1—–2——3——-4 (1 is parent). Suppose at beginning numbers on nodes are 1, 2, 3, 4 respectively. Then at…

At zero second end 5 is added to node zero. At end of 0 seconds numbers on node are 5, 1, 2, 7. (Note 1 is not added to 5 because it is removed).

At one second end, 1 is added to node 4, then numbers are 0, 5, 1, 10. Fourth node has number 10 since it received 2 from parent node and 1 is added and 7 was present on it.

Now suppose at two second end, I am asked to tell number on 2nd node?Answer is 0.

I mean that in each query either a number can be added on a node or a question can be asked like – what is number on $ ith$ node?
How to solve this in less than $ O(nQ)$ . Where $ n$ is number of nodes and $ Q$ is number of queries?

Given node and value find frequency of given value from node to root in a tree

A tree with N vertices and N-1 edges is present.

A value x can be inserted in any of the nodes.

A single node may contain multiple values.

How do I answer queries of the given type?

Given a node n and value v find frequency of v in the path from node n to the root of the tree.

I require an algorithm that answers such queries in log(N) time.

How to answer multiple queries for a tree?

I encountered an interesting problem based on tree-data-structure.

We are given a tree which has N nodes, with 1≤N≤105.

Time starts from second 1 and it continues for q seconds.

At each second, the value of each internal node is transferred to all of its child nodes. This happens with all the nodes, except leaf nodes.

Sometimes, at a given time p (seconds), we are asked to return the current value of node x.

There is this O(logN) approach: just find the pth ancestor of the given node x, and output its value.

A harder version of the same problem

Sometimes, at a given time p (seconds), we are asked to return the current value of node x, or we are said to update the value of node x to y.

How to solve this problem for q queries (seconds) efficiently, where 1≤q≤105.

Example

Input

N=5, q=8

Edges of the tree:-

4 3 3 1 5 2 1 2 

Values of nodes 1 to 5:-

1 10 4 9 4 

Queries:-

  • 1st second:- Add(1,6). Add the value 6 to node 1.
  • 2nd second:- What is the current value of node 3? (?,3)
  • 3rd second:- Add(3,5)
  • 4th second:- (?,3)
  • 5th second:- Add(2,2)
  • 6th second:- Add(5,10)
  • 7th second:- (?,5)
  • 8th second:- (?,4)

Expected Output

  • 6
  • 0
  • 33
  • 25

Explanation

  • 1st second: 6,1,1,13,14 (Values of all nodes)
  • 2nd second: 0,6,6,14,15
  • 3rd second: 0,0,5,20,21
  • 4th second: 0,0,0,25,21
  • 5th second: 0,2,0,25,21
  • 6th second: 0,0,0,25,33
  • 7th second: 0,0,0,25,33
  • 8th second: 0,0,0,25,33

Can I set the root-directory of the tree shown in Thunar?

The root-directory shown in the “tree”-view of thunar defaults to the current user’s home directory. I have a situation were I start thunar (in a script) for some other user. I would like the tree that is displayed to start in /home/some-user/Desktop (or so) and not to show anything above this level.

Is that, at all, possible ?

Thanks in advance And: thanks for this otherwise nice tool!

How to place an article into a tree structure on a mobile web ui

I’m creating a mobile first ui which creates content articles. During the creation of an article (title, body etc) i would like to place it into different taxonomies

The taxonomies are tree structures used to organise content.

I originally envisaged a text box which when typed into, filtered a list of paths.

For example:

Root -> complaints -> how to Root -> contact

When the path is selected a tag is rendered.

You can then select other paths which are also appropriate to your article .

Thus you end up with multiple tags which represent locations in the taxonomies.

This seems a tad rubbish

Any better suggestions?

implementar general tree c++

Tengo problemas para implementar el general tree, cree un struct nodo con un char info y un arreglo de punteros llamados hijos y cree un struct llamado raiz que tiene 19 nodos adentro y no necesito que la raiz tenga informacion cree el algoritmo bien (creo), pero cuando llamo a la funcion insertarletra, para que meter la primera letra al arbol me dice que tiene problemas en la forma por como estoy metiendo los datos aqui les dejo el algoritmo para que especificamente el error

                        struct nodo{                             char dato;                             nodo *hijo[10];                         };                          struct raiz{                             nodo *hijo[19];                         };                          void inserttree(string texto);                          nodo *crearnodo(char c);                          void insertarletra(raiz *&raiz, char c);                              int main(){                             ifstream archivo;                             char c;                             string texto;                             string n;                             int x,z;                             bool billetevalido=false;                             long long y;                             raiz arbol();                                      insertarletra(arbol,c);                                       }                           nodo *crearnodo(char c){                              nodo *nuevo_nodo = new nodo();                              nuevo_nodo->dato = c;                             for(int i=0;i<19;i++){                                 nuevo_nodo->hijo[i]= NULL;                             }                             return nuevo_nodo;                          }                          void insertarletra(raiz *&raiz,char c){                             for(int i=0;i<19;i++){                                 if(raiz->hijo[i]->dato==c){                                     return;                                 }                             }                                     for (int i=0;i<19;i++){                                         if (raiz->hijo[i]->dato!=c &&                                              raiz->hijo[i]->dato==NULL){                                             raiz->hijo[i]->dato==c;                                         }                                     }                                 } 

Height of epsilon-balanced binary search tree

In https://stackoverflow.com/questions/41932988/balanced-binary-search-trees-on-the-basis-of-size-of-left-and-right-child-subtre, Hannes says:

For example, one can say, a BST is balanced, if each subtree has at most epsilon * n nodes, where epsilon < 1 (for example epsilon = 3/4 or even epsilon = 0.999 — which are practically not balanced at all). The reason for that is that the height of such a BST is roughly log_{1/epsilon}

I am a bit puzzled on the last statement — how do we know that the height is roughly 1/epsilon?

Leaf nodes of B+ Tree

I have a b+ tree and i want to find the record associated with a specific key Ki. So i run the b+ tree search algorithm. If a certain node in the search path is a leaf and K=Ki, then the record exists in the table and we can return the record associated with Ki.

Since the leaf nodes have the same structure of internal nodes, how can the algorithm know if a node is a leaf node ?