Skip to content

Commit

Permalink
fix the wording
Browse files Browse the repository at this point in the history
  • Loading branch information
vladak committed Apr 29, 2024
1 parent d4b8234 commit e37a981
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/bintree.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ Write a program that creates a binary tree with N + 1 nodes, where N
is specified as a command line argument.

Each node, besides the root (that is always created), will contain an
integer and will be created like this: take a binary representation of the
integer member and will be created like this: take a binary representation of the
number in the sequence {0, 1, ..., N - 1} and traverse the pre-existing tree
using this representation until a `NULL` node pointer is found. 0 means the
left child, 1 means the right one.

Only the leaf nodes actually contain the number.

For example, for 5 (101 in binary), the tree will be created as follows:

1. create root node
Expand All @@ -20,5 +22,5 @@ Once the tree is populated, traverse the tree (choose your method), count the
nodes and print the number to the standard output.

Variant: add a function pointer to each node that will be called on its visit.
The number stored in the node will be the sole argument of this function.i Use
The number stored in the node will be the sole argument of this function. Use
that to traverse the tree and free the memory in the process.

0 comments on commit e37a981

Please sign in to comment.