construct Binary tree when pre-order and postorder to the tree is given

Just any binary tree cause a unique tree will not be possible?

Awesome q2a theme

+1 vote

1) Time complexity to construct a Binary tree when inorder and preorder/postorder traversal of the tree is given.

a) if inorder sorted

b) if inorder is not sorted.

2) If construct Binary tree when pre-order and postorder to the tree is given.

.....…

My answer:

1 a) O( nlogn)

1 b) O(nlogn)

2) O(2^n)

Please check and correct

Thanks

a) if inorder sorted

b) if inorder is not sorted.

2) If construct Binary tree when pre-order and postorder to the tree is given.

.....…

My answer:

1 a) O( nlogn)

1 b) O(nlogn)

2) O(2^n)

Please check and correct

Thanks

9,211 questions

3,186 answers

14,687 comments

96,181 users