Skip to main content

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.

Implementing Doubly Linked List in Java

A Doubly Linked List (DLL) is a linked data structure where each node holds a value and two pointers: one pointing to the next node and one pointing to the previous node. This bidirectional linkage enables forward and reverse traversal — something a singly linked list cannot do without extra memory. A doubly-linked list: each node stores a value, a link to the next node, and a link to the previous node. In this post, we implement a DLL in Java that supports insertion at the first position, last position, after a given position, and before a given position — as well as deletion, search, and both forward and reverse display.

Implementation of Circular Queue in Java with Array

A Circular Queue (also called a Ring Buffer) is a queue data structure that treats its underlying array as if it were connected end-to-end in a circle. Unlike a linear queue, once the rear pointer reaches the end of the array, it wraps back to index 0 — allowing reuse of freed slots without shifting elements. This post implements a true circular queue in Java using an array, with proper wraparound logic for both the front and rear pointers. How a Circular Queue Works Both front and rear start at -1 (empty state). Enqueue: Advance rear with wraparound: rear = (rear + 1) % size. The queue is full when (rear + 1) % size == front. Dequeue: Advance front with wraparound: front = (front + 1) % size. Reset both to -1 when the last element is removed. Circular property: Elements can be added to index 0 again after front has moved past it.

Implementing Binary Search Tree in Java

A Binary Search Tree (BST) is a node-based binary tree data structure where each node stores a key, and every node in the left subtree holds a key strictly smaller than the parent, while every node in the right subtree holds a key strictly greater. This ordering property makes BSTs excellent for fast lookup, insertion, and deletion — all in O(log n) time on average. In this post, we implement a BST in Java that supports insertion, search, and three traversal orders: inorder, preorder, and postorder. BST Properties One node is designated the root of the tree. Each internal node contains a key and has at most two child subtrees. The left subtree of a node contains only keys strictly less than the node's key. The right subtree of a node contains only keys strictly greater than the node's key. Each subtree is itself a valid BST.

Evaluating Postfix Expression with Java

Postfix notation (also called Reverse Polish Notation or RPN) is a mathematical notation where every operator follows all of its operands. For example, the infix expression 3 + 4 becomes 3 4 + in postfix. This eliminates the need for parentheses and operator precedence rules, making it ideal for stack-based evaluation. In this post, we implement a Java program that evaluates a postfix expression using a stack. The program reads the expression as a string and produces the integer result.

Program to Implement KMP Algorithm in Java

In this post, we’ll explore how to implement the Knuth-Morris-Pratt (KMP) string matching algorithm in Java. The KMP algorithm is an efficient way to search for a substring within a given string. It improves upon the brute-force approach by skipping over unnecessary comparisons after partial matches. What is the Knuth-Morris-Pratt (KMP) Algorithm? The KMP algorithm searches for a substring (pattern) in a larger string (text) efficiently by avoiding redundant comparisons. The key idea behind KMP is that when a mismatch happens, it uses previously gathered information about the pattern to shift the search window instead of starting from scratch. The algorithm uses two main components: Failure Function (Prefix Table): It helps determine how much the pattern should shift when a mismatch occurs. Search Process: Once the failure function is computed, the algorithm searches through the text to find the pattern.

Program to Implement K-Naive Algorithm in Java

In this post, we’ll implement the K-Naive (Brute-Force) string matching algorithm in Java. This is the simplest form of string search, where we check for the presence of a pattern in a text by checking one by one at every possible position. What is the K-Naive (Brute-Force) Algorithm? The Brute-Force algorithm searches for a substring (pattern) within a larger string (text) by checking for a match at every position in the text. It is simple to understand and implement but can be inefficient for large inputs.

Quote

जगातील गोष्टी पाहाव्यात, ऐकाव्यात आणि "नशिबात नाही" अशी मनाला समजूत घालून विसरून जाव्यात! जग सुंदर आहे कारण ते तुमचं नाही... जगातील अनेक गोष्टी सुंदर आहेत कारण त्या तुमच्या नाहीत!

Mediatech: ४ महिने थोडक्यात

Mediatech... वडाळा येथे असलेलेली छोटीशी web development कंपनी. ऑफिस antop hill warehouse मध्ये. सोमवार २३ जून २०१४ रोजी मी या कंपनीत रुजू झालो व ७ नव्हेंबर २०१४ रोजी कंपनीमधून रजा घेतली. तसा कार्यकाल फक्त ४ महिने आणि काही दिवसांचा! पण हा वेळ अनेक विविधरूपी आठवणींनी भरलेला होता. Technical आणि developer point of view ने तर बऱ्याच आठवणी आहेत परंतु इतरही काही किस्से सांगण्यालायक आहेत.