• 28 December

    Single Responsibility Principle in Java

    In this tutorial, we will learn about single responsibility principle in java.It is one of SOLID principles and simplest design principle as well. Single responsibility principle dictates that there should be only one reason to change the class.If you have more than one reason to change the class then refactor the class into multiple classes according […]

  • 24 December

    Reverse number in java

    In this post, we will see how to reverse a number in java. Here is simple program to reverse a number. [crayon-663907337eacd245975015/] Output: Enter a Number : 4567 Reverse of the number : 7654 Let’s just observe values of variables at the end of each iteration. Iteration 0: number = 4567,remainder = 0, reversedNumber = […]

  • 24 December

    Bubble sort in C

    In this post, let’s see how to implement bubble sort in C. Bubble sort, also known as sinking sort,compares adjacent elements and swap them if they are not in correct order. Here is a simple illustration of bubble sort. Above GIF is generated from algorithms app. [crayon-663907337eba1020244051/] Output: Array before sorting: 67 23 45 74 […]

  • 24 December

    Linear Search in Java

    If you want to practice data structure and algorithm programs, you can go through Java coding interview questions. In this post, we will see about linear search in java. Linear search is simple sequential search in which target element is searched one by one in the array. If element is found in the array then index […]

  • 23 December

    Python check if key exists in dictionary

    In this article, we will discuss the different methods on how to check if a key already exists in a dictionary or not. Using the in keyword The in keyword as the name suggests can be used to check if a value is present in some data structure or not. Using this keyword, we can […]

  • 23 December

    Bubble sort in python

    In this tutorial, we will implement bubble sort in python. Bubble sort is a simple sorting algorithm. In bubble sort, we compare two adjacent elements and check if they are in correct order.If they are not in correct order, we swap them. Here is a simple illustration of bubble sort. Above GIF is generated from […]

  • 23 December

    Python sort list of tuples

    In this tutorial, we will see about how to sort list of tuples on the basis of various criterion. Let’s understand with the help of example Let’s say you have list of tuples as below: [crayon-6639073380277428057075/] Now you want to sort list of tuples based on age and age is 1st index in tuple. You […]

  • 16 December

    Iterate through dictionary in python

    In this post, we will see how to iterate through dictionary in python. You can use for key in dict.keys(): to iterate over keys of dictionary. [crayon-6639073380858250976459/] You can use for value in dict.values(): to iterate over values of dictionary. [crayon-663907338085d974354462/] You can use items() method to iterate over key-value pairs of dictionary. [crayon-663907338085f325836629/] Let’s […]

  • 16 December

    Python dictionary append

    In this tutorial, we will see how to append items to dictionary. There is no method called append in dictionary in python, you can actually use update method to add key value pairs to the dictionary. Simplest way to add item to dictionary [crayon-6639073380d4e322358979/] Output: {1: ‘one’, 2: ‘two’, 3: ‘three’} {1: ‘one’, 2: ‘two’, […]