## algorithm – naive construction of suffix tree in Python

You can probably squeeze out a little performance boost, but not much. One thing you could do is omit configuration variables like n = len(prefix) (you don't use n on the next line).

You might also consider collections.deque instead of list where relevant, which can sometimes give you a little more speed. Or if you have the option to use list comprehension, please do so.

And doing if suffix_tree: instead of if len(suffix_tree) == 0: It is also faster ca 30 ns vs 85 ns on my machine (Python 3.8.1).

As for the complexity of time and space, you must make a judgment as to whether time or space are more important; The only other way the search could have O (1) would be with a set.

Finally, you don't need to keep track of found_match— you can use a for-else with a declaration of rupture.

P.S. You must be careful with the mutant objects you are iterating over.

## javascript: create a vscode tree element extension

I use the following code to add a tree element to the vscode extension. By getting the data and building the tree according to the inputs I got, the code works.
As I am new to typing, I appreciate your feedback

export class TaskTreeDataProvider implements vscode.TreeDataProvider {

private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter();
._onDidChangeTreeData.event;

private eeake: Promise | undefined = undefined;
private autoRefresh: boolean = true;

constructor(private context: vscode.ExtensionContext) {
this.autoRefresh = vscode.workspace
.getConfiguration(“sView")
.get("autorefresh");

let filePath = this.fileName;
let fileWatcher = vscode.workspace.createFileSystemWatcher(filePath);
fileWatcher.onDidChange(() => (this.eeake = this.getChildren()), this.refresh());
}

refresh(): void {
this._onDidChangeTreeData.fire();
}

public async getChildren(task?: TreeItem): Promise {
.then(function (value) {
return value;
});

let entry: TreeItem() = ();
for (var i = 0; i < tasks.length; i++) {
entry(i) = new TreeItem(
{
title: "Execute",
}
);
}
}
return entry;
}

}
}

class TreeItem extends vscode.TreeItem {
type: string;
constructor(
type: string,
label: string,
collapsibleState: vscode.TreeItemCollapsibleState,
command?: vscode.Command
) {
super(label, collapsibleState);
this.type = type;
this.command = command;
this.iconPath = getIcon();
}
$$```$$

## Red-black tree height test

I know that the height of a red-black tree is at most 2 lg (n + 1). However, what is the mathematical proof of this? I searched several sites, however I couldn't find a good test. I already know the properties of a red-black tree.

## c # – Do you use data structures like binary search tree, priority queue etc., commonly in daily work?

I see a lot of DS related articles and posts like BS/BST, priority queue, stack, queue etc. about their implementations and applications. I see that these applications are mainly at the system level rather than the usual day-to-day use while working as a developer. For example, I work in C#.Net platform and they mostly end up using DS as Arrays, List, Dictionary while processing data or while extracting it from apis and external databases.

I would appreciate it if someone could share the use and example of other DSs in a day-to-day thinking and working process when choosing them, such as cost optimization, performance.

## javascript – Drupal 8 Accessing the menu tree in JS of a block

How can I pass the menu to the javascript of a block?

I'm trying to build a block for a custom mobile menu (client wants specific logic / animations etc.) and I use it in Structure> Block Design> Main Navigation.

They want me to do it through jQuery for reasons, but I can't find how to access the menu tree in the block javascript. I feel like this should be simple enough with the API, but the documentation seems to be focused on PHP.

Any help is appreciated, thanks!

NOTE

I found this post, but I'm honestly not sure what it's trying to do, it's from about 4 years ago, and making / grouping libraries to access the menu seems like it's probably not the ideal way to do it. I am also using the Bootstrap theme and I don't see a template.php.
Thanks again!

## I'm trying to implement a binary search tree using c ++, but I can't seem to deliver a pointer reference (node ​​* y)

the function below always gives me error

``` bool search(node *&root,string word){
if(root==NULL){
cout <<"ERROR root is null"<word.compare(word)==0)
return true;
if (root->word.compare(word)>0){
search(root->left,word);}
else if (root->word.compare(word)<0){
search(root->right,word);}

return false;

} “ `

node*root=buildTree(filepath); I allocate memory for any new node in this function

cout< I guess I'm passing the wrong value to the function search ...

## Recursion – Recurrences and table / tree method

Use the tree and table method to calculate the $$Theta$$ time complexity for $$𝑇 (𝑁) = 4𝑇 (𝑁 – 5) + 7$$. Assume $$T (N) = 7$$ for all $$0 leq N leq 4$$. Assume $$N$$ is a multiple of $$5$$. Fill in the table below and finish the calculations outside of it.

## java – Add node to binary search tree

I am working in a binary search tree and I have written a method to insert a new node with given data. This is what I have so far:

public void insert(GenericData inData)
{
insertHelper(BST_Root, inData);
}

private BST_Node insertHelper(BST_Node localRoot, GenericData inData)
{
BST_Node returnNode = null;

//If node is empty; insert here
if (localRoot == null)
{
localRoot = new BST_Node(inData);
returnNode = localRoot;
}

//If data is smaller than node, go left
if (localRoot.nodeData.compareTo(inData) > 0)
{
insertHelper(localRoot.nodeLeft, inData);
}

//If data is bigger than node, go right
if (localRoot.nodeData.compareTo(inData) < 0)
{
insertHelper(localRoot.nodeRight, inData);
}

//Return node information
return returnNode;
}

This seems to make sense to be on paper, however I am getting the following errors in my IDE:

Breakpoint method: Generic_BST_Class (input) - insertHelper (BST_Node, GenericData)

It appears on the first line of the private class.

And this line:

insertHelper(localRoot.nodeLeft, inData);

It gives me the error:

Syntax error in token ",", delete this token

inData cannot be resolved or is not a field

I know this is a bit sloppy, but can someone explain to me what these errors are and how to fix them? The class is called Generic_BST_Class and uses BST_Node for the nodes.

## Algorithms: Calculate the number of triangles that can be formed by joining special nodes in a tree

Problem source: CHGORAM2
Problem: we are given a tree and its nodes are marked as 1 or 0. We need to calculate how many triplets (x, y, z) can be formed so that node x, y, z is marked as 1 and the distance (x , y) = distance (y, z) = distance (z, x) Here the distance (x, y) denotes the distance between the nodes x and y. Also x, y, z must be different.

I can only solve it using brute force. But Editorial mentions some O (n) solution that I did not understand.

## How to convert a decision table into a consistent decision tree?

I am working from the presentation of the school, but I cannot understand how they go from one step to another. This is the decision table I have.

From it, the first thing we have to do is choose the root node among these nodes:

But I don't understand why, for example, since Q1 branch Y has a1, a2 and branch N has a1, a3.

This then is the final solution for the tree:

I'm not sure if this is the correct name in English, maybe that's the reason I couldn't find any literature online.

I would appreciate an explanation or at least a link to a guide on how to convert decision tables into optimal decision trees that are consistent with the decision table.