Skip to content

Tree map#8

Open
artemiipatov wants to merge 5 commits intomainfrom
tree-map
Open

Tree map#8
artemiipatov wants to merge 5 commits intomainfrom
tree-map

Conversation

@artemiipatov
Copy link
Owner

Proposed Changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.

Types of changes

What types of changes does your code introduce to Homeworks-sem4?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • Build and tests pass locally
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Comment on lines +18 to +31
let treeToArray length tree =
let result = Array.zeroCreate length

let rec treeToArrayRec curTree index =
match curTree with
| Empty -> ()
| Node(value, left, right) ->
result[index] <- value
treeToArrayRec left (index * 2 + 1)
treeToArrayRec right (index * 2 + 2)

treeToArrayRec tree 0
result

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сильно проще было бы сравнивать саму рекурсивную структуру деревьев, чем массивы. Тем более что так потребуется ещё и гарантировать валидность функции преобразования дерева в массив.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants