Hi :)

I have a question, if you don't mind =]
(What is the situation where quadratic probing is better than chaining?)

I guess (as I'm thinking)

while searching? maybe? because if the Hashtable have a lot of elements in chaining it'll take a lot of time searching the Hashtable and it might some places in the HashTable that they don't have keys (values)..
<< Is what I'm saying right for the question? or, do you have other solution?
thanks :)

+++++++
Last question it is in the HW:
Write a member function to reverse a singly linked list using only one pass through the list??

<< my answer for this question that It'll be like the code below

node *ptr1 = head;

bool reverse( int x )
{
if( !head ) // to check if the linked list is empty
return false;

return reverse( ptr1 -> data ); // recursive
}

Is all my answers are right?

Thanks in advance my friends :)

>What is the situation where quadratic probing is better than chaining?
Chaining takes up more memory, so if storage is tight, one of the open addressing schemes would be better suited. The time it takes to chase pointers in a chained solution might also be prohibitive, in which case an open addressing scheme could be more efficient.

>if the Hashtable have a lot of elements in chaining it'll take a lot of time searching
If the hash table is well designed, the table itself will have enough buckets to keep the chains short, and the hash function will distribute values roughly equally, so this situation would only occur in degenerate cases. It's a good thing to keep in mind, but quadratic probing has degenerate cases as well (more of them), so I wouldn't accept this as an answer to the question.

>my answer for this question that It'll be like the code below
Sneaky, but that technically makes two passes through the list: one going forward and one going backward as you ride the recursion wave. To be strictly correct, you'd need an iterative solution that builds a new list from the existing nodes:

node *result = 0;

while ( head != 0 ) {
  node *save = head->next;

  head->next = result;
  result = head;

  head = save;
}

head = result;

Thanks a lot.. so my 1st answer it might be correct, right?

becasue I've heard the Doctor saying that lol xDD


thanks again for the help :)

and thanks for explaining why I can't use the code I provided :)

>so my 1st answer it might be correct, right?
I'm having trouble understanding how you could come to that conclusion when I quite clearly said:

so I wouldn't accept this as an answer to the question.

>so my 1st answer it might be correct, right?
I'm having trouble understanding how you could come to that conclusion when I quite clearly said:

Well, I thought it might be correct as the doctor said!,, it doesn't matter lol thanks anyway :D

This question has already been answered. Start a new discussion instead.