C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# Rotation distance between two binary trees

By : Bud S
Date : November 20 2020, 11:01 PM
it fixes the issue Rotate right with root 11 and pivot 9
Rotate left with root 7 and pivot 9
code :

Share :

## What are the differences between segment trees, interval trees, binary indexed trees and range trees?

By : Akhil Vyshakh M T
Date : March 29 2020, 07:55 AM
this one helps. All these data structures are used for solving different problems:
Segment tree stores intervals, and optimized for "which of these intervals contains a given point" queries. Interval tree stores intervals as well, but optimized for "which of these intervals overlap with a given interval" queries. It can also be used for point queries - similar to segment tree. Range tree stores points, and optimized for "which points fall within a given interval" queries. Binary indexed tree stores items-count per index, and optimized for "how many items are there between index m and n" queries.

## "Rotation of Binary Search Trees" in Scheme

By : Javidi M
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You really need to provide more information, such as what is your representation of a 'tree' and how is a tree missing its 'left' or 'right' child defined and handled.
code :
(define (make-tree value left right)
`(TREE ,value ,left ,right))

;; How is an 'empty' tree denoted?
(define empty 'EMPTY)
(define (is-empty? tree)
(eq? tree empty))

(define (make-leaf value)
(make-tree value empty empty))

;; Now you have the basis for a solution; here is a start.

(define (right-rotate tree)
(if (is-empty? tree)
empty
(let ((l (left tree)))
(if (is-empty? l)
<something>
(make-tree (value l)
(left  l)
(make-tree (value tree) (right l) (right tree)))))))

## Given a number n, how many balanced binary trees (not binary search trees) are there?

By : Raven
Date : March 29 2020, 07:55 AM
wish of those help Well the difference will be made only by the last level, hence you can just find how many nodes should be left for that one, and just consider all possible combinations. Having n nodes you know that the height should be floor(log(n)) hence the same tree at depth k = floor(log(n)) - 1 is fully balanced, hence you know that is needs (m = sum(i=0..k)2^i) nodes, hence n-m nodes are left for the last level. Some definition of a balanced binary tree force "all the nodes to be left aligned", in this case it is obvious that there can be only one possibility, without this constraint you have combinations of 2^floor(log(n)) chooses n-m, because you have to pick which of the 2^floor(log(n)) possible slots you will assign with nodes, forcing a total of n-m nodes to be assigned.
For the height story you consider a sum of combinations of 2^floor(log(n)) chooses i as i goes from 1 to 2^floor(log(n)). You consider all possibilities of having either 1 node at the last level, then 2 and so on, until you don't make it a fully balanced binary tree, hence having all 2^floor(log(n)) slots assigned.

## Java Binary Trees: Finding the node that reaches two nodes with shortest distance

By : prakashjp.me
Date : March 29 2020, 07:55 AM
like below fixes the issue Change your recursion to return when it checks the left and right children:
if (left.reachesBoth(a, b) != null) return left.reachesBoth(a, b);

## Minimum and maximum height of binary search trees, 2-3-4 trees and B trees

By : user3874833
Date : March 29 2020, 07:55 AM