# Sorting Algorithms

Selection sort

The algorithm first iteration selects the smallest element in the array and swaps it with the first element. The second iteration selects the second smallest item and swaps it with the second element. This continues until the second-largest item is swapped with the second to last index leaving the largest element in the last index.

Insertion sort

The first iteration of this algorithm considers the second element in the array if it is less than the first element then swaps it. …

# Java Collections

Java Collection

A collection is an object that holds references to other objects.

Some of the Collection Interfaces are:

Set

Is an unordered collection that does not contain duplicate elements.

List

An ordered collection that contains duplicate elements.

List examples are:

Map

Is one with keys/values that aren’t duplicate but unique.

Some of the map classes are:

Hashtable, Hashmap, Hashsets etc.

Collection Methods

They help manipulate the collections as mentioned above.

fill — sets every list element to refer to a specific object.

copy — copies references from one list to another.

# Search Algorithms

Linear Search.

The Linear search algorithm is an algorithm that searches each element in an array in a sequence. If the searched-for element is found, the index of that element will be returned.

The efficiency of a Linear Search — Big O

This algorithm runs in O(n) time. The worst case is this algorithm will have to iterate through every element in an array until the searched-for element is found. In case the array is increased, so will be the number of iterations. …

# Big O notation

Big O notation is how hard an algorithm has to work to solve a problem or, in technical terms, the worst-case run time for an algorithm.

O(1) — Constant run-time algorithm.

This is an algorithm that returns an element in a known position regardless of the data size or array. For instance, designing an algorithm to test if the first element of an array is equal to the second.

O(n) — Linear run-time algorithm

For this algorithm, the number of iterations grows as the number of array elements. This is expressed as (n-1) where n is the number of array…

# My experience learning at OutBox 