ajitpec
BAN USER- 3of 3 votes
AnswersSuppose you are supplied with a file containing a list of words like ABC, BCD , CAB ( say each word in new line ). now you have to suggest algorithm for this problem -
- ajitpec in India
When a user type some character, we have to suggest him next character and basis of suggestion is that the character you are going to suggest should have maximum occurrence at that position among all these words.
For example , Let's say words are
ABC
BCD
CBA
Now if user types 'A' we have to suggest him 'B' as next character because if you see at second position in all words 'B' is occurring most number of times ( 2 times ).
similarly if he types 'AB' then we need to suggest him third character as 'C' as in third index all words have same occurrence but 'C' comes first.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 0of 0 votes
AnswersThese question were asked in Written test held in delhi...
- ajitpec
1) find the bug in the following code which concatenates 2 strings ---
char * concatenate(char *s1,char *s2)
{
char buffer[1024];
int i=0;
while(*s1)
{
buffer[i++]=*s1;
s1++;
}
while(*s2)
{
buffer[++i]=s2;
s2++;
}
return buffer;
}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersHy there are 4 questions asked in microsoft written paper in bangalore-
- ajitpec
1) you are given a function prototype like
char * replace(char *str,char *find,char *replace)
you need to code it and specifications are-
str is input string .
find is a given pattern and you need to find this pattern and if it exist replace it with another string (replace).
for example-
if you are given input string "aabcdef" and find pattern is "bcd" and replace string is "xyz" then output string should be "aaxyzef".
Also if Input string is "aabcdef" and find pattern is "bcd" and replace string is "xxxx" the output should be "aaxxxxef".
2) Write top 10 Scenarios for above code and three most critical test cases for above code.
3) Write top test cases to test coffee vending machine.
4)There are 8 cricket teams say t1,t2,t3,..t8 and each team plays two matches against each team one match in india and one match in abroad.these matches are known as league matches. Now after league matches top 4 teams(top scorer) will enter semi finals.Some data is-
A) each win gives one point to winning team.
B) There is no draw in any match.
C) at any point if scores of any two teams are equal then winner is decided by an automatic machine and is out of your control.
Now find-
x) Minimum number of matches to win so that a team can qualify for Semi finals.
y) Maximum Number of matches won by a team when it canNOT qualify for semifinals.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersFind bugs in the following program---
- ajitpec
Function is accepting a string and length of string and it is supposed to return number of occurrences of 'A' or 'a' ..
unsigned int occur(char *pch,unsigned long len)
{
int tmpvar=len;
int i=0;
int ret=0;
if(*pch==NULL || !strcmp(pch," "))
return 0;
do
{
if(pch[i]=='A' || pch[i]=='a')
ret++;
else
i++;
}while(i<tmpvar);
return ret;
}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersFind the output of the following Program-
- ajitpec
void main()
{
int array[4]={10,20,30,40};
int *tmp=array;
for (int i=0;i<4;i++)
{
tmp+=sizeof(int);
printf("%d",*tmp);
}
getch();
}
i think it should be 30 0 0 0| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Arrays
I suggested using a matrix and hash map approach but he was looking more using graph , further optimal solution.
- ajitpec November 21, 2013