Wednesday, August 29, 2007

Interview questions ,algoritms and design thinking

Normally these Questions u can expect if u attend any TOP product MNC.

* Given an array of integers, find the indexes, the contiguous elements between which form the
largest increasing sum.

* Given two arrays which are sorted, remove all the elements from first array which appear in
second array.

* Given a binary search tree and a query x, find the node in the tree which is just less than x.

* Design a data structure to represent a table of employee records.

* Given an array of integers, find two numbers which add up to given sum.

* Write a factorial function for C math Library. Hint: Use amortized analysis

* Design question on how to extract session information from user logs

* Given a binary whose non-leaf nondes are either 'AND' or 'OR' and leaf nodes are either
'TRUE' or 'FALSE'. Given a node, find the boolean value represented by the sub-tree rooted
by that node. Write C++ code.

* Given an array of n bytes and given a pointer to the first byte, find the number of bits which
are 'SET' in the array

* Design a text editor. Design the data structures, classes etc

* Write C++ code for defining a generic Array

* Given two arrays which are sorted, the first array is long enough to hold the elements of
second array. Merge them and obtain a sorted array. TRY to do it with minumum swaps


Tele-Phone Interview Questions normally i ask.

* Write C++ code involving, inheritance, polymorphism, STL, Templates.

* Given a sorted array of integers, Write C code to find the index of the first occurrence of the
query, and also number of repetitions of the query.

* Given two light boxes, find from which floor of n storeyed building, if dropped the light box will
break.

* Difference between Hash table and binary search tree

* Design a data structure for table of employee records, so that the table is sorted frequently on
first name. How will you modify your data structure if image is one of the columns

Essential basics i expect any computer science engineer to have is on the below subjects.

* Essential C
* Binary Trees
* Tree List Recursion
* Linked List Basics
* Pointers and Memory
* Puzzles

Sunday, August 26, 2007

Looking for technical job poisition I expect a computer science guy to know the answers to these basic questions

** This questions for the Brijoo Bopanna is confidential, **

Hi Guys/Gals
Are you looking for technical programming job position, I expect any computer science guy to know the answers to these basic questions.

For more questions and tactics u can reach me by submitting your queries and requests here????

1)How reader and writer problem was implemented and come up with effective solution for reader and writer problem in case we have n readers and 1 writer.

2)What are the differences between C++ and Java exceptions?
(Checked and unchecked, C++ doesn't have an exception type, you
can throw anything.)

3)Write a C function that permutes an array, int* a, in place
without allocating any more memory, so that every permutation is
equally likely. Prove that every permutation is equally likely.

Best of luck,
Regards
Brijoo Bopanna.

Tuesday, June 26, 2007

Finalize a C++ class

// Prevent inheritance from a class

#define DECLARE_FINALIZE(C_)\
class C_;\
class Finalize_##C_{\
friend class C_;\
private:\
Finalize_##C_() {}\
}

#define FINALIZE(C_) virtual Finalize_##C_

// Test finalizing
DECLARE_FINALIZE(Base);
class Base: FINALIZE(Base) { // This finalizes 'Base'
};
class Derived : public Base{
};

Base b_;
Derived d_; // error: cannot access private constructor of 'Finalize_Base'

Tuesday, April 3, 2007

Endianess

/*Program to convert between endianess*/
/*Author Brijoo Bopannna*/
unsigned int endian ( unsigned x )
{
unsigned invert ;
const unsigned char *xp = (const unsigned char *) &x;
unsigned char *pIp = (unsigned char * ) & invert;
//Why is the above type cast required????
pIp [0] = xp [3]; /* reverse the individual bytes */
pIp [1] = xp [2];
pIp [2] = xp [1];
pIp [3] = xp [0];

return invert ; /* return the bytes reversed */
}