• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Binary tree

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


the algorithm above should give me a binary tree. i have one question. what current.info represent? what number?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...

Is this code that you wrote yourself?
 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same value it was constructed with.
 
Marshal
Posts: 75708
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic