# Array List in Java

Description
Java learn.
Categories
Published

View again

All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Share
Transcript
CSC248Jun-Oct 2013 Prepared by: PnYusnitaSokman1 CHAPTER TWO LIST ADT (Pn Yusnita Sokman) List 2  Is a finite, ordered sequence of data items call e emen s  Each list element has the same data type (homogenous)  The basic operation for list is based on the application of the problem  Example:  A list of students, a list of available room, a list of cities and a list of books 2  CSC248Jun-Oct 2013 Prepared by: PnYusnitaSokman2 Cont…  Normally consists of:   3  etrieve an eement rom a ist  Insert a new element to a list  Delete an element from a list  Find how many elements are in a list  Find whether an element is in a list  Find whether a list is empty List Implementation  There two ways to implement a list:   4  se an array to store te eements  Array List  Use a linked structure  Linked List  CSC248Jun-Oct 2013 Prepared by: PnYusnitaSokman3 List Implementation 5  When we define for sequential list, the using of array s suae o mpemen e s  Element in the list is homogenous  The size of element always change –depend on insertion and deletion element in the list  First element in the list called head/front  Last element in the list called tail/rear 5 List Implementation 6  Figure:  To create new list, determine empty list and traverse the list it is uite eas: a 0 a 1 a 2 a 3 a 4 a n a[0]a[1]a[2]a[3]a[4]a[n]headtail  Create new list  Need to define an array variable type  Need variables to count the element in the list 6  CSC248Jun-Oct 2013 Prepared by: PnYusnitaSokman4 List Implementation 7  Empty list  in the list. If the value is zero –empty list  Traverse list  Can be done using for statement  For insertion and deletion operation it is quite difficult deend on tes of list  7 List Implementation 8  Consider a list with a sorting element    nsertion an eetion operation must maintain te characteristics after completed the process  To insert new element  Need to shift on the right for every element in the list in order to give a place to anew element  To delete element     Need to shift on the left for every element from the list in order to replace the element that we want to delete 8

Jul 23, 2017

#### Pyotr Ilyich Tchaikovsky

Jul 23, 2017
Search
Similar documents

View more...
Tags

Related Search