Category: Algorithms

Selection Sort Implementation in Java Example

Selection Sort Implementation in Java Example:   Psudeocode for selection sort: Take an array with N elements (say new long[]{3,3009, 76,172,271,2}) Outer for loop to iterate all the elements in the array. (index starts from 0) Create a currentMinimum variable with index value(initially 0) Create a nested for loop to iterate from innerIndex(index+1) (because till …

601 total views, no views today


Binary Search Implementation in Java Example

Binary search is one of the most important searching algorithm to know and understand for search functionality. In the below we are going to return the array position based on the searching number existence in the array, if it does not exist then we will return -1.   Binary search basically works this way, 1. …

548 total views, no views today


Singly Linked List Algorithm Implementation Java Example

Linked list is nothing but having the link of the next node with the current node, this gives lot of advantages like directly doing any manipulation on particular node instead of iterating everything for all the operations like we do in arraylist.   Why we need Linked List ?   Array does not help us …

714 total views, no views today


Reversing a string using Stack Implementation

In our previous post, we saw how to create a custom stack implementation in java.┬áToday we are going to extend the same implementation to perform additional operations like reversing, checking empty or full etc. Approach 1: [Simple & Best Approach]   We have used the same Stack class from this post [Java Stack Implementation Simple …

623 total views, 1 views today


Java Stack Implementation Simple Example

Recently I started refreshing the backbone of CS, data structure and algorithms. As part of that I wrote a core stack implementation functionalities like Push and Pop in java. I also wrote isEmpty() method just to make use in loops and stuffs like that.   I want you to try writing the stack(LIFO – Last …

625 total views, no views today