Aashish
BAN USER
- 0of 0 votes
AnswersGive a good data structure for having n queues ( n not fixed) in a finite memory segment. You can have some data-structure separate for each queue. Try to use at least 90% of the memory space
- Aashish in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersYou are given many slabs each with a length and a breadth. A slab i can be put on slab j if both dimensions of i are less than that of j. In this similar manner, you can keep on putting slabs on each other. Find the maximum stack possible which you can create out of the given slabs.
- Aashish in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
Answersyou are given a system of passing binary trees among 2 ppl
- Aashish in India
Step1: convert the tree to preorder and inorder strings
Step2:send those strings to the intended person
Step3:get back tree from the strings
whats your strategy of testing?write various test scenarios.---10 marks| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
AnswersWe have a text editor application where we can choose 1)between 100s of
- Aashish in India
different fonts like arial, calibri, etc.. 2)different text sizes 3) different formatting such as bold, Italics, regular, etc..
Imagine that the application is similar to word(there we will have these options). Now give different test cases to test this application.| Report Duplicate | Flag | PURGE
Microsoft Software Development Manager - 0of 0 votes
AnswersTest cases for finger print reader say in a laptop to login. Here you can swipe your finger to have a secured login. e.g. I will swipe my finger and the system will allow me to login.
- Aashish in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Testing - 0of 0 votes
AnswersGiven an array of 32bit unsigned integers in which every number appears exactly twice except three of them, find those three numbers in O(n) time using O(1) extra space. The input array is read-only. What if there are k exceptions instead of 3?
- Aashish in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersYou have a stream of bytes from which you can read one byte at a time. You only have enough space to store one byte. After processing those bytes, you have to return a random byte. Note: The probability of picking any one of those bytes should be equal.
- Aashish in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 3of 3 votes
AnswersGiven a circular single linked list.Write a program that deletes every kth node until only one node is left.
- Aashish in India
After kth node is deleted, start the procedure from (k+1)th node.
e.g.list is 1->2->3->4->5->1
k=3
1. You are at 1, delete 3.
List is: 1->2->4->5->1
2. You are at 4, delete 1
List is: 2->4->5->2
3. You are at 2,delete 5
List is: 2->4->2
4. You are at 2, delete 2
List is: 4
Return 4.
How efficient you can do it?| Report Duplicate | Flag | PURGE
Amazon Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersDesign the Class diagram for vending machine for Tea & Coffee. This machine can generate the diff type of tea like Cardemom, Elichi, Ginger. Same way 3 type of coffee. The thing is when you make the tea or coffee user can add n number of flavors like sugar, honey or etc.
- Aashish in India| Report Duplicate | Flag | PURGE
InMobi Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersRemove duplicates from min-heap.
- Aashish in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWhat is wrong with the below code?
- Aashish in India#include <iostream> #include <string.h> using namespace std; class A { char *p; public: A(const char* str) { p=new char[strlen(str)+1]; strcpy(p,str); } ~A() { delete p; } }; int main() { A s("Object s"); A t=s; s.~A(); A u("Object u"); u=s; return 0; }
| Report Duplicate | Flag | PURGE
Sap Labs Software Engineer / Developer Algorithm - 0of 0 votes
Answers
- Aashish in Indiavoid freeList( struct node *n ) { while( n ) {????} } Which one of the following can replace the ???? for the function above torelease the memory allocated to a linked list? Choice 1 n = n->next; free( n ); Choice 2 struct node m = n; n = n->next; free( m ); Choice 3 struct node m = n; free( n ); n = m->next; Choice 4 free( n ); n = n->next; Choice 5 struct node m = n; free( m ); n = n->next;
| Report Duplicate | Flag | PURGE
Aricent Software Engineer / Developer Algorithm - 0of 0 votes
Answersvoid *ptr;
- Aashish in United States
myStruct myArray[10];
ptr = myArray;
Which of the following is the correct way to increment the variable "ptr"?
Choice 1 ptr = ptr + sizeof(myStruct);
Choice 2 ++(int*)ptr;
Choice 3 ptr = ptr + sizeof(myArray);
Choice 4 increment(ptr);
Choice 5 ptr = ptr + sizeof(ptr);| Report Duplicate | Flag | PURGE
Aricent Software Engineer / Developer Algorithm - 4of 8 votes
AnswersDesign an algorithm that, given a list of n elements in an array, finds all the elements that appear more than n/3 times in the list. The algorithm should run in linear time ( n >=0 )
- Aashish in India
You are expected to use comparisons and achieve linear time. No hashing/excessive space/ and don't use standard linear time deterministic selection algo| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersIf i type some numbers in my cell, all phone numbers which have these typed nos in any order should appear, tell data structure for this.
- Aashish in United States
eg:if i type 926 then
932678....
92678...
9777726....
should appear.
[EDIT]: It seems you have lot of confusion.
Let me clear it through another example
eg: i enter 321, then
o/p(if they r in book)
9344241..
972153....| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Data Structures - 0of 0 votes
AnswersGiven a set of data ranges (i.e. 2-7, 5-9, 10-20), write a function to determine if there is any overlap within the set. Write test cases. Which data structure would be best to represent the intervals.
- Aashish in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 2of 2 votes
AnswersDoes it always happen that stack always grows downwards & heap grows upwards?
- Aashish in India
If its so, then how does OS keeps the heap area protected from the interference of the stack & vice-versa?
If its not, then what factors affect it? OS version ? Compiler? Anything else??| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Operating System
The memory for string is allocated in the read only area of the data region.While memory for the pointer p is allocated in the stack. Hence compiler doesn't permit us to the the string to which the pointer is pointing. To understand & see how it is happening, see the below program & try to analyze how the memory is allocated.
int main()
{
int i;
char *p="Hello";
int j;
printf("%p %p %p %p",&i,&p,&j,p);
return 0;
}
ideone.com/qNREi
- Aashish July 05, 2012Here is my approach.
Note that i have not handled the case of negative numbers.
int binaryD(char *bin,int n,int depth)
{
static int count;
if(n)
{
count++;
binaryD(bin,n/2,depth+1);
bin[depth]=(n&1)?'1':'0';
}
return count;
}
int binaryF(char* bin,float f,int *depth)
{
int count=0,i;
if(f<=0.0f)
return 1;
if(f==1.0f)
{
bin[*depth]='1';
return 1;
}
while(f)
{
f*=2;
if(f==1.0f)
{
bin[++*depth]='1';
return 1;
}
i=f;
if(f>1.0f)
{
bin[++*depth]='1';
f=f-i;
}
else
bin[++*depth]='0';
if(++count>32)
return 0;
}
}
void toBinary(char *s)
{
int num=0,i,depth=0,po=10,count;
char bin[50];
float f=0.0f;
for(i=0;s[i] && s[i]!='.';i++)
{
if(s[i]>='0' && s[i]<='9')
num=num*10 + s[i]-'0';
else
return;
}
if(s[i]=='.')
{
for(++i,po=10;s[i];i++,po*=10)
if(s[i]>='0' && s[i]<='9')
f=f+ (s[i]-'0')/(float)po;
else
return;
}
i=binaryD(bin,num,depth);
for(count=i-1;count>=0;count--)
printf("%c",bin[count]);
count=i;
if(f!=0.0f)
{
bin[i]='.';
binaryF(bin,f,&i);
for(;count<=i;count++)
printf("%c",bin[count]);
}
}
ideone.com/GElaE
Please let me know if any corner cases are missing
Modified Kadane algorithm can perform the task.
Time Complexity: O(M^2*N)
Space Complexity: O(M)// number of rows
Check for each sub-array starting with column number i to column number j. Store the sum[elements with row 0 will be summed & stored in temp[0] & so on] in the temporary buffer. Apply kadane algorithm on the temp[] to find the maximum sum contiguous subsequence. Let maximum sum subsequence in temp[] lies between y1 & y2. Keep updating the maximum sum till now as well as y1,y2,i&j.
Here is the function:
void printV(struct node *root,int *arr,int *depth)
{
if(root)
{
arr[++(*depth)]=root->data;
printV(root->left,arr,depth);
if(!(root->left || root->right))
{
while((*depth)>=0)
printf("%d ",arr[(*depth)--]);
}
printV(root->right,arr,depth);
}
}
Complete code: ideone.com/IAKcD
- Aashish July 04, 2012Won't work. Lets say you have pushed 2,3 &5.
Now the root becomes NULL, print it & return. However you are not emptying the stack.So, 2,3 remains in stack & again you push 6 to stack. The root becomes NULL in next call. You print 6,3,2.
In simple, you have written the program to print all leaf to root paths.
The output is undefined. There is no sequence point defined between the two expressions ++i & i++. Even if the expression is written like i=i++, the output is said to be undefined. A sequence point is also needed betwwen the two expressions i & i++, as the evaluation order of the expression is uncertain & varies from compiler to compiler based on parsing algorithm it follows to parse the instructions to be executed.
In simple words, if the value of the same variable is changed more than once in a statement, then it is said to be UNDEFINED BEHAVIOUR(UB).
A semi-colon is a sequence point where as +(plus) is not.
ideone.com/LGFEm
void correctList(struct node *root)
{
struct node *cur,*prev,*mark1,*mark2,*p,*q,*r;
if(!root || !(root->next))
return;
cur=root;prev=NULL;
while(cur->next && cur->data<cur->next->data)
{
prev=cur;
cur=cur->next;
}
mark1=prev;
prev=mark1->next;
while(cur->next && cur->data>cur->next->data)
cur=cur->next;
mark2=cur->next;
p=r=NULL;q=mark1->next;
while(q!=mark2)
{
r=q->next;
q->next=p;
p=q;
q=r;
}
mark1->next=p;
prev->next=mark2;
}
here is a backtracking approach which prints the solution as well.
#include <stdio.h>
void coinDenomination(int *coin,int size,int *sol,int depth,int tofind,int start)
{
int i;
if(tofind<0)
return ;
if(tofind==0)
{
for(i=0;i<depth;i++)
printf("%d ",sol[i]);
printf("\n");
}
else
{
for(i=start;i<size;i++)
{
sol[depth]=coin[i];
coinDenomination(coin,size,sol,depth+1,tofind-coin[i],i);
}
}
}
int main()
{
int coin[]={1,5,10,25},size,sol[50]={0},tofind;
size=sizeof(coin)/sizeof(coin[0]);
scanf("%d",&tofind);
coinDenomination(coin,size,sol,0,tofind,0);
return 0;
}
ideone.com/0ioYp
- Aashish July 03, 2012#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
void createList(int *arr,int size,struct node **root)
{
int i;
struct node *tail;
for(i=0;i<size;i++)
{
if(!(*root))
{
*root=(struct node*)malloc(sizeof(struct node));
(*root)->next=NULL;
(*root)->data=arr[i];
tail=*root;
}
else
{
tail->next=(struct node*)malloc(sizeof(struct node));
tail=tail->next;
tail->next=NULL;
tail->data=arr[i];
}
}
}
void traverse(struct node *root)
{
for(;root;printf("%d ",root->data),root=root->next);
printf("\n\n");
}
struct node *updateList(struct node *root)
{
struct node *p,*cur,*tail;
static struct node *newroot=NULL;
if(root==NULL)
return NULL;
cur=root;
while(cur)
{
if(cur->next && cur->data!=cur->next->data)
{
if(!newroot)
{
newroot=cur;
tail=cur;
}
else
{
tail->next=cur;
tail=tail->next;
}
cur=cur->next;
}
else
{
p=cur;
while(cur->next && cur->data== cur->next->data)
cur=cur->next;
if(p==cur)
{
if(!newroot)
{
newroot=cur;
tail=cur;
}
else
{
tail->next=cur;
tail=tail->next;
}
}
cur=cur->next;
}
}
tail->next=NULL;
return newroot;
}
int main()
{
int arr[]={1,1,1,2,3},size;//{1,2,3,3,4,4,5},size;
struct node *root=NULL;
createList(arr,sizeof(arr)/sizeof(arr[0]),&root);
traverse(root);
traverse(updateList(root));
return 0;
}
ideone.com/QVsBy
- Aashish July 03, 2012#include <stdio.h>
#include <stdlib.h>
int my_atoi(char *s)
{
int i,num=0,sign=1;
for(i=0;s[i];i++)
{
if(s[i]==' ')
continue;
else if(s[i]=='-') sign=-1;
else break;
}
for(;s[i] && s[i]>='0' && s[i]<='9';i++)
num=num*10 + s[i]-'0';
return num*sign;
}
int main()
{
char s[]="-12a4";
printf("%d %d",atoi(s),my_atoi(s));
return 0;
}
ideone.com/QiIS3
- Aashish July 03, 2012#include <stdio.h>
#include <limits.h>
void find(char *s)
{
int hash[256]={0},i,min=INT_MAX;
for(i=0;s[i];i++)
hash[s[i]]++;
for(i=0;s[i];i++)
{
if(hash[s[i]]==1 && i<min)
min=i;
}
if(min!=INT_MAX)
printf("First non-repeating character: %c",s[min]);
else
printf("No non-repeating character");
}
int main()
{
char ch[10];
fgets(ch,10,stdin);
find(ch);
return 0;
}
ideone.com/WuUQq
- Aashish July 03, 2012Output will be 4. An expression is never evaluated inside sizeof operator.
So, the function will not be called. However, you must be surprising that how the compiler is able to output 4. Its because compiler sees the signature of the function. Change the return type to double & you will see the output 8.
#include <stdio.h>
#define ROW 4
#define COL 5
void findMaxSumSubset(int *temp,int *x1,int *x2,int *sum_till_now)
{
int i,j,max_sum=0;
for(i=0;i<ROW;i++)
{
(*sum_till_now)+=temp[i];
if((*sum_till_now)<=0)
{
*sum_till_now=0;
*x1=i+1;
}
if((*sum_till_now)>max_sum)
{
max_sum=*sum_till_now;
*x2=i;
}
}
*sum_till_now=max_sum;
}
void display(int (*arr)[COL],int x1,int y1,int x2,int y2)
{
int i,j;
printf("\n--------------------------------\n");
printf("%d %d %d %d\n",x1,y1,x2,y2);
printf("\n--------------------------------\n");
for(i=y1;i<=y2;i++)
{
for(j=x1;j<=x2;j++)
printf("%d ",arr[i][j]);
printf("\n");
}
}
void findMaxSumSubsetRectangle(int (*arr)[COL])
{
int i,j,k,x1,x2,fx1,fx2,fy1,fy2,sum_till_now,max_sum,temp[ROW];
max_sum=0;
for(i=0;i<COL;i++)
{
for(k=0;k<ROW;k++)
temp[k]=0;
x1=i;
for(j=i;j<COL;j++)
{
sum_till_now=0;
for(k=0;k<ROW;k++)
temp[k]+=arr[k][j];
findMaxSumSubset(temp,&x1,&x2,&sum_till_now);
if(sum_till_now>max_sum)
{
fy1=x1;
fy2=x2;
fx1=i;
fx2=j;
max_sum=sum_till_now;
}
}
}
printf("Max Sum = %d\n",max_sum);
display(arr,fx1,fy1,fx2,fy2);
}
int main()
{
int arr[ROW][COL],i,j;
for(i=0;i<ROW;i++)
for(j=0;j<COL;j++)
scanf("%d",&arr[i][j]);
findMaxSumSubsetRectangle(arr);
return 0;
}
/************************************ SAMPLE OUTPUT ****************************
1 2 -1 4 -20
8 -3 4 2 1
3 8 10 -8 3
-4 -1 1 7 6
Max Sum = 37
--------------------------------
0 1 4 3
--------------------------------
8 -3 4 2 1
3 8 10 -8 3
-4 -1 1 7 6
*/
An approach without backtracking with O(1) space.
#include <stdio.h>
#include <string.h>
#include <math.h>
void comb(char *str)
{
int n,i,j,top,wt;
n=strlen(str);
n=pow(2,n);
for(i=1;i<n;i++)
{
for(j=i,wt=1,top=0;j>0;j>>=1,top++)
{
if(j&wt)
printf("%c",str[top]);
}
printf("\n");
}
}
int main()
{
char str[]="ABCD";
comb(str);
return 0;
}
ideone.com/A5Ucq
- Aashish July 02, 2012I have modified the code & it prints the encodings too.
#include <stdio.h>
void encoding(char *s,char *str,int depth)
{
int i;
if(*s=='\0')
{
str[depth]='\0';
printf("%s\n",str);
}
else
{
str[depth]=*s-48 + 64;
encoding(s+1,str,depth+1);
if(*(s+1)!='\0')
{
i=( (str[depth]-64)*10 + (*(s+1)-48) );
if(i<=26)
{ str[depth]=i+64;
encoding(s+2,str,depth+1);
}
}
}
}
int main()
{
char s[]="12121",str[10];
encoding(s,str,0);
return 0;
}
ideone.com/1MIff
- Aashish July 02, 2012Here is a recursive one.
The idea is very simple. If we know the number of solutions for n-1 characters, we can extend it for n characters. How? Lets see.
Say the number of solutions for n-1 characters is p, then if by combining n-1th character with nth character gives an integer <=26, it also leads to another possible solution.\
Based on same idea, here is the simple code.
#include <stdio.h>
#include <string.h>
int count_decode(char s[10],int n)
{
int x1,x2,z,res;
if(n<0)
return -1;
if(n==0)
return 1;
else
{
res= count_decode(s,n-1);
x1=s[n]-'0',x2=s[n-1]-'0';
z=x2*10 + x1;
return (z<=26?(res+1):res);
}
}
int main()
{
int i,j,n;
char S[10];
gets(S);
n=strlen(S);
printf("< %d >",count_decode(S,n-1));
return 0;
}
@Barney, @luv, I want to share some of my concepts.
I request you to get your basic concepts clear & brushed up.
When you are calling f(), then memory is being allocated for array a[] on the stack, where you are initializing its sots with 1. Now, since this array has been allocated on the stack, the scope is local. When you return from the function, the memory gets freed up. However memory doesn't go anywhere. The OS maintains a free list of all the memory which has been freed & so, can be used by any other process. By garbage value, the process means that it is expecting any unusual value[it may mean 1 or value with figure like 84638290(Both are considered as garbage for that process)].
Now, coming to the point, When you call function g(), memory is being allocated for array b[], However, its just an accident that the same memory gets allocated that was being allocated to a[] & so, it contains all 1.
However, its never safe to rely upon such type of allocation[as its just an accident].
A different compiler, a different optimization settings would trap you.
Hope everything is clear.
Use Augmented BST where each node will have three child.
An interval with end time less than the start time of the root will serve as the left child.
An interval with start time greater than the start time of the root & end time less then end time of the root will serve as the middle child.
An interval with start time greater than the end time of the root will serve as the right child.
Now insert all intervals in the BST. Print all the middle children.
But the problem is that it won't allow the insertion of the intersecting intervals.Do the presence of intersecting intervals really change the solution?
Maintain a BST of customers. The node will contain customer id & a hash of size 2[2 days are there]. when a new customer logs in, search its existence in BST. If its there update the corresponding hash. If no,insert a new node in BST & update the corresponding hash entry.
Finally traverse the BST & output all customers with both days visited.
Note that i think this approach is dynamic because there is no limit on the number of customers. So, it would be better than hash where initially size is fixed[may be resized later but takes time to copy the enteries].
yeah sure. There is a concept called as memory banking which is undertaken by the microprocessor for faster memory access. In INTEL micro-processor, an address always starts from the even one. If it starts from the odd address, then the micro-processor will take two clock cycles to access a memory.
I am not talking about the word alignment in case of fundamental types. Word alignment plays a very vital role in case of use defined types for faster memory access.
Now, coming to your issue. Your output is correct but you are missing some points. Word alignment is never done based upon the size of biggest type. Consider the below example:
struct s
{
int i;
double d;
};
int main()
{
struct s s1;
printf("%d ",sizeof(s1));
return 0;
}
The output is 12 & not 16. See here: ideone.com/uVdlU
One more point must be noted. Alignment is also done based on the structure variables.
The output depends upon the architecture i.e. word length of the micro-processor.
If the word length is 16 bits, then the output is 4 bytes.
If the word length is 32 bits, then the output is 8 bytes.
One more factor that may affect the output is the word alignment which can be changed by #pragma. By default, in turbo-c, the word alignment is 1 byte.There is no effect of #pragma directive. So, there you will find the output as 3 bytes.
int isValid(int (*sudoku)[SIZE],int row,int col)
{
int i,j,start_row,start_col;
// initialise a hash of size 10 with each slot containing 3.
for(j=0;j<col;j++)
for(i=0;i<SIZE;i++)// checking each column
if(hash[sudoku[i][j]]==3)
hash[sudoku[i][j]]--;
else return 0;
for(j=0;j<row;j++)
for(i=0;i<SIZE;i++)// checkin each row
if(hash[sudoku[j][i]]==2)
hash[sudoku[j][i]]--;
else
return 0;
return 1;
}
If all the rows & all the columns have been checked for correctnes, then there is no need to check correctness of each grid.
- Aashish July 01, 2012The behavior is undefined.The explanation goes as follows:
If you want to change the pointer p to point to another memory location, you must use &p in scanf.
However, if you write p, then you must supply the format specifier as %d, because by p, you are actually passing the memory location where the pointer p is pointing[i.e. i]. So, whatever you input that gets stored in i indirectly.
Note that in printf, if the format specifier is changed then the programmer is responsible for all kinds of side effects.
@Barney, My program is working correctly for the input set given by you.
I request you to check it again. Can you provide the link where you tried it & it failed[like ideone]?
Here is the link where i have tried.
Please see: ideone.com/9c0A6
Note: Here i am not able to figure out why it is showing runtime error. The program is working perfectly under the ubuntu [gcc] platform without reporting any run-time error or segmentation fault[memory access violation exception].
Here is the backtracking approach:
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
void back(int *arr,int *sol,int N,int tillnow,int sumtillnow,int remainsum,int *finalsol)
{
static int mindiff=INT_MAX;
int i;
if(tillnow==N/2)
{
if(abs(sumtillnow-remainsum)<mindiff)
{
mindiff=abs(sumtillnow-remainsum);
for(i=0;i<N;i++)
finalsol[i]=sol[i];
}
}
else
{
for(i=0;i<N;i++)
{
if(!sol[i])
{
sol[i]=1;
back(arr,sol,N,tillnow+1,sumtillnow+arr[i],remainsum-arr[i],finalsol);
sol[i]=0;
}
}
}
}
int main()
{
int arr[10]={1,2,3,4,5,6,7,8,9,10},sol[10]={0},finalsol[10],i,sum=0;
for(i=0;i<10;i++)
sum+=arr[i];
back(arr,sol,10,0,0,sum,finalsol);
for(i=0;i<10;i++)
{
if(finalsol[i])
printf("%d ",arr[i]);
}
printf("\n");
for(i=0;i<10;i++)
{
if(!finalsol[i])
printf("%d ",arr[i]);
}
}
#include <stdio.h>
void change(int (*M)[5])
{
int flagrow=1,flagcol=1,i,j;
for(i=0;i<5;i++)
flagrow&=M[0][i];
for(i=0;i<5;i++)
flagcol&=M[i][0];
for(i=1;i<5;i++)
{
for(j=1;M[i][0] && j<5;j++)
M[i][0]&=M[i][j];
}
for(i=1;i<5;i++)
{
for(j=1;M[0][i] && j<5;j++)
M[0][i]&=M[j][i];
}
for(i=1;i<5;i++)
{
for(j=1;j<5;j++)
if(M[i][j]==1 && M[i][0]==0 || M[0][j]==0 )
M[i][j]=0;
}
if(flagrow==0)
for(i=0;i<5;i++)
M[0][i]=0;
if(flagcol==0)
for(i=0;i<5;i++)
M[i][0]=0;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
printf("%d ",M[i][j]);
printf("\n");
}
}
int main()
{
int arr[][5]={{1, 1, 1, 1, 1 },
{ 1, 0, 1, 1, 1 },
{ 1, 1, 1, 1, 1 },
{ 1, 1, 1, 0, 1 },
{ 1, 1, 1, 1, 1 }};
change(arr);
return 0;
}
No, the algo will not change. When updating place 1 in place with 0.
- Aashish June 30, 2012
What if one word doesn't fit into memory at a time?
- Aashish July 05, 2012