Facebook | Phone screen

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-06-22Added By Anonymous
Source: Link
The following content details a phone screen interview experience at Facebook:

Question 1

// Array of tree nodes
// Determine if the array is a binary tree

A
/ \
B C
/ \ \
D E F

TreeNode f = new TreeNode (null, null);
TreeNode d= new TreeNode (null, null);
TreeNode e = new TreeNode (null, null);
TreeNode b = new TreeNode (d, e);
TreeNode c = new TreeNode (null, f);
TreeNode a = new TreeNode (b, c);

new Array[b, d, f, a, c, e]

class TreeNode {
TreeNode* left;
TreeNode* right;
int value;
}

Question 2

Serialize and Deserialize binary tree into string.


Comments