data structures and algorithms on algonomics
https://algonomics.io/
Recent content in data structures and algorithms on algonomics
Hugo  gohugo.io
Copyright © 2019, all rights reserved.
Sat, 06 Feb 2010 00:00:00 +0000

Introduction to Trees
https://algonomics.io/blog/introductiontotrees/
Sun, 22 Sep 2019 04:05:31 +0000
https://algonomics.io/blog/introductiontotrees/
A tree is an abstract data structure that represents hierarchal data structure. The individual nodes of a tree maintain the parentchild hierarchal relationship. The tree data structure is built of individual nodes where each node is made up of:
value: the value represented by the node children: list of children of this node. For binary trees as there are at most 2 children, the common practice is to refer to those as left and right children.

Linked Lists
https://algonomics.io/blog/linkedlist/
Fri, 06 Sep 2019 04:05:31 +0000
https://algonomics.io/blog/linkedlist/
A LinkedList is a linear data structure comprised of a sequence of nodes where each node is made up of two components:
Value: the actual value that the node holds. Next: a reference to the next node in the sequence. Below is an illustration of the Node structure and their arrangement to form a LinkedList:
The first node is also known as the head or root node. Similarly, the last node is known as tail node.

HashMap Hash Function
https://algonomics.io/blog/hashmaphashfunction/
Mon, 02 Sep 2019 17:05:31 +0000
https://algonomics.io/blog/hashmaphashfunction/
Assuming that you are already aware about the concept of hashing and hash functions in general, this post tries to look into the details of how the hash function is implemented in java8 HashMap.
Let’s take a quick look at the below mentioned snippet from java8 (1.8.0_221)  HashMap class:
// Computes key.hashCode() and spreads (XORs) higher bits of hash // to lower. Because the table uses poweroftwo masking, sets of // hashes that vary only in bits above the current mask will // always collide.

Fibonacci Numbers
https://algonomics.io/blog/fibonaccinumbers/
Tue, 30 Jul 2019 17:05:31 +0000
https://algonomics.io/blog/fibonaccinumbers/
Fibonacci Numbers, named after the great Italian mathematician of the same name, are so popular that theres even a mathematical journal (The FIbonacci Quarterly) dedicated to their theory and applications.
From golden ratio (also known as phi), to their appearance in various natural settings like branches of a tree, seed patterns of a sunflower, veins of leaves and many more, fibonacci numbers can be found almost everywhere.
Recurrence Relation Mathematically, the $n^{th}$ fibonacci number can be represented as the sum of two previous fibonacci numbers: $F_{n}=F_{n1}+F_{n2}$ with a set of given initial values:

Permutations, Substrings and Subsequences
https://algonomics.io/blog/substringandsubsequences/
Tue, 18 Jun 2019 07:46:55 +0000
https://algonomics.io/blog/substringandsubsequences/
Let’s start this article by defining these terms:
Permutation: A permutation, also called an “arrangement number” or “order” is a rearrangement of the elements of an ordered list S into a onetoone correspondence with S itself. Substring: A substring is a contiguous sequence of characters within a string. The word contiguous is important here as you cannot skip words or characters between the selected words/characters in a substring. Subsequence: A subsequence is a sequence that can be derived from another sequence (sequence of characters in case of a string) by deleting some or no elements without changing the order of the remaining elements.

Permutations and Combinations
https://algonomics.io/blog/permutationscombinations/
Thu, 06 Jun 2019 07:46:55 +0000
https://algonomics.io/blog/permutationscombinations/
Before we look into various mathematical formulas, the first thing is to understand the difference between permutation and combination. Consider the following two scenarios:
Selecting 2 students from a class of 30 students to collect notebooks from rest of the students. Entering the unlock code on your cell phone. As you notice, in the first case the order does not matter; i.e. the students (say a,b) can be selected in any order {a,b} or {b,a}, the end result remains same.

Recursion
https://algonomics.io/blog/recursion/
Thu, 23 May 2019 03:48:01 +0000
https://algonomics.io/blog/recursion/
An algorithm design paradigm that is :
Based on “divide and conquer” approach. Is used to solve complex problems by breaking the original problems into small problems. Implemented by calling the same methods or routines for small subsets of the problems and then combining the results of those individual subsets. To understand recursion, one must first understand recursion  Stephan Hawking
Every recursive algorithm is comprised of two sections:

Bitwise Operations
https://algonomics.io/blog/bitwiseoperations/
Fri, 17 May 2019 03:48:01 +0000
https://algonomics.io/blog/bitwiseoperations/
Bitwise algorithms is a class of algorithms where instead of performing common operations like addition, comparisons etc on the decimal numbers, are performed on the individual bits that comprise those numbers.
The bitwise operations are considered very efficient as compared to their decimal counterparts.
Bitwise Operators Following is the list of bitwise operators:
Bitwise AND (&): Performs bitwise AND on the individual bits of the two operands.

Mathematical Progressions
https://algonomics.io/blog/mathematicalprogressions/
Mon, 06 May 2019 07:46:55 +0000
https://algonomics.io/blog/mathematicalprogressions/
A mathematical progression is a sequence of numbers such that all the members of the sequence are governed by certain rule, which defines the relation between consecutive terms. There are three types of mathematical progressions:
1. Arithmetic Progression An arithmetic progression (AP) or arithmetic sequence is a sequence of numbers such that the difference between the consecutive terms is constant.
For an AP with common difference as d and first term as $a_1$, the terms of the progression can be represented as: $a_1, a_1+d, a_1+2d, a_1+3d … a_1+(n1)d$

