Skip to content
sneppets

sneppets

  • Privacy
second biggest

Find the second biggest element in an unsorted array – Single Traversal

December 5, 2018December 8, 2018 Editorial StaffLeave a Comment on Find the second biggest element in an unsorted array – Single Traversal

Given an input array of integers, your goal is to find the second biggest element present in the array in an effective way. Note, you need to achieve this in O(n) time i.e., you should be able to find result… Read More!

Algo, Java Algorithms, arrays
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
selection sort

Selection Sort in Java and Complexity Analysis

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

Selection sort is a sorting algorithm, precisely an in-place comparison sort. The selection sort improves over the bubble sort by reducing the number of swapping necessary from O(n2) to O(n). But the number of comparisons remains O(n2). Selection Sort Java… Read More!

Algo, Java Algorithms, selection sort, sort
bubble sort

Bubble Sort in Java and Complexity Analysis

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

Bubble Sort is a simple sorting algorithm that repeatedly steps through the list to be sorted and compares each pair of adjacent elements in the list and swaps them if they are not in order. This algorithm is too slow… Read More!

Algo, Java Algorithms, bubble sort, sort

Binary Search

September 9, 2018March 11, 2020 Editorial StaffLeave a Comment on Binary Search

Binary search is also known as half-interval search or logarithmic search. It is a searching algorithm used to find the position of an element in the sorted array. The payoff for using a sorted array comes when we use a… Read More!

Algo, Java Algorithms, Datastructures, java

Posts navigation

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