An array is of the same type, and a linked list is of a different type.

In an interview, when I ask recent graduate students what the difference is between an array and a linked list, the first answer is usually "You have the same data types in the array, and you can have different data types in the linked list." When I told them to explain that they would say that they had just read it or that they didnโ€™t know for sure. I really donโ€™t understand where this idea comes from in their brain. Can someone help me understand why a college graduate considers this? Or do you think this is really the difference?

+3
source share
4 answers

It is possible that these students were taught arrays with statically typed languages โ€‹โ€‹and linked lists with dynamically typed languages, so they came to identify the data structure with the paradigm of the language in which they used it.

For example, they could use arrays in C and related lists in Schema. Or no matter how fashionable names are for today's languages, which are essentially similar to C, respectively Scheme.

+3
source

, , , . , . , , ... ... .

, , :

, -

int[] myArray = new int[20];

, , ...

node

prev= object;
next = object;

, .

. , .

P.S: , ... , -:)

+1

, perl, ... perl list . , c void *, , void.

+1

, , , , . ( , , , , ). , , , , , , .

0

Source: https://habr.com/ru/post/1763217/


All Articles