Array Vs Linked-List

Linear Data Structure is the most commonly used structure found in Computer Science. Implementation of the linear structure in a computer’s memory is easy as the data is organized sequentially. The data elements stored in the linear data structure have single relationship between them. Array as well as Linked-List are the bane of linear data structure. In this article, we will distinguish between the both and set out to see the benefit of both world.

Array:

Array is a container which can hold a fix number of items of same data type. It is created by assigning pointer to a contiguous block of memory. The memory is divided into fixed length buckets depending on the data type used. The pointer is used to access the data present at each bucket.

data


address

0

100

1

200

2

300

3

400

4

500

5

600

6

700

7

800

8

900

9

1000

Most programming languages follow the standard of 0-based indexing, where the first element is present at the 0th index. Most advantageous point of array is that it's data can be accessed in constant time which makes operation like searching very optimal (given the address).

Linked-List:

A linked list is a linear data structure that stores a collection of data elements dynamically. Nodes represent those data elements, and links or pointers connect each node. Each node consists of two fields, the information stored in a linked list and a pointer that stores the address of its next node. The last node contains null in its second field because it will point to no node. A linked list can grow and shrink its size, as per the requirement. It does not waste memory space.

1

arrow-sign

2

arrow-sign

3

arrow-sign

4

arrow-sign

5

arrow-sign

6

arrow-sign

7

arrow-sign

8

arrow-sign

9

arrow-sign

10

arrow-sign

Linked lists can be of multiple types: singly, doubly, and circular linked list. The power of a linked list comes from the ability to break the chain and rejoin it. Doing something similar in an array would have required shifting the positions of all the subsequent elements. Apart from that, linked lists are a great way to learn how pointers work. By practicing how to manipulate linked lists, you can prepare yourself to learn more advanced data structures like graphs and trees.

Sakil Co. Limited
Created by: Sk Sakil Mostak
Registration No.: 12018257