...

/

Solution: Random Binary Search Tree

Solution: Random Binary Search Tree

See the solution that implements a treap from a sorted array.

We'll cover the following...

Task

Here is the task that implements an algorithm that constructs a Treap from a sorted array, a, of n elements. This method runs in O(n)O(n) worst-case time and should construct a Treap that is indistinguishable from one in which the elements of a were added one at a time using the add(x) method.

Solution

The code widget shows the implementation ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy