Implementation of "Linked Lists" using Arrays
To insert element at
1) 1st postition
2) last position
3) user defined position
To delete element at
1) 1st postition
2) last position
3) user defined position
Arrays.
Well what we know about them is that
- it is a fundamental construct.
- stores a sequence of values that are all of the same type. We want not just to store values but also to be able to quickly access each individual value.
- Now if we want to access the individual elements we can do so specifying the index value of that particular element.
- Zero-based indexing. We always refer to the first element of an array a[] as a[0], the second as a[1], and so forth.
- Array length. Once we create an array, its size is fixed. You can refer to the length of an a[] in your program with the code a.length.
And when we do something like this
The array created is nothing but a dense list. i.e we cannot modify the size of the array after compilation. Which has its own advantages and disadvantages.
So we will be implementing A linked List using arrays for a change. Shall we?
Now we the correct way of implementing "Linked Lists" is by using pointers. You might wanna take a look a this. A simple C++ implementation of Linked Lists
Delete an Element from Array in C++
ReplyDeleteOh nice post