answersLogoWhite

0

Differencs link list and array

Updated: 10/3/2023
User Avatar

Wiki User

7y ago

Best Answer

An array is a contiguous section of computer memory that contains elements of equal size. A linked list are non-contiguous sections of memory that contain data that is dynamically allocated and released as necessary.

Arrays are fixed in size. Changing the size requires significant processing power. They are quick to retrieve an element by index in the array. Finding elements in the array requires less code, and so is also faster. They also use less memory, since only one memory "pointer" is needed to locate the entire array. Arrays are best used when there are many elements and the overall size of the array will not change often.

Linked lists are variable in size. Changing the size requires virtually no processing power relative to arrays. Finding an element by index requires significant processing power. They use more memory, as each element requires at least one additional "pointer" to locate another node (some use two). Linked lists are best used when there are a limited number of elements that will be fairly often added and removed in a way that would incur the array's high cost of resizing itself frequently.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Differencs link list and array
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which one is the two way linked list a Circular link list b Node having header and trailer in the list C Array?

b Node having header and trailer in the list


What is array literal in as2?

An array literal is a comma-separated list of the elements of an array. An array literal can be used for initializing the elements of an array.


Create a mark list using array with structure?

sorce code for student mark list usig array


How would you use the word array in a sentence?

An array is a list of data items or variables of the same type, like a list of numbers or a list of dates or a list of names.


Can linked list represent in array if yes show how insertion and deletions can perform in array representation of inked list?

yes


Can Array-based lists can never be empty?

It's either an array or it's a list, it cannot be both. However, an empty array is entirely possible: std::vector<int> my_vector; // an empty array my_vector.push_back(42); // an array of 1 element my_vector.push_back(1); // an array of 2 elements my_vector.clear(); // an empty array An empty list is also possible: std::list<int> my_list; // an empty list my_list.push_back(42); // a list of 1 element my_list.push_back(1); // a list of 2 elements my_list.clear(); // an empty list The same thing can be done in C: int* my_array = nullptr; // an empty array my_array = malloc (2*sizeof(int)); // an array of 2 elements my_array[0] = 42; my_array[1] = 1; free my_array; // an empty array my_array = 0;


Which is better vector or array list?

It depends... If you want a speedy processing go for array list If you want thread safety go for a vector


An array is a list of data items that all have the same type and the same name?

An array element has the same type as the array name.


What is an ordered list of data structure using c plus plus?

An ordered list of data in any programming language is simply a sorted array or list. In C++ this can either mean a sorted array, vector, list or forward list.


Difference between vector and array list?

Vectors are thread safe but array lists are not. Hence array lists are faster than Vectors.


How do you use push operation in stack give the exampale of the program?

A stack can be implemented as an array or a list. If an array, simply push the new element onto the end of the array. If a list, point the new node at the head node then make the new node the new head of the list.


Can a linked list implemented using an array be accessed by giving the location?

A linked list implemented with an array defeats the purpose of using a linked list, which is to address the memory allocation problems associated with arrays.