Quick Sort
https://algonomics.io/blog/quicksort/
Sun, 28 Apr 2019 16:38:01 +0530
https://algonomics.io/blog/quicksort/
Before we discuss the actual algorithm, keep in mind that Quick Sort algorithm does not justifies its name and is not the quickest sorting algorithm that you may have expected it to be (from its name).
There are other algorithms like MergeSort which outrun quick sort for worst case scenarios.
Ok, so enough of the preface, let’s talk about the actual algorithm.
QuickSort (like MergeSort) is another divide and conquer based algorithm that considers one pivot element at a time and sorts the elements of the input dataset around this element.

Merge Sort
https://algonomics.io/blog/mergesort/
Sat, 27 Apr 2019 07:46:55 +0000
https://algonomics.io/blog/mergesort/
MergeSort algorithm works on the principle of divide and conquer and achieves a better average and worst case runtime as compared to the sorting algorithms (ex: InsertionSort, SelectionSort) that we previosuly discussed.
The basic idea behind this algorithm is to divide the given input into equal halves until it cannot be further divided. Once done, we start merging these individual elements in sorted order which evantually gives us the entire datastructure in sorted order.

Insertion Sort
https://algonomics.io/blog/insertionsort/
Sun, 21 Apr 2019 07:46:55 +0000
https://algonomics.io/blog/insertionsort/
Insertion Sort algorithm takes input, an unsorted array or any other sequential datastructure and sorts the same inplace, one element at a time. The idea is similar to how a player sorts the playing cards in hand.
It is not the most optimum algorithm and performs poorly for large data sets. The average case complexity is $O(n^2)$. Consider the following example:
For the given input array: $\{10,8,11,3,5\}$, following steps are performed:

Selection Sort
https://algonomics.io/blog/selectionsort/
Sat, 20 Apr 2019 18:37:19 +0000
https://algonomics.io/blog/selectionsort/
As with Bubble Sort, Selection Sort is another sorting algorithm that is based on the approach of compare and swap. It also has $O(n^2)$ complexity thus making it unusable for very large datasets.
Selection Sort is based on the method of identifying the smallest (or largest, depending on the sorting requirement) element from the given input dataset and replacing it with the value at smallest not yet sorted index.

Bubble Sort
https://algonomics.io/blog/bubblesort/
Wed, 17 Apr 2019 07:46:31 +0000
https://algonomics.io/blog/bubblesort/
Bubble Sort is one of the first sorting algorithms that is taught as part of any basic CS course. Even with its simple implementation, bubble sort is rarely used for large datasets or where efficient processing is required due to its quadratic, average and worst case run time complexity.
The algorithm is also known as comparisonsort and works on the method of swapping elements which are not at correct position.

Interpolation Search
https://algonomics.io/blog/interpolationsearch/
Sun, 14 Apr 2019 04:46:31 +0000
https://algonomics.io/blog/interpolationsearch/
Interpolation Search is another searching algorithm, used to search sorted datasets with an additional condition that the data should be uniformaly distribued. Keep in mind that the uniformity of the data is NOT a mandatory ask. Its just the fact that the algorithm performs better in case the data is uniformaly distributed.
Umm.. Ok.. but what is uniformaly distributed data?
In layman terms, we can say that when all the elements in a dataset have equal probability to get selected, the dataset is said to be uniformaly distributed.

Jump Search
https://algonomics.io/blog/jumpsearch/
Sun, 17 Feb 2019 00:23:19 +0000
https://algonomics.io/blog/jumpsearch/
Just like Binary Search, Jump Search is also applicable only on sorted elements and works by dividing the entire dataset into smaller partitions. This technique helps these algorithms to reduce the overall time complexity to search for an element.
The basic idea in Jump Search is to consider only a subset of the entire dataset at any given point of time and to see if the key element (the element that we need to find) is present in it or not.

Binary Search
https://algonomics.io/blog/binarysearch/
Fri, 15 Feb 2019 16:23:19 +0000
https://algonomics.io/blog/binarysearch/
While Linear Search can be used in every possible scenario for sequential data structures, the overhead of linear time complexity makes it unsuitable for large data sets.
Another problem involved with linearsearch algorithm is that, it does not consider any additional metadata, that might be available for the input dataset. For example, if the data is already sorted and compared to the first value the value that we need to search is very large, we can start scanning from the end, to reduce the number of iterations performed.

Linear Search
https://algonomics.io/blog/linearsearch/
Wed, 13 Feb 2019 16:23:19 +0000
https://algonomics.io/blog/linearsearch/
Linear Search is one of the most fundamental searching algorithm in computer science. The same is also known as Sequential Search becuase of the fact that this algorithm is mostly used on linear or sequential data structures like lists, arrays etc.
The idea behind linearsearch algorithm is to compare each element present in the underlying data structure that we need to search, with the key element that we need to find.

Algorithm Complexity  What, How, Why
https://algonomics.io/blog/algorithmcomplexity/
Wed, 06 Feb 2019 15:21:50 +0000
https://algonomics.io/blog/algorithmcomplexity/
Let’s start with a few questions:
How do we say that an algorithm is better performing than another algorithm? Are there any set criteria on which we can compare two algorithms? Or in other words, why is it such a big deal to compare two algorithms in the first place. Before we answer the abovementioned questions, lets first be on the same page about a fact that comparing two algorithms is not as straight forward as it sounds.

About Me
https://algonomics.io/about/
Sun, 06 Jan 2019 00:00:00 +0000
https://algonomics.io/about/
Hi, my name is Sumit. I am fulltime java developer for the last 8 years. I started this blog as a side project for listing the most commonly used algorithms used in the day to day life of a developer.
I would certainly welcome any suggestions that you may have. Please drop me an email or you can also contact me at :
https://github.com/algonomics https://www.linkedin.com/in/sumitgaur/