Author Archives: YS

Given an array A[] and a number x, check for pair in A[] with sum as K

Let’s say the array is of size N. The naive way to solve the problem, for each element checking whether k-element is present in the array, which is O(N^2). This is of course far from optimal and you might not … Continue reading

Posted in Uncategorized | Tagged | Leave a comment

Casting Operators of C++ (Static Cast).

This is the first casting operator provided in c++. Syntax for using this operator is var=static_cast<type_id>expression static_cast can perform conversions between pointers to related classes, not only from the derived class to its base, but also from a base class to its derived. … Continue reading

Posted in cpp facts | Tagged | Leave a comment

Memory Layout of C Programs

A typical memory representation of C program consists of following sections. 1. Text segment 2. Initialized data segment 3. Uninitialized data segment 4. Stack 5. Heap A typical memory layout of a running process 1. Text Segment: A text segment … Continue reading

Posted in Uncategorized | Leave a comment

Adding more to function overloading in c++

Predict the output of following C++ program. #include<iostream> using namespace std; class Test { protected:     int x; public:     Test (int i):x(i) { }     void fun() const     {         cout << “fun() const called ” << endl;     }     void fun()     {         cout … Continue reading

Posted in cpp facts | Leave a comment

“Hello World” JNI

Steps to be follow to compile a hello world program on ubuntu 1) Create java file    — 2) Compile with javac javac output:- MyPro.class 3) Generate .h file for native cpp class using javah javah -jni MyPro … Continue reading

Posted in Uncategorized | Leave a comment

JDK setup for building android source code

Many time I face problem while setting build environment for building android. Specially when i format my machine . After  googling a lot  I find that now Sun-java-6 has be removed from the ubuntu repository so it is a big problem for … Continue reading

Posted in android, Java | Leave a comment

mounting network file system on your ubuntu system

There is a interesting thing about Unix, there is no limit of utilities. One of the utility I come to know is that you can mount the network file-system under your local file system. All of us know about the … Continue reading

Posted in Unix | Leave a comment