## Data Structures – Given node and given value determine the frequency of the 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 each of the nodes.

A single node can contain multiple values.

How do I answer inquiries of the specified type?

Given a knot n and value v Find the frequency of v on the way from the knot n to the root of the tree.

## To place an article in a tree on a mobile web interface

I'm creating a mobile UI that creates content articles.
When creating an article (title, text, etc.) I would like to classify it into different taxonomies

The taxonomies are tree structures used to organize content.

I originally envisioned a text box into which a list of paths was filtered as you type.

For example:

Root -> complaints -> like
Root -> contact

When the path is selected, a tag is rendered.

You can then choose other paths that are also suitable for your article.

This will give you several tags that represent positions in the taxonomies.

This seems a bit rubbish

Better suggestions?

## bitcoin core – Unused output tree in the block chain

I read about the security of thin clients and came across the section that discusses the proposal of the unused output tree in the block chain.

Unused output tree in the block chain (UOT)
There have been several suggestions (the first seems to be that of gmaxwell, who called it "open transaction tree", although the term "open" now means "not yet included in the block chain" and not "not spent") Not around a tree used to form transaction outputs at each block in the chain, it is hashed as a Merkle tree and the root hash encoded in the block chain (probably as part of the Coinbase input) .This is referred to as the Unused Output Tree (UOT) Proposal seems to be that of Alberto Torres The etude etiquette's ultimate block compression is a variant of it.

If such UOT hashes were included in the block chain, a client delivered with a checkpoint block with a UOT would only need to download blocks after the checkpoint. After the client had downloaded these blocks and confirmed their UOTs, it was also able to discard all blocks except the last block that contained a UOT.

I understand this part and how the Merkle tree is constructed, but the next part that talks about the risks involved is what confuses me:

Enemy miners can insert blocks in the chain that are supposed to be a UOT but are actually invalid. It is unlikely that such blocks will be kept out of the chain, as this in turn would require the addition of a new pelleting criterion, and miners using this new criterion would run the risk of breaking down on the wrong side of a fork, which could cost them a lot of money. Therefore, any UOT strategy would have to deal with the fact that not every block containing a UOT entry can be trusted.

So my questions are:

1. I assume that an invalid UOT means a tree that contains outputs that are either duplicated or not even in the chain. Why can not the Bitcoin network reject it? Are complete nodes vulnerable to this attack? I think that full nodes can always compare the outputs in the UOT with the previous ones to make sure that all the outputs are either contained in the previous UOT or generated by transactions in the current block.
2. I understand that the implementation would require some changes to the current validity criteria. Would nodes adopting these changes take the risk of "dismantling on the wrong side"?

## Functions – Implement the general tree c ++

I'm having trouble implementing the common tree, creating a tree node with a char info and an array of pointers named children, creating a structure called root that contains 19 nodes, and I do not need the root so that information does the algorithm well create (I think). but when I call the function insertletra, so putting the first letter to the tree tells me that there are problems in the way I set the data here, I leave the algorithm, so specifically the 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

Take any path in the tree, starting with the root, and take into account the number of nodes in the subtree that are rooted at each vertex along the path. It is for the root $$n$$ Node. For the second corner it is at most $$epsilon n$$ Node. For the third corner point it is at most $$epsilon ^ 2 n$$ Node. For the $$t$$Vertex, it's at most $$epsilon ^ {t-1} n$$ Node. If the path has length $$ell$$ (Edges), then the last node contains at most $$epsilon ^ ell n$$ Knots and so on $$epsilon ^ ell n geq 1$$, or equivalently, $$ell leq log_ {1 / epsilon} n$$,

## 8 – Add an extra class to the last element of the navigation / tree menu

For one of my projects, I need to create a tree menu with parents and children that will be used to navigate the site. The parents are collapsible. Below is the branch file that I use to generate the menu:

{% macro menu_links(menu_tree, route_tid, current_depth, max_depth, collapsible) %}
{% import _self as macros %}
{% for item in menu_tree %}
{%
set liClass = (
)
%}


{% if item.image %}

{% endif %}

{{ item.name }}{% if item.show_count == true %} ({{ item.nodes|length }}){% endif %}

{% if item.subitem and current_depth < max_depth %}
{% if item.interactive_parent %}

{% endif %}
{% if collapsible == TRUE %}

{% else %}

{% endif %}

{% endif %}

{% endfor %}


{% endmacro%}

I wanted to know if it's possible to add an extra class to the last class of the tree menu. I actually tried to add current_depth == max_depth? & # 39; item – last & # 39 ;: & # 39; in the setliClass and {% if
current_depth == max_depth%} item – last {% endif%} "
in the li class = "{{liClass | join (# 39;}}}}" part, but that does not work.

## reactjs – Use custom image for the PrimeReact data tree icon

I am using the data tree component of PrimeReact [see below]. The tree component picks up an object with fields defined as such

const data = [
{
"key": "0",
"label": "Documents",
"data": "Documents Folder",
"icon": "pi pi-fw pi-inbox",
"children": [{
"key": "0-0",
"label": "Work",
"data": "Work Folder",
"icon": "pi pi-fw pi-cog",
"children": [{ "key": "0-0-0", "label": "Expenses.doc", "icon": "pi pi-fw pi-file", "data": "Expenses Document" }, { "key": "0-0-1", "label": "Resume.doc", "icon": "pi pi-fw pi-file", "data": "Resume Document" }]
},
{
"key": "0-1",
"label": "Home",
"data": "Home Folder",
"icon": "pi pi-fw pi-home",
"children": [{ "key": "0-1-0", "label": "Invoices.txt", "icon": "pi pi-fw pi-file", "data": "Invoices for this month" }]
}]
}
]


designated as such




The icon attribute determines the icon that appears next to the label tag. I want to use my own .png instead of the available symbols. I would initially try to add an img tag, but that does not seem to work. If more information is needed, please let me know.

https://www.primefaces.org/primereact/#/tree

## python – Reduces the binary tree to the linked list

I am trying to reduce a binary tree to a linked list.

I have a working, correct solution:

# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

def insert(root, node):
if root.right is None:
root.right = node
return None
else:
insert(root.right, node)
class Solution:
def flatten(self, root: TreeNode) -> None:
"""
Do not return anything, modify root in-place instead.
"""
if root is None:
return None
if root.left is None and root.right is None:
return root
left = self.flatten(root.left)
right = self.flatten(root.right)
root.left = None
if left:
root.right = left
insert(root.right, right)
else:
root.right = right
return root


I'm not sure, but I think the temporal complexity is O (n ^ 2). How do I let it run faster? How do I change it specifically so that it runs in optimal time complexity (linear time)?

## Create a binary search tree (manually)

I've got the following values ​​to add to a binary search tree (in the given order)

56, 35, 55, 58, 29, 15, 16, 5, 71, 92, 69, 95

And so my tree ended:

but apparently it is wrong?

## Algorithms – solving repetitions (tree method) with square roots

Thank you for sending a reply to Computer Science Stack Exchange!