I recently found out about the Rose tree data structure, but just going off of a Haskell data definition and the tiny Wikipedia description of it, I've got some trouble understanding what applications a Rose tree might have.
For reference, the…
For example, I have a program generates two ASTs, and I want to compare the two trees.
I've tried to treat the trees as graphs, but I think it doesn't show the particularity of trees.
Let $T$ be a finitely branching tree. I will call a subtree of $T$ a "tassel" if it is of width one, closed downward, and is maximal subject to this criterion. Equivalently, a tassel is a sequence of nodes $A_1,\dots, A_n$ such that $A_i$ is the…
I want to compare two trees:
I will consider the trees equal if they are:
Isomeric-i.e have the same structure.
Nodes in both trees have the same values but the order of the children nodes are not necessarily the same.
A picture is worth a thousand…
Consider this question ( 18.2-4 of CLRS) which states that:
Suppose that we insert the keys ${1,2,...,n}$ into an empty B-Tree with minimum degree 2. How many nodes does the final B-tree have?
My approach:
We add each element one by one. We'll…
I'm working on a problem and I've managed to design an efficient algorithm, but I'm stuck at the last part.
After some processing I'm left with a tree and I have to answer several queries of the form $(x,y)$, such that for each such query we have…
I've written a recursive function of a tree, and I would like to know what it's called! It's not quite the same as the height or the width of a tree, but it seems kind of like a width.
Assuming the tree $T$ is binary, we can define the…
I know an unlabeled unrooted tree normalization algorithm that uses parentheses:
label each vertex with ()
while there are more than two leaves repeat:
remove each leaf placing its label within the ( and ) of the parent so that within the ( ) of…
Let $T$ be a tree with $n$ nodes. If I remove $k$ edges from $T$, I will have $k+1$ new trees i.e. a forest of $k+1$ trees.
How do I calculate the number of nodes in each of these new trees formed?
I need to do this for $q$ queries.
My approach:
I…
Wikipedia says:
a radix tree is a data structure that represents a space-optimized trie (prefix tree) in which each node that is the only child is merged with its parent.
Now they are situations where the parent of the child represent a valid key…
I just studied about this 2-4 tree which is a self-balanced tree. Various sources and textbook often mentioned that the insertion, deleting and searching of this tree is $O(\lg n)$.
However, none of them explain the detailed reasons for that…
I'm trying to understand what a random binary tree is. According to Wikipedia:
Two different distributions are commonly used: binary trees formed by
inserting nodes one at a time according to a random permutation, and
binary trees chosen from a…
After performing operations (e.g. insertion/deletion of a node - rotations) on an AVL tree, is the result fully determined by the order of insertion on the initial tree, or do multiple solutions exists that satisfy all AVL properties?
I was wondering if there is a name for the construct described below:
Given $N$ integers $n_0, ..., n_{N-1}$ we construct a tree of height $N$ levels such that:
each node of level $0$ (i.e the root) has $n_0$ children.
each node of level $1$ has…