Featured Article

Branch and Bound | Set 2 (Implementation of 0/1 Knapsack)

We strongly recommend to refer below post as a prerequisite for this. Branch and Bound | Set 1 (Introduction with 0/1 Knapsack) We discussed different approaches to solve above problem and saw that the Branch and Bound solution is the best suited method when item weights are not integers. In this post implementation of Branch… Read More »

Featured Article

Count strings with consecutive 1’s

Given a number n, count number of n length strings with consecutive 1’s in them. Examples: Input : n = 2 Output : 1 There are 4 strings of length 2, the strings are 00, 01, 10 and 11. Only the string 11 has consecutive 1’s. Input : n = 3 Output : 3 There… Read More »

Featured Article

Decorator Pattern | Set 3 (Coding the Design)

We have discussed Pizza design problem and different naive approaches to solve it in set 1. We have also introduced Decorator pattern in Set 2. In this article, design and implementation of decorator pattern for Pizza problem is discussed. It is highly recommended that you try it yourself first. The new class diagram (Click on… Read More »

Strategy Pattern | Set 1 (Introduction)

As always we will learn this pattern by defining a problem and using strategy pattern to solve it. Suppose we are building a game “Street Fighter”. For simplicity assume that a character may have four moves that is kick, punch, roll and jump. Every character has kick and punch moves, but roll and jump are… Read More »

Python Modules

A module is a file containing Python definitions and statements. A module can define functions, classes and variables. A module can also include runnable code. Grouping related code into a module makes the code easier to understand and use. Example:   The import statement We can use any Python source file as a module by… Read More »

Handling Ajax request in Django

Introduction This tutorial explains how to carry out a ajax request in Django web framework. We will create a simple post-liking app as a part of example. Glossary Project Initialization Create models Create views Write urls Carry out request with Jquery AJax. Register models to admin and add some posts.  Implementation: 1. Initiate the Django… Read More »


What is Laravel ? Laravel is a web application framework created by Taylor Otwell in 2011 and like all other modern frameworks, it also follows the Model-View-Controller (MVC) architectural pattern. Laravel values Elegance, Simplicity, and Readability and if one talks of building applications with PHP frameworks, Laravel is second to none. Since Laravel is open-source,… Read More »

Difference between Scanner and BufferReader Class in Java

java.util.Scanner class is a simple text scanner which can parse primitive types and strings. It internally uses regular expressions to read different types. Java.io.BufferedReader class reads text from a character-input stream, buffering characters so as to provide for the efficient reading of sequence of characters Following are differences between above two. Issue with Scanner when… Read More »

Branch and Bound | Set 1 (Introduction with 0/1 Knapsack)

Branch and bound is an algorithm design paradigm which is generally used for solving combinatorial optimization problems. These problems typically exponential in terms of time complexity and may require exploring all possible permutations in worst case. Branch and Bound solve these problems relatively quickly. Let us consider below 0/1 Knapsack problem to understand Branch and… Read More »

The Decorator Pattern | Set 2 (Introduction and Design)

As we saw our previous designs using inheritance didn’t work out that well. In this article, decorator pattern is discussed for the design problem in previous set. So what we do now is take a pizza and “decorate” it with toppings at runtime: Take a pizza object. “Decorate” it with a Capsicum object. “Decorate” it… Read More »

Artificial Intelligence 101: How to Get Started

Artificial Intelligence: Artificial Intelligence (AI) is the study of computer science focusing on developing software or machines that exhibit human intelligence. A lot of people think that AI is just a sci-fi concept that’s being used in movies like Star Wars, Terminator or Lucy, but there is a lot more to it. AI is a very broad… Read More »

Decorator Pattern | Set 1 (Background)

To understand decorator pattern let us consider a scenario inspired from the book “Head First Design Pattern”.  Suppose we are building an application for a pizza store and we need to model their pizza classes. Assume they offer four types of pizzas namely Peppy Paneer, Farmhouse, Margherita  and Chicken Fiesta. Initially we just use inheritance… Read More »

Viruses – From Newbie to pro

NOTE: Using an online compiler is not going to work here. Please install Python 2.7x and cv2, argparse modules to actually try out this example. Heya friends! Welcome back! Before continuing on with Malicious Logic, I request you to have a look at this great and informative article Worms, Viruses and Beyond!! Now, this article… Read More »

Count minimum steps to get the given desired array

Consider an array with n elements and value of all the elements is zero. We can perform following operations on the array. Incremental operations:Choose 1 element from the array and increment its value by 1. Doubling operation: Double the values of all the elements of array. We are given desired array target[] containing n elements.… Read More »