Skip to content
sneppets

sneppets

  • Privacy
Stack Example

Stack Example 1: Reverse a string or word

November 13, 2018December 8, 2018 Editorial StaffLeave a Comment on Stack Example 1: Reverse a string or word

In our previous article Stack Introduction and Implementation we had learnt how to implement stack in java. In this first example we will see how to reverse a word or a string using a stack. When you run the following code, it… Read More!

DS, Java reverse string, stack, stack example
Stack Java

Stack Introduction and Implementation in Java

November 13, 2018December 8, 2018 Editorial StaffLeave a Comment on Stack Introduction and Implementation in Java

Stack is more abstract entity than array and many other data structures. The underlying mechanism used to implement stacks is not visible to the user. It follows Last In First Out (LIFO) principle i.e., stacks allows access to only one… Read More!

DS, Java stack, stack class
Arrays.sort() NullPointerException

Arrays.sort(), compareTo NullPointerException

November 13, 2018August 6, 2024 Editorial Staff

Are you getting NullPointerException while using Arrays.sort() and Comparable and don’t know exactly where is the problem in your code ? Solution You may get this exception when you miss any element or something is null. Check the following example,… Read More!

Java arrays sort, comparable, compareTo, NullPointerException
sort objects

Sort objects in Java using Insertion Sort

November 1, 2018December 8, 2018 Editorial StaffLeave a Comment on Sort objects in Java using Insertion Sort

In our Java program below we use insertion sort to sort Student objects based on the lastName key values. The doInsertionSort() method in this example is similar to doInsertionSort() method in the insertion sort example, but the only difference is we… Read More!

Algo, Java comparable, comparator, insertion sort, sort objects
insertion sort

Insertion Sort in Java and Complexity Analysis

September 27, 2018December 8, 2018 Editorial StaffLeave a Comment on Insertion Sort in Java and Complexity Analysis

Insertion sort consumes or marks one element in each iteration from the array of elements and grows the sorted output list. At each iteration, insertion sort removes one element from the input array and insert that element in a location… Read More!

Java Algorithms, insertion sort, sort

Posts navigation

Older posts
Newer posts
Copyright © 2018 Sneppets. All Rights Reserved