Questions tagged [trees]

Questions about a special kind of graphs, namely connected and cycle-free ones.

See also and .

855 questions
11
votes
3 answers

What are the applications of Rose trees?

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…
Jules
  • 632
  • 6
  • 19
3
votes
0 answers

How can we describe the similarity between trees?

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.
ice1000
  • 940
  • 6
  • 35
3
votes
0 answers

Big O of a parallel tree algorithm

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…
3
votes
1 answer

Numbering of unlabelled trees

For labelled trees there are the Pruefer numbers that uniquely identify them. Is there a similar numbering system for unlabelled trees?
Mok-Kong Shen
  • 515
  • 4
  • 11
3
votes
1 answer

Comparing two rooted n-ary trees irrespective of the order of children nodes?

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…
2
votes
1 answer

Insertion of n consecutive keys in an initially empty B-Tree

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…
Mooncrater
  • 169
  • 11
2
votes
0 answers

Minimum cost edge in path between nodes (tree)

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…
user43389
  • 260
  • 1
  • 2
  • 13
2
votes
1 answer

What is the name of this function of a tree?

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…
guest
  • 41
  • 3
2
votes
0 answers

Canonical forms for unlabeled unrooted trees

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…
Vor
  • 12,513
  • 1
  • 30
  • 60
2
votes
1 answer

How to find size of each tree in a forest?

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…
Resorcinol
  • 121
  • 2
1
vote
1 answer

Can a node of Radix tree which represents a valid key have one child?

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…
Syed
  • 113
  • 4
1
vote
1 answer

Show that run time complexity of operations on 2-4 tree is $O(\lg n)$

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…
Bryan
  • 113
  • 1
  • 5
1
vote
1 answer

Example of Random Binary Tree?

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…
1
vote
1 answer

Are results after performing operations on AVL trees ambiguous?

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?
T. Johnson
  • 11
  • 2
1
vote
0 answers

name perfect generalized sum tree with variable number children for each level

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…
burnedWood
  • 21
  • 2
1
2 3