11901 - Matrix to Tree Converter   

Description

測資說明:
測資 1 就是 sample input/output
測資 2、5 只會要求算 level-order
測資 3、6 只會要求算 pre-order
測資 4、7 只會要求算 post-order
測資 8、9 會混合三種 traversal methods、且 matrix 最大 (100*100 內)
測資 10 測試一些比較極端的情形

  • Given
    • A matrix of digits
    • A starting non-zero digit
    • A traversal method
  • Task
    • Convert all the nonzero digits of the 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

Traversal method can be one of the following:

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

Output

Repeat the inputs and additionally print out the tree traversal

Sample Input  Download

Sample Output  Download

Tags




Discuss