Friday, November 8, 2013

Want to crash the system manually?

You have seen BSOD on windows system many times. But may wonder how to crash it manually. Here is the tool that can help you do it.

http://download.sysinternals.com/files/NotMyFault.zip
Note: This is not my application. It is owned by sysinternals.com

Interview Questions 2

How to find the middle node from a link list?

middle = last = head;

while( last!=NULL && last->next != NULL )
{
middle = middle->next;
last = last->next->next;
}

// here middle element is in the middle of list


How to count the number of on bits in the number?

count=0;
while( n>0 )
{
if( n & 1 )
{
count++;
}
n = n>>1;
}


How can you delete a node from a singly link list?
you are provided with only the pointer to node.


Save next node.
Copy all the data from the next node to the current node.
copy the next pointer from next node to the current node.
then delete the next node.

temp = node->next;
node->data = node->next->data;
node->next = node->next->next;
delte temp;

This would not work if the provided node is last element.