M
M
Max2020-03-17 22:53:22
Data Structures
Max, 2020-03-17 22:53:22

What is the difference between a linked list and a hash table?

What is the difference between a linked list and a hash table, and is there one at all? Or is it the same thing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mercury13, 2020-03-18
@max10110

A linked list solves the following problem: how to store a collection of objects by adding and removing objects there. (Forgive me if I don't write the characteristics of both, read it in smart books)
In its pure form, the linked list is extremely rarely used due to restrictions, but imagine an object pool (a bunch of ready-to-use objects), and you need to store a free list - very convenient to use bound. Also associated sometimes store the contents of the socket in a hash table.
The hash table solves another problem: to set up a key → value mapping. For example, “donkey → ea, rooster → crow”, and so on. An array, only the index will not be a number, but something else: x["donkey"] = "ia". The so-called associative array.
If the array index can only be a digit, let's do this: turn our donkey into a digit - for example, o+c+e+l = 4363 (in Unicode), and let 63 be the number of the nest. In the 63rd element of the array, let our “donkey → ia” lie.
If another animal has a hash value of 63, this is a hash collision, and it is solved differently in different implementations. I know this: the nest contains not just one element, but a linked list. The main thing is that this slightly reduces performance, but it is acceptable.

R
Roman Kitaev, 2020-03-17
@deliro

What is the difference between pasta and sausage in dough and is there any at all? Or is it the same thing?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question