Shobhit
BAN USER- 0of 0 votes
AnswersGiven an unsorted array.
- Shobhit in United States
With each number, we can associated a sum which is equal to the sum of all the numbers, less than the current number.
We've to find the total sum of all those numbers.
e.g. unsorted array :1, 5, 3, 6, 4.
for a[0]=1, sum[0]=0
for a[1]=5, sum[1]=1
for a[2]=3, sum[2]=1
for a[3]=6, sum[3]=1+5+3
for a[4]=4, sum[4]=1+3
total sum =sum[0]+sum[1]+sum[2]+sum[3]+sum[4] = 15| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
AnswersGiven the array of digits, you have to calculate the least positive integer value of the expression that could NOT have been received by you.
- Shobhit in United States
The binary operators possible are *, +, -, / and brackets possible are ( and ). Note that / is an integer division i.e. 9/5 = 1.
For ex- 6 6 4 4 the answer is 18
1 = 6 /6 + 4-4
2 = 6/6 + 4/4
3 = 6 +( 6/4) -4
4 = (6+6+4) / 4
……..
18 cannot be formed| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 0 votes
Answerssearch an element in sorted 3D Array .(Sorted in all the 3 directions) .
- Shobhit in United States
best time complexity (less than O(n^2))| Report Duplicate | Flag | PURGE
Amazon C - 0of 0 votes
Answersgiven a string . find the first unique character .
- Shobhit in United States
time complexity : O(logn) , space O(1)| Report Duplicate | Flag | PURGE
Amazon C - -1of 1 vote
AnswersWhat is the main use of interface ? Provide a real time example that shows it
- Shobhit in United States| Report Duplicate | Flag | PURGE
Goldman Sachs Java - 0of 0 votes
AnswersWhat is the importance of overriding in java ? Give any real life example . How is it increasing the code reusability and robustness .? Cant we create new function instead of override ? What difference will it make ?
- Shobhit in United States| Report Duplicate | Flag | PURGE
Goldman Sachs Java - 0of 0 votes
AnswersExplain the output :
- Shobhit in United States
#include<stdio.h>
int main()
{ double i=0;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
if(i==0.7)
printf("Equal : i=0.7\n");
i+=0.1;
if(i==0.8) printf("Equal : i=0.8\n");
else printf("Not Equal : i=0.8\n");
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerschar *p="havfun" , *q ="havfun" ;
- Shobhit in United States
are these two pointers equal ? If yes , then explain .| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersCompare the behavior of both the programs :
- Shobhit in United States
(1) . #include<stdio.h>
int main()
{
int i,a[3];
for(i=0;i<=3;i++)
a[i]=1;
for(i=0;i<=3;i++)
printf("%d\n",a[i]);
return 0;
}
(2) . #include<stdio.h>
int main()
{
int i,a[3];
for(i=0;i<=3;i++)
a[i]=i;
for(i=0;i<=3;i++)
printf("%d\n",a[i]);
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersIs there no null character after "abcd" string in the following declaration .
- Shobhit in United States
char *p="abcd";| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersExplain the output :
- Shobhit in United States
int main()
{
struct{int a:1;
int b;
}obj;
obj.b=6;
obj.a=1;
printf("%d %d",obj.b,obj.a);
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersIn the following declaration ptr is
- Shobhit in United States
far * near * huge * ptr;
1. far
2. huge
3. near
4. all of the above| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answers#include<stdio.h>
- Shobhit in United States
#include<conio.h>
int main()
{
int i;
i=5;
i=++i/i++;
printf("%d",i);
getch();
}
Explain the output .| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answers#include<stdio.h>
- Shobhit in United States
int main()
{
int a=10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut: // There should be an error .
printf("NONE\n");
}
return 0;
}
Check the output .. and explain why is it not showing an error ?| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerswrite a C program which generates random numbers between 1-100 (inclusive) on mouse movements.
- Shobhit in United States| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersExplain the output :
- Shobhit in United States
#include<stdio.h>
#define power(a) #a
int main()
{
printf("%d",*power(432));
getch();
return 0;
}| Report Duplicate | Flag | PURGE
C
can be done in O(n) time complexity
1. take 2 variable i, j,s (all r initially zero)
2. increment j and sum s+=a[j] till you get s>=given sum (and maintatin the count also) .
3. if(equal as above) then store the value of i , j , count in other variable .
4. else if(greater) then increment the i , and decrement the s with a[i] till u get s<=given sum.
4.a if(equal) then no probs , just cmpre the curr count with the prev stored count to chek max val and assign acc to it .
4.b else if(less) then increment j , s+=a[j] and check s with the givn sum .
i think accessing the values using 2D array (means just by knowing row and column , we can directly use the value ) is faster than the database queries because in db , we've to pass through all the rows until the match is found. But if the number of stations are huge , then database is preferred .
- Shobhit August 15, 2012#include<stdio.h>
#define max(a,b) (a>b?a:b)
#define size 9
int a[size],b[size];
void level(int);
int main()
{
int i,j=-1;
printf("Enter the elements(size = 9) :\n");
for(i=0;i<size;i++)
{ b[i]=-1;
scanf("%d",&a[i]);
}
for(i=0;i<size;i++)
level(i);
for(i=0;i<size;i++)
j=max(b[i],j);
printf("Height of the tree is %d\n",j);
return 0;
}
void level(int i)
{
if(a[i]==-1)
b[i]=0;
else if(b[a[i]]!=-1)
b[i]=b[a[i]]+1;
else {
level(a[i]);
b[i]=b[a[i]]+1;
}
return;
}
Its simple . Just open the cube box . and join the two diagonally opposite corners .
I mean first ant will move to the middle of the opposite side on the same plane from the staring point .
Then from that point , it'll start move to the corner (which lies diagonally opp to the starting point )
Total length covered = a*(5^0.5)
Repwilliamland1990, Associate at Advent
Gifted in donating shaving cream worldwide. Crossed the country getting my feet wet with the elderly in Salisbury, MD. Have ...
RepLizaZeiger, Animator at Accenture
I am a Loan processing clerk. My work is assembling, administering and processing your loan application paperwork before it gets ...
RepNaomiMoore, abc at A9
I have wide experience with commercial negotiations and international transactions.Advising on the incorporation and related shareholder agreements for a ...
RepRomiTerry, Member Technical Staff at Cleartrip.com
Romi , a Dynamic Property Manager highly regarded for increasing and maintaining a high level of occupancy adhering to all regulations ...
Algorithm : Fisher and Yates shuffle (no extra storage)
- Shobhit December 24, 2012