How to represent the tree here in the form of an Array?

If it was a complete binary tree then you could represent in array. You can use matrix or 2D vector for representation

Okay@sebastian what is time complexity of a skewed binary tree?

If tree of limited height and is binary tree, it can represented in array like in segment tree or heaps.

Arr[i] = value

Left child of `left = 2*i+1`

and right child as `right = 2*i+2 `

So `arr = [-1,9,8,11,-1,23,12,34,-1,10]`

I think this is a valid answer. Sorry if I missed something.

https://codeforces.com/blog/entry/43230

Are you talking about modified dfs order traversal? It’s somewhere in this blog.

Thanks, @ay2306, @everule1, and @sebastian for your efforts and kind help.

I like this community for its helping nature.

Please keep doing the good work and thanks a lot for clearing my doubts.

Regards,

Pen

I guess it should be O(n)

**You can apply tree flattening algorithm.**