Results 1 to 7 of 7

Thread: can someone please explain to me the point of a binary tree/hashing?

  1. #1

    Joined
    Mar 2014
    Posts
    25
    Userbars
    0
    Thanks
    9
    Thanked
    6/5
    Mentioned
    Never
    Time Online
    2d 18h 28m
    Avg. Time Online
    1m

    Question can someone please explain to me the point of a binary tree/hashing?

    not sure if this is the right place to ask or if i should be in homework help, but i am working on some homework and apparently our teacher thought it was beneficial to skip the original chapter on binary trees, so reading about AVL trees and hashing, i am extremely confused. what's the point of them? what would they be used for? (if it matters, this is in java)

  2. #2
    Saiyan Race
    j03's Avatar
    Joined
    Dec 2011
    Posts
    13,720
    Userbars
    166
    Thanks
    5,906
    Thanked
    33,077/6,608
    DL/UL
    23/36
    Mentioned
    3,867 times
    Time Online
    563d 4h 55m
    Avg. Time Online
    3h 13m

    can someone please explain to me the point of a binary tree/hashing?

    Quote Originally Posted by obstaclez View Post
    not sure if this is the right place to ask or if i should be in homework help, but i am working on some homework and apparently our teacher thought it was beneficial to skip the original chapter on binary trees, so reading about AVL trees and hashing, i am extremely confused. what's the point of them? what would they be used for? (if it matters, this is in java)
    A Binary Tree is similar to an array, list, but it's more of a hierarchical data structure... So instead of a list which is made up like this:

    Code:
    Item 1
    Item 2
    Item 3
    Etc.
    The Binary Tree will look like this:

    Code:
    Item
    |....item 1
    .    |....item 1.1
    |....item 2
    .    |....item 2.1
    |....item 3
    .    |....item 3.1
    Edit: Damn it, the formatting messed up when I hit submit. It's supposed to show the ".1" items branching out from "1", "2", "3". And those ones branching out from "item", like a tree. And the last elements are called leaves.

    I got lazy doing this on my phone, could have added more elements but you get the idea... It's basically a tree. Sometimes it'll be needed for you to break down your data into categories like this instead of having one list. I think if you google or YouTube, you'll get a better explanation. Typically this makes data easier to search and manipulate.

    Hashing is also pretty simple to understand. It's similar to the list above, except what if this list was massive and you didn't know all of the item names? You could use an ID, call the ID an index number, or key, which will point to the item name in the list. Google this too as it doesn't take a lot of reading.


    Sent from my iPhone using Tapatalk
    Last edited by j03; 07-29-2018 at 07:29 PM.
    (you need an account to see links)
    (you need an account to see links)(you need an account to see links)

    ------------------------
    [02/24/2013] Stealth CORE is made into the first standalone Neopets auto-player.
    ------------------------


  3. The Following 6 Users Say Thank You to j03 For This Useful Post:

    bluelatios (09-04-2018),I_royalty_I (07-27-2018),Loval (11-23-2018),obstaclez (07-27-2018),omg.UFOs (09-03-2018),♥ PrettySarcastic ♥ (08-02-2018)

  4. #3

    Joined
    Mar 2014
    Posts
    25
    Userbars
    0
    Thanks
    9
    Thanked
    6/5
    Mentioned
    Never
    Time Online
    2d 18h 28m
    Avg. Time Online
    1m
    i'm really just not understanding how to do this assignment. is there someone i can pm about it?

  5. #4
    Saiyan Race
    j03's Avatar
    Joined
    Dec 2011
    Posts
    13,720
    Userbars
    166
    Thanks
    5,906
    Thanked
    33,077/6,608
    DL/UL
    23/36
    Mentioned
    3,867 times
    Time Online
    563d 4h 55m
    Avg. Time Online
    3h 13m
    Quote Originally Posted by obstaclez View Post
    i'm really just not understanding how to do this assignment. is there someone i can pm about it?
    Edited my post so it should look like how I was trying to explain it. You can share the questions in a spoiler tag like [ spoiler] question here [ /spoiler] (but no space after '[')so it's not picked up by Google or any other search engines... if not, you could PM me and I'll try to help.
    (you need an account to see links)
    (you need an account to see links)(you need an account to see links)

    ------------------------
    [02/24/2013] Stealth CORE is made into the first standalone Neopets auto-player.
    ------------------------


  6. #5
    omg.UFOs's Avatar
    Joined
    Jun 2018
    Posts
    457
    Pronouns
    --------------------
    Userbars
    30
    Thanks
    776
    Thanked
    876/287
    DL/UL
    48/0
    Mentioned
    54 times
    Time Online
    25d 22h 12m
    Avg. Time Online
    17m
    Quote Originally Posted by Infamous Joe View Post
    A Binary Tree is similar to an array, list, but it's more of a hierarchical data structure... So instead of a list which is made up like this:

    Code:
    Item 1
    Item 2
    Item 3
    Etc.
    The Binary Tree will look like this:

    Code:
    Item
    |....item 1
    .    |....item 1.1
    |....item 2
    .    |....item 2.1
    |....item 3
    .    |....item 3.1
    Edit: Damn it, the formatting messed up when I hit submit. It's supposed to show the ".1" items branching out from "1", "2", "3". And those ones branching out from "item", like a tree. And the last elements are called leaves.

    I got lazy doing this on my phone, could have added more elements but you get the idea... It's basically a tree. Sometimes it'll be needed for you to break down your data into categories like this instead of having one list. I think if you google or YouTube, you'll get a better explanation. Typically this makes data easier to search and manipulate.

    Hashing is also pretty simple to understand. It's similar to the list above, except what if this list was massive and you didn't know all of the item names? You could use an ID, call the ID an index number, or key, which will point to the item name in the list. Google this too as it doesn't take a lot of reading.


    Sent from my iPhone using Tapatalk
    you see the world in ones and zeros, dont you joe.

  7. The Following User Says Thank You to omg.UFOs For This Useful Post:

    bluelatios (09-04-2018)

  8. #6
    Saiyan Race
    j03's Avatar
    Joined
    Dec 2011
    Posts
    13,720
    Userbars
    166
    Thanks
    5,906
    Thanked
    33,077/6,608
    DL/UL
    23/36
    Mentioned
    3,867 times
    Time Online
    563d 4h 55m
    Avg. Time Online
    3h 13m
    Quote Originally Posted by Necrophilia.FUN View Post
    you see the world in ones and zeros, dont you joe.
    I mean, you could. I try and think of everything differently if I'm looking for a solution or for something to make more sense.
    (you need an account to see links)
    (you need an account to see links)(you need an account to see links)

    ------------------------
    [02/24/2013] Stealth CORE is made into the first standalone Neopets auto-player.
    ------------------------


  9. The Following User Says Thank You to j03 For This Useful Post:

    Midas (09-10-2018)

  10. #7

    Tyler Durden's Avatar
    Joined
    Nov 2018
    Posts
    75
    Userbars
    2
    Thanks
    83
    Thanked
    29/18
    DL/UL
    29/0
    Mentioned
    3 times
    Time Online
    7d 22h 28m
    Avg. Time Online
    5m
    Quote Originally Posted by obstaclez View Post
    not sure if this is the right place to ask or if i should be in homework help, but i am working on some homework and apparently our teacher thought it was beneficial to skip the original chapter on binary trees, so reading about AVL trees and hashing, i am extremely confused. what's the point of them? what would they be used for? (if it matters, this is in java)
    I'll just add to what @(you need an account to see links) pointed out.
    A binary tree is a hierarchical data structure where in you have a root node followed by its children followed by children of its children. The word binary is because at each node you can have a max of 2 children (binary) if you want 3 it's ternary and so on.
    The advantage is in a height balanced binary tree ( AVL tree or Red Black tree) the left child is always less than the parent, where as right child is always greater than or equal to the parent.
    Now imagine you want to find an element, in a regular array search you need to check every element, whereas Ina a binary tree you've gotta just check left or right node, so your max search would be log(n)base2. OK big deal, but I can do binary search on an array and still get it in same time complexity, so why trees? The answer is if you gotta insert an element into the array you've gotta shift the array upto n elements, whereas in a binary tree simply add it as a child to a node in log(n) base2 time, same for removal
    The real advantage comes in large data sets, imagine you need to search a user in a database consisting of 1 million records, conventionally you will have to iterate through each element to get the result, that means parse through 1 million users, whereas in a binary tree you need to just check log of 1 million = 20 users approx.
    Hashing to put simply, take a value and generate a value of constant bits based on it. You can use any of the plenty algorithms present.
    If you need any help feel free to ask, competitive programming is one of my hobbies
    Here's a link I suggest.
    (you need an account to see links)

    Ps. Wrote on my tab so bare with typos :p
    Last edited by Tyler Durden; 12-18-2018 at 04:10 PM.

  11. The Following User Says Thank You to Tyler Durden For This Useful Post:

    obstaclez (12-18-2018)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •