Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d4be4st/voxxed_script
https://github.com/d4be4st/voxxed_script
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/d4be4st/voxxed_script
- Owner: d4be4st
- Created: 2016-09-29T07:51:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-29T07:52:48.000Z (over 8 years ago)
- Last Synced: 2024-12-28T04:02:06.283Z (24 days ago)
- Language: Ruby
- Size: 6.1 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.txt
Awesome Lists containing this project
README
Given a binary tree:
2
/ \
/ \
/ \
1 3
/ \ / \
0 7 9 1
/ / \ / \
11 13 10 8 4
/
12There are couple of algorithms for traversal. We will consider only depth-first.
By using depth-first traversal, we might opt in for pre-order or in-order. Also,
we can choose to left-to-right or right-to-left traversal.If we choose pre-order left-to-right depth-first traversal order of visited nodes is:
2 1 0 11 7 13 10 12 3 9 1 8 4If we choose in-order left-to-right depth-first traversal order of visited nodes is:
11 0 1 13 7 12 10 2 9 3 8 1 4It is possible to reconstruct same tree based on these two sequences.
In assignment, there are two input files, named `preorder.txt` and `inorder.txt`.
Your job is to reconstruct tree used to generate those values. Once tree is
reconstructed, take all leaf nodes (nodes that have no children) ordered
from left to right, concatenate them all in one string (without blank spaces)
and calculate md5 sum of that string. That is the solution.In given example, leaf nodes would be:
11 13 12 9 8 4Concatenated string would be "111312984" and md5 sum "004c0b214b7b88203f33cdf32141a969".
Submit your solution to: www.sevenbridges.com/vdb16/ch2?entry.1154285018=bqypSBGtlic