Quantcast
Channel: Question and Answer » trees
Browsing all 36 articles
Browse latest View live

Algorithm to go from infix notation to a tree

I’ve been trying to figure out an algorithm to go from an infix equation to a syntax tree, like so: (1+3)*4+5 + * 5 + 4 1 3 However, I don’t just want it to handle operators, I want it to handle...

View Article


Image may be NSFW.
Clik here to view.

MInimum tree coverage

I would like to understand what would be the optimal method of finding minimum tree coverage of tree nodes. Let me explain. I have a self-referencing structure that represents a tree, with a limited...

View Article


How can I roll-back the execution of a constructor while building a complex...

I’m building a complex tree of objects. There are a total of five types, A, B, C, D, and E. There is a single instance of A, which is the root node. A has one or more Bs as children, each B has one or...

View Article

Can a tree be used to create a stack?

I’m aware that linked lists, sets and arrays can be used to create stacks by themselves. The theory behind it is this linked-list: In some languages, a linked-list is substitutable for an array. Stacks...

View Article

How to find the closest right neighbour in a tree?

Given a class: public class Node { public List nodes[]; public Node right; //NULL for now } What’s the best way to fill the “right” element of all tree nodes? N | | / | / | C1--->C2-->C3 / /...

View Article


Retrieving an incorrectly stored tree data structure

Way back in the hazy origins of our platform it was decided that we were going to need some hierarchical data structures stored in the RDBMS. The relationships between nodes were stored via a...

View Article

Image may be NSFW.
Clik here to view.

Abstract Syntax Tree with parent or not? [closed]

My question is as simple as the title says — should I implement AST with parent or not? Currently I implemented it with parent — the benefit of that approach is, that whatever I use, I can go up or...

View Article

Sum of squares of distances on a weighted graph O(n)

Given a weighted tree with n nodes. We have to find for each node sum of squares of distances towards every other node. Complexity should be O(n). I am looking for an algorithm to solve the problem. No...

View Article


Minimal spanning trees in multigraphs with constraints

I have a multigraph G whose edges have three identities. Let’s say I have three colors of the edges red, blue and green and each two nodes may be connected by a red, blue and/or green edges. The graph...

View Article


BST to AVL in O(n)

I found in different places on the internet how to turn a Binary Search Tree into an AVL tree in O(nlog(n)). I was wondering how can this be done in O(n) (as the worst case limit). It kinda seems...

View Article

Image may be NSFW.
Clik here to view.

How do I typeset this parsing tree for propositional logic formula with...

The following parsing tree is from Mathematical Logic published in 2007 and written by Ian Chiswell & Wilfrid Hodges. It looks like a forest tree, but I guess it could be typeset better by another...

View Article

Suggestions for structuring complex json structures?

I can’t find many tips for how to design complex json structures beyond the obvious tips of not trying to nest too deeply, using defined data types, etc. For example, if I have a location that needs to...

View Article

Is this Red-Black tree insertion pseudocode from Introduction to Algorithms...

For the Red-black tree insertion fixup the book distinguishes between 6 cases, 3 of which are symmetric. The cases are (z is the node being inserted): Case 1: z’s uncle is red Case 2: z’s uncle is...

View Article


Image may be NSFW.
Clik here to view.

Fundamental group of the sphere via triangulation

I know that the fundamental group of the sphere is zero, i.e. $pi(S^2)=0$ I want to show this by triangulation, i.e: Triangulate the sphere Draw maximal tree Draw maximal contractable subspace Consider...

View Article

Weedy uneven lawn with tree stumps: grind, chip, till, roll and reseed?

My sister just bought a place and she’s asking for help getting her lawn back in order. I’m not sure the way we’ve come up with is the best way. Here’s my plan of attack. I would appreciate a sanity...

View Article


Image may be NSFW.
Clik here to view.

Prooftrees logic tree preamble for an example

The following example is out of the documentation of prooftrees (I suppose that an updated version of TeX Live is needed to make use of that package). The problem is that the documentation’s .tex file...

View Article
Browsing all 36 articles
Browse latest View live