The pseudo random numbers can be generated using linear congruential method. Successive members of the linear congruential sequence {x} are generated using the expression: X_n+1 = ( a*X_n + b) mod m
Category: Placements
Delete a node from a Double Linked list, with out using any extra variables
DLNode *DelNode(DLNode *aHead, int DelValue) {
Reverse a Double Linked list
DLNode *revList(DLNode *aHead) {
Swap two variables in one line with out using temporary variable
a = a+b-(b=a) OR a = a^b^(b=a) And both of them will work also for chars and stuff ….
Detect cycle in a linked list
ptr1 = ptr2 = head; do{ ptr1 = ptr1 -> next; ptr2 = ptr2 -> next -> next; }while(ptr1 != ptr2); ptr2 is iterating along the list with double the speed of ptr1. If there is any cycle, then ptr1Continue reading… Detect cycle in a linked list
GOOGLE PAPER – Sept, 2006 – CHENNAI
Test consist of 15 question based on C, C++, and Data Structure and two C programs. So i am listing some of the question as i remembered. Q1) What is the value of i after execution of the following program.Continue reading… GOOGLE PAPER – Sept, 2006 – CHENNAI
Programming puzzles – 1
Some of the Technical Interview Questions For Computer Science Programmers …. The following is a list of questions which have been floating around some Internet circles. They are excellent prep questions for a technical interview. Don’t bother asking me forContinue reading… Programming puzzles – 1
Programming puzzles – 2
1. Write an efficient C program to count the number of bits set in an unsigned integer. i/p o/p ==== === 0(00) 01(01) 12(10) 13(11) 2….. … 2. Write a small C program, which while compiling takes another programfrom inputContinue reading… Programming puzzles – 2
Riddles
Some of the common riddles which will be asked in the interviews are …. 0. Classic: If a bear walks one mile south, turns left and walks one mile to the east and then turns left again and walks oneContinue reading… Riddles
Problmes on Bit Manipulations
1. Reverse the bits of an unsigned integer. ANS. #define reverse(x) (x=x>>16|(0x0000ffff&x)<<16, x=(0xff00ff00&x)>>8|(0x00ff00ff&x)<<8, x=(0xf0f0f0f0&x)>>4|(0x0f0f0f0f&x)<<4, x=(0xcccccccc&x)>>2|(0x33333333&x)<<2, x=(0xaaaaaaaa&x)>>1|(0x55555555&x)<<1) *2. Compute the number of ones in an unsigned integer. ANS. #define count_ones(x) (x=(0xaaaaaaaa&x)>>1+(0x55555555&x), x=(0xcccccccc&x)>>2+(0x33333333&x), x=(0xf0f0f0f0&x)>>4+(0x0f0f0f0f&x), x=(0xff00ff00&x)>>8+(0x00ff00ff&x), x=x>>16+(0x0000ffff&x)) 3. Compute the discrete log ofContinue reading… Problmes on Bit Manipulations