posted 1 year ago
This is the original problem:
Given a hash function h(x) = x mod 3, insert entries with keys 13, 22, 8, 16, 33, 52, 43, 28, 45, 23, 11, 15, 9, 2, 20, 30, 19, 50 to the hash table. Use binary search trees to solve hash collision, where each cell of the hash table stores the root of a binary search tree. Also draw the trees after removing keys 43, 30 and 2.
I'm unsure if I have the correct answer to this Homework problem. If I'm wrong please direct me in the right direction.
0 1 2  3  4 5 6  7 8 9 1011121314 151617
451322165243281983323112 2050 15930
Given a hash function h(x) = x mod 3, insert entries with keys 13, 22, 8, 16, 33, 52, 43, 28, 45, 23, 11, 15, 9, 2, 20, 30, 19, 50 to the hash table. Use binary search trees to solve hash collision, where each cell of the hash table stores the root of a binary search tree. Also draw the trees after removing keys 43, 30 and 2.
I'm unsure if I have the correct answer to this Homework problem. If I'm wrong please direct me in the right direction.
0 1 2  3  4 5 6  7 8 9 1011121314 151617
451322165243281983323112 2050 15930
Patty Lebowski
Greenhorn
Posts: 7
Norm Radder
Rancher
Posts: 2767
32
Patty Lebowski
Greenhorn
Posts: 7
posted 1 year ago
I ran into the same issue. I posted it here because I figured it would be the 'best' fit
Norm Radder wrote:ok, I was just confused. This section of the forum is for beginning java programmers that have problems with their code. So naturally I was looking for your code that needed help.
I don't know what section of the forum this question would fit in better.
I ran into the same issue. I posted it here because I figured it would be the 'best' fit
Norm Radder
Rancher
Posts: 2767
32
Patty Lebowski
Greenhorn
Posts: 7
posted 1 year ago
I should have pointed out I'm in a java programming class, this is the logic for an assignment to be done on paper. There is no code yet. I would like to make sure I understand how to do the logic of two data structures combined into one.
I'm very new here so I apologize for the mistakes I've made.
I just wanted to see if I could understand this better before I go to my professors office hours.
I'm very new here so I apologize for the mistakes I've made.
I just wanted to see if I could understand this better before I go to my professors office hours.
Campbell Ritchie
Marshal
Posts: 57499
175
posted 1 year ago
Start trying it out with the following has function:
h = x
Nice and simple. You now have thirty‑something numbers each with a hash. Put each into a tree and see what sort of tree you get. Show us the results. You will find it easier if you wrap the output in [code=text] ...[/code] tags. Use the /\ keys for the branches of the tree and spaces to move to the right. Use Text in the dropdown list next to the code button and write by hand on the first line only.
I'll give you a startNow use the hash function you were given and try it for these numbers: 13, 22. You will have to consider what algorithm you are going to use because 13 and 22 will return the same hash.
And, to General Computing we shall go.
h = x
Nice and simple. You now have thirty‑something numbers each with a hash. Put each into a tree and see what sort of tree you get. Show us the results. You will find it easier if you wrap the output in [code=text] ...[/code] tags. Use the /\ keys for the branches of the tree and spaces to move to the right. Use Text in the dropdown list next to the code button and write by hand on the first line only.
I'll give you a startNow use the hash function you were given and try it for these numbers: 13, 22. You will have to consider what algorithm you are going to use because 13 and 22 will return the same hash.
And, to General Computing we shall go.
posted 1 year ago
That doesn't look right to me.
Selfcheck:
1. What does a hash table look like? Does your answer look like one?
2. What does a binary search tree look like? Does your answer look like it's using binary search trees?
3. How many unique hash codes will you get if the hash function is h(x) = x mod 3? Does your answer show this many hash codes? What are those hash codes? (HINT: the given hash function produces less than 5 unique hash codes)
you should be able to tell whether or not your answer is correct based on these selfcheck questions.
Patty Lebowski wrote:
I'm unsure if I have the correct answer to this Homework problem. If I'm wrong please direct me in the right direction.
0 1 2  3  4 5 6  7 8 9 1011121314 151617
451322165243281983323112 2050 15930
That doesn't look right to me.
Selfcheck:
1. What does a hash table look like? Does your answer look like one?
2. What does a binary search tree look like? Does your answer look like it's using binary search trees?
3. How many unique hash codes will you get if the hash function is h(x) = x mod 3? Does your answer show this many hash codes? What are those hash codes? (HINT: the given hash function produces less than 5 unique hash codes)
you should be able to tell whether or not your answer is correct based on these selfcheck questions.
Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.— Junilu
[How to Ask Questions] [How to Answer Questions]
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
ScroogeXHTML 7.2  RTF to HTML5 / XHTML converter
https://coderanch.com/t/692027/ScroogeXHTMLRTFHTMLXHTMLconverter
