Skip to main content

Posts

Showing posts from 2018

Design Patterns using Java

According to Gang of Four(GOF) any software is classified in to one of the three categories. I read so many books about design patterns which provide a lot of information about Design Patterns in a language neutral way or related to a particular programming language. I am trying to complement the great books by providing the precise and concise information that is required in the day to day programming of a Java Developer. Any software can be classified into one of the three categories -Framework, Toolkit, Application. Framework - Framework defines a set of steps to create an application. Framework provides design reuse. Toolkit - Toolkit provides some utility functions to an existing application. Toolkit provides code reuse. Application - Application is some thing that is specific to the project, and is not useful outside the context of the current application. Gang of Four divided the Design Patterns in to 3 types based on their usage. There are 3 types of Gang of Fo

Twelve Factor app development for Microservices

The Twelve (12) Factor app methodology is a list of principles for any Web Application or Software as a Service, and it is especially useful for microservices. This methodology can be applied to apps written in any programming language that use any combination of backing services(database, queue, memory cache, etc). 1. Code Base  - There should a dedicated code base per app. There should be a dedicated code base for each App, and multiple code bases can not use the same code base. If any code base is required by more than one application, separate that code into a separate repository, and inject that using dependency manager into the dependent apps. The same code base can be used to deploy the application to different environments like develop, stage, and production. 2.  Dependencies  - Explicitly declare and isolate dependencies. All the dependencies need to be explicitly declared, and should be available as part of the build process. The should not depend on any implic

Java Comparator Applications

Java Comparator is one of the favourite questions in Java Interviews. This concept looks deceptively simple, and slight variations of this could be asked in the interviews. 1) Write an AlphaNumeric Comparator in Java that sorts the given strings in the human readable     format.  e.g., file1, file2, file 3, file4, file 10 Not like the typical comparator file1, file10 2) Chained Comparator which can be used to join Multiple Comparators 3) Given a List of Employee Objects group the Objects such that all the employees are grouped by     Department and by Name. 4) Use Java 8 Style Comparators

Java Dynamic Programming

1) This class handles the Fibonacci Series Problem using Dynamic Programming, and Memoization 2) This class solves the Stair Case Problem by finding the Number of Jumps possible to the Top of the StairCase. 3) This class Solves the Coin Change problem using Dynamic Programming and Memoization

Data Structures - Strings

1) Find if a given First String is a SubSequence of a Second String 2) Find Max Occurring Frequency Character in  a String 3) Check if Sequence of Characters of Two Strings can become same by removal of a Character 4) Remove all Duplicate Words from a String 5) Find for a Given Two Strings, if one is the rotation of the Other. 6) Find if two Strings are K-Anagrams 7) Longest Common Subsequence where character occurs at least k times. 8) Find if the two given Strings are anagrams of Each Other. 9) Anagram SubString Search

Searching Algorithms

1) Binary Search Iterative Approach /**   *  */ package com . test . search ; /**   * @author Kiran   *  */ public class BinarySearchIterative { /** * @param args */ public static void main ( String [ ] args ) { BinarySearchIterative binarySearch = new BinarySearchIterative ( ) ; int [ ] elements = new int [ ] { 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 } ; int searchElement = 11   ; int start = 0 ; int end = 0 ; if ( elements ! = null ) { end =   ( elements . length ) ; } int elementIndex = binarySearch . doBinarySearchIterative ( elements , searchElement , start , end ) ; if ( elementIndex ! = - 1 ) { System . out . println ( " Found the searching element" + " at the Index of " + elementIndex ) ; } else { System . out . println ( " The element is Not" + "  found in the Array " ) ; } } /** * * @param elements * @param sea