Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Working with LinkedList [Java]
Rating: 4.9 out of 5(6 ratings)
842 students

Working with LinkedList [Java]

Solving LinkedList questions using two pointers
Created byMonish Njs
Last updated 2/2023
English
English [Auto],

What you'll learn

  • How to traverse a LinkedList
  • How to use two pointer approach in Linked List
  • How to access, add, delete, add elements in Linked list
  • How to reverse a Linked list

Course content

1 section5 lectures32m total length
  • Printing all elements in LinkedList5:18

    Traverse a singly linked list from the head node, printing each node's data while following the next pointer until reaching null.

  • Delete an element in LinkedList5:17

    Delete a given non-last node in a singly linked list by copying the next node's value and redirecting links to skip the next node.

  • Find middle element in LinkedList7:53

    Finds the middle element of a linked list using the slow and fast pointer technique, handling even-length lists by choosing the second middle and discusses the time and space complexity.

  • Remove nth node in LinkedList8:42

    Learn to remove the nth node from the end of a linked list in Java using a fast and slow pointer approach, including edge cases like one or two elements.

  • Reverse a LinkedList5:21

    Reverse a singly linked list by swapping pointers with three references, previous, current, and next, until the current node is null, yielding the new head, with no extra space.

Requirements

  • Basic OOP concepts like class, methods etc

Description

LinkedList is the easiest topic comparing with all other DSA topics.


What is LinkedList?


A class / node is created with two elements - data and address. Data field stores some values. Address field will store the address of the node to which it needs to connect.

When several nodes are connected with each other, it forms  a Linked List.


Why Linked List?


Array has a size limitation. When we don't know the size of the elements we are going to have, we can't use Arrays. We can use Lists in those situations


Types of Linked Lists:

  • Simple Linked List – In this type of linked list, one can move or traverse the linked list in only one direction. where the next pointer of each node points to other nodes but the next pointer of the last node points to NULL. It is also called Singly Linked List”.

  • Doubly Linked List – In this type of linked list, one can move or traverse the linked list in both directions (Forward and Backward)

  • Circular Linked List – In this type of linked list, the last node of the linked list contains the link of the first/head node of the linked list in its next pointer.

  • Doubly Circular Linked List – A Doubly Circular linked list or a circular two-way linked list is a more complex type of linked list that contains a pointer to the next as well as the previous node in the sequence. The difference between the doubly linked and circular doubly list is the same as that between a singly linked list and a circular linked list. The circular doubly linked list does not contain null in the previous field of the first node.


Two pointer approach is the most commonly used approached for all Linked list problems. In this course, we have solved many basic Leetcode questions related to Linked list.

Who this course is for:

  • People who wants to learn how Linked List works