We need to know what is meant by “particular position” we have used “?” for this in the above table. There are two possibilities:

 

  • Use the actual index of element: i.e. insert it after element 3, get element number 6. This approach is used with arrays
  • Use a “current” marker or pointer to refer to a particular position in the list.

 

The first option is used in the data structures like arrays. When we have to manipulate the arrays, we use index like x[3], x[6]. In the second option we do not use first, second etc for position but say wherever is the current pointer. Just think of a pointer in the list that we can move forward or backward. When we say get, insert or update while using the current pointer, it means that wherever is the current pointer, get data from that position, insert data after that position or update the data at that position. In this case, we need not to use numbers. But it is our responsibility that current pointer is used in a proper way.

 

If we use the “current” marker, the following four methods would be useful:

 

Functions

Description

start()

 Moves the “current” pointer to the very first element

tail()

 Moves the “current” pointer to the very last element

next()

 Move the current position forward one element

back()

 Move the current position backward one element

 

In the next lecture, we will discuss the implementation of the list data structure and write the functions discussed today, in C++ language.

 

 

BACK

HOME