Linked+Lists

=Linked Lists=

Linked List Basics
toc Memory is allocated as and when neededNo fixed sizeWhen you delete an item, the size of the structure reducesEfficient memory allocationEach item points to the next itemRandom access to an item not possibleStart at the beginning and move sequentially. To make a linked list, you need data and a pointer to the next piece of data.Each item in the list is called a Node. When the next pointer is null, it signifies the end of listIf first pointer is null, the list is empty.

Advantages of LL
Memory allocated at the time of execution of programContinuous memory space not neededCan keep adding more data – limited by available memoryWhen an item is removed, no empty slots get created Easy to insert a new item between two existing items, no data shifting needed

Disadvantages of LL
Sequential structure – not very suitable for efficient searchMore complex to manage – pointers to next item have to be updated

LL Task Set 1
> Node class > addLast > addFirst > isListEmpty > getListSize > displayList > > Required to follow correct programming format - indented, method comments
 * 1) Read pages 742-758, CH
 * 2) coding linked lists methods

Knowledge check

 * 1) can explain a LL structure in detail
 * 2) can draw a labeled diagram of a LL
 * 3) can state the BigO efficiency of a LL

Paper-pencil work: 3. Draw a labeled diagram of LL. 4. Draw a neat diagram illustrating how a node can be added to a LL 5. Draw a neat diagram illustrating how a node can be deleted from a LL 6. Draw a labeled diagram of a doubly linked list.

LL Task Set 3(due Aug19)

 * 1) Create an 'EventLL' class to store event name and date objects inside a new package called 'historicalEvents'
 * 2) create a test class to add events to the list and then display all.
 * 3) test data for your program will be given to you