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.
b Node having header and trailer in the list
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.
sorce code for student mark list usig array
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.
yes
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;
It depends... If you want a speedy processing go for array list If you want thread safety go for a vector
An array element has the same type as the array name.
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.
Vectors are thread safe but array lists are not. Hence array lists are faster than Vectors.
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.
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.