Microsoft interview question

Related to trees and graphs.