Skip to content

Latest commit

 

History

History
43 lines (26 loc) · 1.08 KB

README.md

File metadata and controls

43 lines (26 loc) · 1.08 KB

List

List in data structure is an ordered data structure that stores elements sequentially and can be accessed by index. It is a linear data structure.

Static List

Static list is a list that has a fixed length. It is implemented by array.

Pros:

  • Access by index is fast.
  • It is easy to implement.

Cons:

  • It is not easy to insert or delete an element.
  • It is not easy to expand the length of the list.

Dynamic List

Dynamic list is a list that has a variable length. It is implemented by array and linked list.

Pros:

  • It is easy to insert or delete an element.
  • It is easy to expand the length of the list.

Cons:

  • Access by index is slow.
  • It is not easy to implement.

Linked List

Linked list is a list that stores elements in a node. Each node contains the element and a pointer to the next node. The first node is called the head node, and the last node is called the tail node. The tail node points to null.

+--------+    +--------+    +--------+
|  data  |    |  data  |    |  data  |
|  next  |    |  next  |    |  next  |
+--------+    +--------+    +--------+