Northrop Grumman Interview Question

What's the difference between and linked list and an array?

Interview Answer

Anonymous

Mar 14, 2017

Linked List are efficient for insertion in middle of a list while array is efficient for insertion at the end of the list. Array is initialized as a continuous chunk of memory and thus can be iterated by increasing the pointer (address of an element of an array) while Linked Lists are have memory allotted for each element separately. int a[]= {1,2,3,4,5,6}; int* p= a; //pointing to first element i.e 1 p++; //now p is pointing to the next element i.e 2 In linked List you cant do this what i did above with an array.