Skip to main content

Implementing Singly Linked List in Java

A singly linked list is a linear data structure made up of nodes, where each node contains a data field and a pointer to the next node in the sequence. Unlike arrays, linked lists do not require contiguous memory — elements can be inserted or removed at any position without shifting other elements. In this post, we implement a full-featured singly linked list in Java that supports insertion (at first, at last, at a given position), deletion (from first, last, or a given position), search, and display. A singly linked list — each node stores a value and a link to the next node.

Using Localhost For Facebook App Development

Note: This post was written in 2015 using an older version of ngrok. The current ngrok CLI uses different syntax: custom subdomains (-subdomain flag) are no longer available on the free plan, and the auth token command has changed to ngrok config add-authtoken <token>. The general approach of tunnelling localhost for Facebook OAuth is still valid — see the current ngrok documentation for up-to-date instructions. As a programmer you do develop every application on your machine first and then you test it on same machine and then you push it to remote test/production environment. You are developing a Facebook app and your requirement is user must login to use the app. Now you are ready with local environment, you have created a new project in your powerful IDE, you have downloaded the SDK, you are done with creating a new app in FB developer, now you are trying to add app domains to get access to FB's oAuth API. Hmm..... Something went wrong!... Facebook is not allowing you to use 'localhost' as app domain. Now what to do? Here is solution.

Java Implementation of Queue using Linked List

A queue is a FIFO (First In, First Out) data structure where elements are added at the rear and removed from the front. While a queue can be implemented using a fixed-size array, backing it with a linked list removes the capacity constraint — the queue grows and shrinks dynamically as elements are enqueued and dequeued. In this post, we implement a queue using a singly linked list in Java, supporting enqueue, dequeue, peek, and display operations.

Implementing Quick Sort in Java

Quick Sort is a highly efficient, comparison-based sorting algorithm that uses the divide-and-conquer strategy. It selects a pivot element, partitions the array into elements smaller than the pivot and elements larger than the pivot, then recursively sorts each partition. Its average-case time complexity is O(n log n), making it one of the fastest general-purpose sorting algorithms in practice.

Java Program to Convert Infix Notation to PostFix Notation

Infix notation is the standard way we write arithmetic expressions, with operators between operands — e.g., A + B. Postfix notation (also called Reverse Polish Notation or RPN) places operators after their operands — e.g., A B +. Postfix expressions can be evaluated by machines without needing parentheses or operator-precedence rules, making them ideal for expression evaluators and compilers. In this post, we implement a Java program that converts an infix expression to its equivalent postfix form using a character stack and an operator-precedence table.

Implementing Graph Traversing Algorithms in Java

Graph traversal is the process of visiting all nodes in a graph in a systematic order. It is a fundamental operation in graph algorithms used for pathfinding, connectivity analysis, cycle detection, and more. There are two standard traversal strategies: Breadth-First Search (BFS) — Explores all neighbours of the current node before going deeper. Uses a queue internally. Depth-First Search (DFS) — Explores as far as possible along each branch before backtracking. Uses recursion (implicit call stack) internally. In this post, we implement both BFS and DFS on an undirected graph represented as an adjacency matrix.

Java Program to Evaluate PostFix Expressions

Postfix notation (also called Reverse Polish Notation or RPN) places every operator after its operands. For example, the infix expression (6 - (2 + 3)) * (3 + 8/2) becomes the postfix expression 623+-382/+*. Evaluating postfix expressions is straightforward using a stack — no parentheses or precedence rules are needed. This post implements a postfix evaluator in Java using an integer stack. The program accepts a postfix string as input and prints the computed result.

Demonstrating Few String Manipulation Functions in Java

Java's String class provides a rich set of built-in methods for manipulating text. In this post, we demonstrate the most commonly used string functions — including case conversion, length, concatenation, trimming, character access, equality checks, and index searching — through a simple interactive Java program.

Implementation of Stack using Linked List in Java

A stack is a LIFO (Last In, First Out) data structure where elements are inserted and removed from the same end, called the top. While a stack is commonly implemented using a fixed-size array, it can also be backed by a linked list — which removes the size constraint entirely and allocates memory only as elements are pushed. In this post, we implement a stack using a singly linked list in Java. Each push operation adds a new node at the head of the list, and each pop removes the head node — making both operations O(1).

Implementing Circular Queue in Java with Arrays

A circular queue is a fixed-size queue where the storage array is treated as a ring. When elements are dequeued from the front, those positions become available again for future insertions — eliminating the wasted space problem of linear array queues. The queue follows the FIFO (First In, First Out) principle: elements are added at the rear and removed from the front. This post presents a circular queue implementation in Java using a static array-backed design, demonstrating enqueue, dequeue, peek, and display operations through a menu-driven console program.