objectives
play

Objectives: Discuss linked lists Review Typical operations - PowerPoint PPT Presentation

Linked List Objectives: Discuss linked lists Review Typical operations Linked List Classification: Holds the series of objects (also called node) Singly linked list: each object, except the last one, has an address


  1. Linked List • Objectives: – Discuss linked lists • Review • Typical operations

  2. Linked List Classification: • Holds the series of objects (also called node) • Singly linked list: each object, except the last one, has an address (reference) of another object. • 2-way linked list: each object has an address of another object and in return the referenced object will has the referencing-object address. • Doubly linked list: each object contains 2 addresses to reference two nodes. One of these two nodes must be of the same type and the other does not.

  3. Linked List • each Node must have at least 2 fields – Info field • Contains information, • is an object ( not a node object) from another well-defined class – Link field • Contains a reference to another Node • Is the address of a Node • The address can be its own Node address. • It can be null. That mean it has no Node to reference to.

  4. Linked List • Example of a Node at 2205 in heap 2205 infoField(int) address 7 EE01

  5. Memory (RAM) structure 8-bit data bus One Byte Address Bus

  6. Simple Node and RAM 8-bit data bus Hex: 2205 0000 0000 Bin: 0010 0010 0000 0101 0000 1001 1110 1110 0000 0001

  7. Symbolic Node Reference line One Node

  8. Symbolic Internal Node Reference line infoField

  9. Reference Variable & Node Variable name: head head Ref infoField

  10. Singly linked list • 2 nodes head null

  11. circular linked list • 3 nodes head

  12. 2-way linked list • 3 nodes null head tail null

  13. Doubly linked list • 3 nodes head null null null null

  14. Insert a new node • The dotted linked must be established. • head = new Node(new (infoField) , head ) ; head null

  15. Delete a node • The dotted linked must be established.

  16. Linked List summary • store many objects with one or more references • the objects are created by new and inserted into the list. • An object is deleted when it is de-linked out of the list. This object will not be discarded in the memory until Virtual Machine reclaims it.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend