Question: Java code as well as the runtime and space requirements using Big O Given a binary tree node that looks like this: public class Node

Java code as well as the runtime and space requirements using Big O

Given a binary tree node that looks like this:

public class Node {

public int value;

public Node left;

public Node right;

}

/* This function should insert the provided value into the binary tree provided. */

static void insertValue(Node root, int value) { }

/* This function should return a sorted array containing the values present in the binary tree provided. This algorithm should run in linear time. */

static int[] asSortedArray(Node root) { }

/* +++Return the smallest value that exists in both arrays. Brute force. */

static int minShared(int[] array1, int[] array2) { }

/* Return the smallest value that exists in both arrays. Optimize for speed. Must be better than n^2 or m^2 where n and m are the lengths of the arrays. */

static int minShared(int[] array1, int[] array2) { }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!