You are on page 1of 15

ADT and Data structures

Definition
● In computer science, an abstract data type
(ADT) is a mathematical model for data types,
where a data type is defined by its behavior
(semantics) from the point of view of a user of
the data, specifically in terms of possible values,
possible operations on data of this type, and the
behavior of these operations.
● This contrasts with data structures, which are
concrete representations of data, and are the
point of view of an implementer, not a user.
Definition
● A data structure is a collection of data
values, the relationships among them, and
the functions or operations that can be
applied to the data
● Data structures can implement one or
more particular abstract data types (ADT),
which specify the operations that can be
performed on a data structure and the
computational complexity of those
operations.
● Formally, an ADT may be defined as a "class of
objects whose logical behavior is defined by a
set of values and a set of operations";

● Data Structure: They are used to store
data in organised form in computer.

● Data Types: They basically specify the


type of data you are storing in your
system
List
● A list or sequence is an abstract data type
that represents a countable number of
ordered values, where the same value
may occur more than once
● Ordered Collection
Principal
Charecteristics
● Items have a position
● List has a size
● Can grow and shrink
● Cannot have gaps
LIST
operations
● Void CreateList(List);
● Precondition:None
● Postcondition:The list has been created and is
initialized .
● Void ClearList(List);
● Precondition:The list has been created
● Postcondition: all entries removed.List empty
● Boolean ListEmpty(List);
● Precondition:The list has been created
● Postcondition:check if ele not present or
not. Return True /False
● Void InsertList(Position p,ListEntry x,List
list);
● Precondition:List has been created,list is
not full, x is a valid list
entry,o<=p<=n,n:no.ele in the list
● Postcondition:x has been inserted into
position p in the list;the entry formerly in
the position pand all later entries have
thier position numbers increased by 1
● Void Deletelist(Position p,ListEntry x,List
list);
● Precondition:The list has been ,list is not
empty and 0<=p<=n,where n is the
number of entries in the list
● Postcondition:The entry in position p of list
has been returned as x and deleted from
list the entries in all later positions have
thier position numbers decreased by 1
● Void RetrievalList(Position p,Listentry
x,List list);
● Precondition:The list has been created,list
not empty,and 0<=p<=n,where n is the
number of entries in list
● Postcondition:The entry in position p of list
has been returned as x, list remains
unchanged.
● Void ReplaceList(Position p,ListEntry
x,List list);
● Precondition:The list has been created,list
is not empty,x is a valid list entry and
0<=p<n,where n is the number of entries
in list
● Postcondition:The entry in position p of list
as been replaced by x. The other entries
of list remain unchanged.
The List interface of JAVA

public interface List<E> extends Collection<E> {    
  // Positional Access
    E get(int index);
    E set(int index, E element);    // Optional
    boolean add(E element);         // Optional
    void add(int index, E element); // Optional
    E remove(int index);            // Optional
    
    // Search
    int indexOf(Object o);
    // Iteration
    ListIterator<E> listIterator();
    // Range­view
    List<E> subList(int from, int to);
    int size();
}
● MyList.get(2)

You might also like