11902 - Matrix to Tree Converter (CS2351)   

Description

  • Given
    • A matrix of digits
    • A starting non-zero digit
    • A traversal method
  • Task
    • Convert the nonzero digits of the path in matrix into a tree
    • Print out the digits according to one of the following tree traversal methods
      • Level-order-traversal
      • Pre-order-traversal
      • Post-order-traversal
  • Example

Input

width < 100 and height <100 

Traversal method can be one of the following:

  • "Level-order-traversal"
  • "Pre-order-traversal"
  • "Post-order-traversal"

Output

print out the tree traversal

There is an white space between each elements.

Sample Input  Download

Sample Output  Download

Tags




Discuss