Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does inorder in reverse also classify as inorder?

I know inorder traversal works like this:

  1. Traverse the left subtree.
  2. Visit the root.
  3. Traverse the right subtree.

But what if we have an algorithm that does the following

  1. Traverse the right subtree.
  2. Visit the root.
  3. Traverse the left subtree.

Would such a tree traversal be consdered inorder as well?

like image 423
GTL Avatar asked Jan 28 '26 14:01

GTL


1 Answers

I was wondering the same thing for some time.

I would say, it can be called inorder traversal also. The result would be reverse sorted array instead of the sorting that would come up with left-root-right.

But the definitions are strict on saying left-root-right.

like image 123
Shamim Hafiz - MSFT Avatar answered Jan 31 '26 05:01

Shamim Hafiz - MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!