Now we will see what kind of operations a programmer performs with a list data structure. Following long list of operations may help you understand the things in a comprehensive manner.

 

Operation Name

Description

createList()

Create a new list (presumably empty)

copy()

Set one list to be a copy of another

clear();

Clear a list (remove all elements)

insert(X, ?)

Insert element X at a particular position in the list

remove(?)

Remove element at some position in the list

get(?)

Get element at a given position

update(X, ?)

Replace the element at a given position with X

find(X)

Determine if the element X is in the list

length()

Returns the length of the list.

 

createList() is a function which  creates a new list. For example to create an array, we use int x[6] or int* y = new int[20]; we need similar functionality in lists too. The copy() function will create a copy of a list. The function clear() will remove all the elements from a list. We want to insert a new element in the list, we also have to tell where to put it in the list. For this purpose insert(X, position) function is used. Similarly the function remove(position) will remove the element at position. To get an element from the list get(position) function is used which will return the element at position. To replace an element in the list at some position the function update(X, position) is used. The function find(X) will search X in the list. The function length() tells us about the number of elements in the list.

 

 

BACK

HOME

NEXT