• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Binary tree

 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


the algorithm above should give me a binary tree. i have one question. what current.info represent? what number?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...

Is this code that you wrote yourself?
 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:...

Is this code that you wrote yourself?


NO, NEWTON, it is my teachers code. i understand that. but i dont understand the line which i marked
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please KeepItDown.

So, follow the code: I'm still not convinced you ever work out anything on paper--this is a *critically* important skill.

1) What does BTree.add(int) do?
2) What does the Node constructor do?
3) Question answered, correct?

That's all it takes: you only had to look at a few lines of code to determine the answer.
 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Please KeepItDown.

So, follow the code: I'm still not convinced you ever work out anything on paper--this is a *critically* important skill.

1) What does BTree.add(int) do?
2) What does the Node constructor do?
3) Question answered, correct?

That's all it takes: you only had to look at a few lines of code to determine the answer.


Newton , i scanned the whole thing. i know where the info comes from

but what value does the current.info has got?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same value it was constructed with.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49379
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote: . . . I'm still not convinced you ever work out anything on paper--this is a *critically* important skill. . . .
Agree with David N.

You need to imagine you have added 2 3 1 in that order to a tree, and draw a diagram of that tree after adding each of those values.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic