Starup Interview Question for SDE-2s
- 1of 1 vote
Given multiple tuples in the form of (A,B) where A is the parent and B is the child in a binary tree, find if the input is valid or not. 4 error conditions were provided:- Ankita October 14, 2018 in United States
1. If a parent has more than 2 children,
2. If duplicate tuples entered,
3. If the tree has a cycle,
4. If more than one root possible.
For violation of multiple validity conditions, print the condition coming first in the above order.
If the input is valid, print the tree in a serial representation. For eg: If input is (A,B), (B,C), (A,D), (C,E) , output: (A(B(C(E)))(D))
| Report Duplicate | Flag | PURGE
Starup SDE-2 Algorithm Problem Solving
Interview Type: In-Person
Open Chat in New Window