Skip to content

Latest commit

 

History

History
132 lines (84 loc) · 2.57 KB

Chapter 2 - Linked Lists.md

File metadata and controls

132 lines (84 loc) · 2.57 KB

Chapter 2: Linked Lists

By Rachael Pai 11/10/2017


Chapter Outline

  • What is Linked List ?
  • Creating Linked List
    • Issue and solution to creating a node in Java
  • Deleting a Node from Single Linked List
  • The Runner Technique
  • Resurcive Problems

What i have expected to my study ?

  • Fundamental
  • Content of the chapter
  • What left behind the topic ?
  • What is the difference between first-read and now ?
  • Questions to practice

What is linked list ?

  • Node
    • Data
    • Reference to next node
  • Head: reference to first node


Type of linked list

  • Single linked list
  • Double linked list
  • Circular linked list

Linked List Operations (1)

  • AddFirst

  • Travesering


Linked List Operations (2)

  • AddLast

  • Inserting "after"


Linked List Operations (3)

  • Inserting "before"

  • Deletion


Iterator / Cursor

The whole idea of the iterator is to provide an access to a private aggregated data and at the same moment hiding the underlying representation


Functions of Iterator

  • AnyType next() - returns the next element in the container
  • boolean hasNext() - checks if there is a next element
  • void remove() - (optional operation).removes the element returned by next()

Creating Linked List

  • wrap this with head

Deleting a Node from Single Linked List

  • Check null pointer
  • Upadte Head / Tail pointer

The Runner Technique

  • Detecting a circular linked list
  • One fast and one slow, eventually they will be in the same node sometimes


Extra: Linkedlist vs Array

  • Fix Size (Array) vs Dynamic (Link)
  • Easier Insertion and Deletion (Link)
  • Random Access(Array) vs Access Sequentially (Link)
  • More Memory (Link)
  • Better Cache locality (Array)

Reference

tags: wwc cracking the code linked lists