Tree: Preorder Traversal

  • + 0 comments

    I find this question is confusing. Would anyone help please?

    Instruction: Complete the preOrder function in the editor below, which has 1 parameter: a pointer to the root of a binary tree. It must print the values in the tree's preorder traversal as a single line of space-separated values.

    In the sample test cases, there are two input: the root and the input elements. This is the first thing making me confused.

    The 2nd thing is that, in the expected output of both samples, the root node is not the first element to be printed. I checked multiple website, Root Node value should be printed first in PreOrder traversal. Is that the question and answer having some problems?

    I am new to Binary Search Tree, hope someone can help me. Thanks