0
19kviews
Explain the various operations of the list ADT with examples
1 Answer
written 2.6 years ago by |
Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of values and a set of operations.
There are three ADTs namely List ADT, Stack ADT, and Queue ADT.
//List ADT Type Definitions
typedef struct node { void *DataPtr; struct node *link; } Node; typedef struct { int count; Node *pos; Node *head; Node *rear; int (*compare) (void *argument1, void *argument2) } LIST;
A list contains elements of the same type arranged in sequential
order and following operations can be performed on the list.
- get() – Return an element from the list at any given position.
- insert() – Insert an element at any position of the list.
- remove() – Remove the first occurrence of any element from a non-empty list.
- removeAt() – Remove the element at a specified location from a non-empty list.
- replace() – Replace an element at any position with another element.
- size() – Return the number of elements in the list.
- isEmpty() – Return true if the list is empty, otherwise return false.
- isFull() – Return true if the list is full, otherwise return false.