Thoughts of a programmer

Binary Indexed Tree

Previous week, we saw how we can use Square root decomposition to solve our problem. This week, we will see how we can solve the same problem by using a different technique called Binary Indexed Tree (also called Fenwick Tree). Binary Indexed tree is a useful technique when we are dealing with a dynamic array of data where following type of ... Read more

Square Root Decomposition

Let’s consider the Problem Statement from HackerEarth. Basically, you are given an array of size and queries. Each query can be of two types - - add to the element of the array - print the odd number of the array if it exists, else print And all the indexes are -based. So how can we solve this problem. Let’s try brutefor... Read more

Python & Terminal

(Note: All of these is related to Python 2. Python 3 may show different results.) While doing some office work, I came across this. I had written below line in my Python 2 interpreter. >>> s = '©' >>> s #for checking the value of s Surprisingly, I got the following value. '\xc2\xa9' The reason I was surprised,... Read more

Life of a binary

Almost every one of you must have written a program, compiled it and then ran it to see the fruits of your hard labour. It feels good to finally see your program working, isn’t it? But to make all of this work, we have someone else to thankful too. And that is your compiler (of course, assuming that you are working in a compiled language,not an ... Read more

Threading Explained

Normally the programs that you write are single-threaded. By single-threaded, I mean that the processor starts at the first instruction in the program and then executes them one-by-one in the sequential manner, of course with some branching here and there, until eventually it reaches the last instruction in the program and the program ends. But... Read more