Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Abstract Data Types (ADTs) – List ADT – array-based implementation – linked list
implementation ––singly linked lists- circularly linked lists- doubly-linked lists –
applications of lists –Polynomial Manipulation – All operations (Insertion, Deletion,
Merge, Traversal).
Data Structure
A data structure is a particular way of organizing and storing data in a computer so that it
can be accessed and modified efficiently.
Types of Data structure:
1. Linear Data structure
Elements are organized in sequential order. Ex.: Array, List, Stack, Queue.
2. Non-Linear Data Structure
Elements are organized in random order. Ex.: Tree, Graph.
2. List ADT
Let us consider a general list of the form A1, A2, A3,…..An. The size of this list is N.
The special list of size 0 is called as an empty list.
For any list except the empty list, we say that Ai+1 follows Ai(i<N) and that Ai-1 precedes Ai
(i>1). The first element of the list is A1, and the last element is An. The position of element
Ai in a list is i.
Associated with these “definitions” is a set of operations that would be performed on the
list ADT. Some operations are PrintList and MakeEmpty, which do the obvious things;
Find, which returns the position of the first occurrence of a key.
Insert and Delete, which generally insert and delete some key from some position in the
list; and FindKth, which returns the element in some position (specified as an argument).
If the list is 34, 12, 52, 16, 12, then Find(52) might return 3; Insert(X, 3) might make the
list into 34, 12, 52, X, 16, 12; and Delete(52) might turn that list into 34, 12, X, 16, 12.
Drawbacks:
Because the running time for insertions and deletions is so slow and the list size must be
known in advance, simple arrays are generally not used to implement lists.
Figure 1.2 shows the actual representation of the list in Figure 1.1.
Each structure contains the element and a pointer to a structure containing its successor.
This is called as next pointer. The last cell's next pointer points to NULL. Figure 1.1 shows
a singly linked list in which we can traverse only in a single direction (forward
direction).
The delete command can be executed in one pointer change. Figure 1.3 shows the result of
deleting the third element in the original list.