Welcome to the_blog

All the things I know related to coding and design I put it here.

What is a Linked List Queue and How to Implement it in Java, Part 2

Date: 11 Jun 2024 | By: Mohd. Sameer


Welcome back! In our previous post, we explored the concept of a Linked List Queue and began its implementation in Java. We established fundamental functionalities like `getLength` and `enqueue`. Now, let’s expand our queue’s capabilities by implementing the `peek` and `dequeue` functions. These methods are crucial for a fully functional queue, allowing us to view and remove elements in a First-In-First-Out (FIFO) manner. To recap, a linked list queue is a data structure where elements are stored in nodes, with each node pointing to the next, thus creating a sequence. In this structure, the first element added is the first to be removed, mimicking a real-world queue.

What is a Linked List Queue and How to Implement it in Java, Part 1

Date: 20 May 2024 | By: Mohd. Sameer


In this post, I will explain what a Linked List Queue is and how to implement it in Java. Let's begin. In simple terms, a linked list queue is just a regular queue that can hold data in nodes or slots. The key characteristic is that the element added first will be removed first (FIFO - First In, First Out), similar to real-world queues, such as those in restaurants where the person who arrives first gets served first. In Big O notation, adding, removing, and peeking items are O(1) operations, meaning they are constant time operations regardless of the queue size. Now, let's implement it in Java.