Code submission mechanism: Include source code (single file .c/.cpp/.py) in your submission ZIP file to Blackboard. Include your PSID and Submission ID from the on-line judge system. Your code must only read from stdin and write to stdout.
We will be compiling and running your submitted code. We may use test cases that are not given to you.
Starter code: p5.cpp
Given the pre-order traversal and in-order traversal of a binary tree, output the post-order traversal of the binary tree.
Input format:
line 1: number of nodes
line 2: the pre-order traversal;
line 3: the post-order in-order traversal.
note: The tree nodes are labeled 1, 2, ..., n
Example 1
Input: 9 1 2 3 4 5 6 7 8 9 3 2 5 4 6 1 8 7 9 Output: 3 5 6 4 2 8 9 7 1 Explanation: The tree can be reconstructed from the input as:
Starter code: p6.cpp
Given a n*n grid of square; each square can be 1 (land) or 0 (water). An island is a maximally connected land square; two land square are connected if they have common edges.
Find the number of islands for the given grid of squares
Example 1
Input: 6 1 1 0 0 1 1 1 0 1 1 0 0 1 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 Output: 3 Explanation: There are three connected land areas: top left, top right, and bottom.
Example 2
Input: 10 1 1 1 0 0 0 0 0 1 1 0 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 0 1 0 1 1 0 1 0 1 1 1 0 0 0 0 0 0 0 1 0 0 1 0 1 1 1 0 0 1 0 1 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 0 1 0 0 1 1 0 0 0 0 1 0 0 Output: 7 Explanation: