{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Lect3-New- - Data Structures ADT List 1 ADT List Elements...

This preview shows pages 1–7. Sign up to view the full content.

1 Data Structures ADT List

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 ADT List Elements Structure Operations Domain Specification Representation Implementation User of an ADT must only know this Implementer must know all these.
3 ADT List: Specification Elements: The elements are of type <Type>. The elements are placed in nodes for linked list implementation. public class Node<T> extends Object { public T data; public Node<T> next; public Node () { data = null; next = null; } public Node (T val) { data = val; next = null; } }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 ADT List: Specification Structure: the elements are linearly arranged, the first element is called head , there is a element called current , and there is a last element. Domain: the number of elements in the list is bounded therefore the domain is finite. Type name of elements in the domain: List
5 ADT List: Specification Operations: We assume all operations operate on a list L. 1. Method FindFirst ( ) requires: list L is not empty. input: none results: first element set as the current element. output: none. 1. Method FindNext ( ) requires : list L is not empty. Cur is not last. input : none results : element following the current element is made the current element. output : none. 1. Method Retrieve (Type e) requires : list L is not empty. input : none results : current element is copied into e. output : element e.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 ADT List: Specification Operations : 1. Method Update (Type e). requires : list L is not empty. input : e. results : the element e is copied into the current node. output : none. 5. Method Insert (Type e). requires : list L is not full. input : e. results : a new node containing element e is created and inserted after the current element in the list. The new element e is made the current element. If the list is empty e is also made the head element.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}