Posts

Segment Trees, Tutorial, C++ Code and Applications

Image
A segment tree is a heap-like data structure that can be used for making update/query operations upon array intervals in logarithmical time. We define the segment tree for the interval  [i, j]  in the following recursive manner: the first node will hold the information for the interval  [i, j] if i<j the left and right son will hold the information for the intervals  [i, (i+j)/2]  and  [(i+j)/2+1, j] Notice that the height of a segment tree for an interval with  N  elements is  [logN] + 1 . Here is how a segment tree for the interval  [0, 9]  would look like:  Code for creating a segment tree recursively: #include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; typedef struct segmentTreeNode* Node; struct segmentTreeNode { int low; int high; Node left; Node right; } segmentTreeNode; Node createSegmentTree(int low, int high); int main() {   ...

Apache in Ubuntu: Changing location of www directory.

Hello there! I was trying to install drupal to my computer, so that I can play with its features. For your information, I am using Lubuntu 13.10 (a variant of ubuntu). For installing drupal, I needed to install LAMP on my computer, which I installed using apt-get as: sudo apt-get install lamp-server^ (detailed instructions:  http://www.howtogeek.com/howto/42480/ ) Now, after installing LAMP,

Making money from internet, the most reliable ways!

Image
What you need: A computer and a working internet connection. Have a will to earn, a bit of expertise and some free time? Well, all you need to have is an Internet connection. Here we bring to you a few ways how you can earn some money on the Internet in the comfort of your home. Self publish books If you love writing and want to get a book published, Amazon offers a free service called Kindle Direct Publishing. The service allows anyone to self publish books on the Kindle (electronic) bookstore and earn royalties from sales. There are two plans you can choose from- the 35 per cent royalty works across any book sold in any country, while the 70 per cent royalty plan works if you sell in a few select countries. Indian authors can choose to set prices specifically for the Indian bookstore and receive royalty payments in Indian currency as well. Make and sell your apps With so many smartphones and tablets, app development can be a very lucrative business. You can learn about devel...

Roadies X Winner is Palak Johal!!

Image
Palak Johal, claimed the title of 10th season of famous MTV reality show Roadies, Battle For Glory. Palak, who proved himself the strongest contestant, defeated 15 contestants  and took home a cheque of Rs 4,50,000 and a Hero bike. The other Hero Roadies X Contestants of the finale were Raman Deep, Mohit and Anirudh. Palak- Winner of Roadies X The final  episode of Roadies X began with all the eliminated Roadies entering the location where they clashed with the final four. These four were the finalites: The two boys got eliminated in the rope task. So the ultimate battle was between Ramandeep and Palak. Too bad, isn't it.. most of us wanted Mohit or Anirudh to claim the title. So, the final battle concluded to between Ramandeep and Palak! And finally, Palak Claimed the title of Roadies X, battle for glory !!! Like always Raghu Ram, his twin brother Rajiv Laxman and Rannvijay were the judges. How did you like the 10th s...

One evening story, small things

Image
Yet another important chapter of life is made of small things that we, sometimes, ignore. Another day, a holiday, it was around 4 in the evening. I was preparing to take bath, and while going towards the bathroom, I decided to take a visit to the 'popular' Pangay's room. He was banging his head with his computer screen, trying to find some software on the internet, which I doubt he could find in one life (Thank God he knows how to work on a computer). Going by the brand, he owns a Dell-Pavillion-'some model', with a core i3 inside, but his computer seemed to be beaten by an old pentium. Anyway, it was not his computer's fault, sometimes it depend on who works on it.

A football match in the hostel

It's around 5 in the evening. I am feeling a little hungry. I gathered some known-mates, and we are going to Surendra's. Now we are at Surendra's. We are 4 in number, me, Patlu, Motu, and another weird guy, popularly known as Pangay due to his unusual involvement with the hostel staff member, Rajbir ;) We ordered two tandoori paranthas, and a tea. The Patlu and Motu are unwilling to eat, as they already had a good time in the market. The prantha arrival took considerable time, so in the meantime we took an argument over the high rates with the shop owner (or whoever he was, sitting on the counter). Paranthas arrived. The "Pangay" guy is eating at a faster pace than me, so I am in worry that he will eat my parantha after finishing his own. So I took a piece of his parantha saying that for sake of checking taste. And the fear turned real. The "Pangay" guy took a piece of my parantha, and that too the very central piece.. and suddenly after that he t...

Logic Puzzles that will troll your mind!

Image
Logic Puzzles 1. The Missing Piece Below the four parts have been reorganized. The four partitions are exactly the same in both arrangements. Why is there a hole? Hint:  This is not an optical illusion. If you print out the puzzle, cut out the pieces and rearrange them, you get the exact same dilemma. Answer:  The gradient of the teal hypotenuse is different than the gradient of the red hypotenuse. 2. Four Gallons You have a three gallon and a five gallon measuring device. You wish to measure out four gallons. Answer:  Fill the five gallon container. Pour all but two gallons into the three gallon container. Empty the three gallon container. Put the two remaining gallons from the five gallon container into the three gallon container . Fill the five gallon container one more time. Pour one gallon from the five gallon container by filling the three gallon container. Now the five gallon container contains four gallons. 3. The Islanders ...