FIGHTER
BAN USER- 0of 0 votes
Answersclass A { int a; void show(){ }; } int main() { A *obj = new A(); printf("\n object size = %d", sizeof(A)); return 0; }
printf() shows OBJ size 4 bytes ( i.e int size). why Function show() size is not included in OBJ size and where that show() information(i.e.. function pointer and implementation) stored ?.
- FIGHTER in United States| Report Duplicate | Flag | PURGE
NetApp Software Engineer / Developer C++ - 0of 0 votes
AnswersProcess has some 10 threads and all 10 threads entered DEADLOCK state. How can you free process(threads) from DEADLOCK state ? . Is there any way to kill lower priority thread ? . Can we attach that deadlocked process to the debugger and assign proper value to the Mutex variable ( assume all the threads are waiting on a mutex variable MUT but it is value is 0 and can we assign MUT value to 1 through debugger ) .
- FIGHTER| Report Duplicate | Flag | PURGE
NetApp Software Engineer / Developer Operating System - 0of 0 votes
AnswersHow MEMORY TOOLS (Valgrind , Purify ) detects memory leaks and memory corruptions ?. Interviewer asked me to write a function MEMORY_MONITOR() which should provide memory leaks information .
- FIGHTER| Report Duplicate | Flag | PURGE
NetApp Software Engineer / Developer Algorithm - 0of 0 votes
Answersvoid func( int *p) { // Add code to print MEMORY SIZE which is pointed by pointer P. } int main() { int *p = (int *) malloc (10); f(p); }
How can we find MEMORY SIZE from memory pointer P in func() ?
- FIGHTER| Report Duplicate | Flag | PURGE
NetApp Software Engineer / Developer C - 0of 0 votes
Answers#include<iostream> using namespace std; int A() { return 1; } char A() { return 'a'; } int main() { int a = (int )A(); return 0; }
Interviewer asked me, is it function overloading? . I said no this not function overload then he asked me why ? ( He emphasized on different function return types int and char ) .
- FIGHTER| Report Duplicate | Flag | PURGE
NetApp Software Engineer / Developer C++
#include <stdio.h>
inline int max( int a, int b, int c)
{
return (a>b)?( (a>c)? a:c ) : ((b>c)? b : c);
}
int find_max_sum(int A[4][4], int B[4][4], int n)
{
if( n<= 0 )
{
return 0;
}
else if(n == 1 )
{
return A[0][0];
}
else
{
int i=0, j=0;
for(i=0; i<n; i++ )
B[n-1][i] = A[n-1][i];
for(i=n-2; i>=0; i-- )
for( j=0; j<=i; j++ )
{
if( j == 0 )
B[i][j] = A[i][j] + max(0, B[i+1][j], B[i+1][j+1] );
else
B[i][j] = A[i][j] + max(B[i+1][j-1], B[i+1][j], B[i+1][j+1] );
}
return B[0][0];
}
}
int main()
{
int A[4][4] = {{3,-1,-1,-1},{8,5,-1,-1},{2,3,1,-1},{0,7,4,2}};
int B[4][4] = {0};//{;//{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1},{-1,-1,-1,-1}};
printf("\n max sum is %d\n", find_max_sum(A,B,4));
}
#include <stdio.h>
#include <malloc.h>
using namespace std;
int min(int a, int b, int c)
{
return ((a<b)?((a<c)?a:c):((b<c)?b:c));
}
int Largest_matrix(int input[5][5], int temp[5][5], int size)
{
int i, j;
int max=0; // this variable stores maximum value
/* last row values storing in temp*/
for(i=size-1, j=0; j < size; j++ )
temp[i][j] = input[i][j] ^ 1;
/* last column values storing in temp */
for(i = 0, j=size-1; i< size-1; i++)
temp[i][j] = input[i][j] ^ 1;
for( i = size-2; i>=0 ; i-- )
for(j=size-2; j>=0 ; j-- )
{
if( (input[i][j] == 0) && !( input[i][j] ^ input[i+1][j] ^ input[i+1][j+1] ^ input[i][j+1] ) )
{
temp[i][j] = 1 + min(temp[i+1][j], temp[i+1][j+1],temp[i][j+1]);
if(max < temp[i][j] )
max = temp[i][j];
}
else
{
temp[i][j] = input[i][j]^1;
}
}
return max;
}
int main()
{
int input[5][5] = {
{1,0,0,0,1},
{0,0,0,0,0},
{0,0,0,0,0},
{1,0,1,0,0},
{0,0,0,0,0}
};
int temp[5][5] = {0};
printf("\n largest matrix is %d\n", Largest_matrix(input, temp, 5));
for(int i=0; i<5; i++ )
{
for(int j=0; j<5; j++ )
printf("%d, ", temp[i][j] );
printf("\n");
}
}
Catalon number is the Solution
- FIGHTER May 01, 20122 points 1
4 points 2
6 points 5
8 points 14
Catalon number values C1 = 1, C2 = 2, C3= 5, C4 = 14
Cn= (2nCn)/(n+1)