There are 3 baskets of fruits with worng lables,one basket
has apple,another basket has orange,another has combination
of apple and orange,what is the least way of interchange
the lables.
Answer Posted / anoop
Beside answer 3, following is one more alternative:
Let the 3 baskets with labels A,O,M.
Interchange labels of any 2 baskets. (assume that u
interchanged lables of A & O)
Now see (or take out) the fruits of either of the baskets
with changed labels (A & O).
There wud be 2 cases:
1. This basket(the one of which u saw (or took out) the
fruits) has fruits not conforming to the label.
2. This basket(the one of which u saw (or took out) the
fruits) has fruits conforming to the label.
If (1) is true,just interchange its label with the third
untouched basket (basket with label M).
If (2) is true, just interchange label of other basket with
the third untouched basket (basket with label M).
Idea is : Just one interchange of labels of any 2 basket
will fix one basket with correct label. In second step you
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What functions are used for dynamic memory allocation in c language?
Explain what is the benefit of using const for declaring constants?
while initialization of array why we use a[][2] why not a[2][]...?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
Is malloc memset faster than calloc?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
You have given 2 array. You need to find whether they will
create the same BST or not.
For example:
Array1:10 5 20 15 30
Array2:10 20 15 30 5
Result: True
Array1:10 5 20 15 30
Array2:10 15 20 30 5
Result: False
One Approach is Pretty Clear by creating BST O(nlogn) then
checking two tree for identical O(N) overall O(nlogn) ..we
need there exist O(N) Time & O(1) Space also without extra
space .Algorithm ??
DevoCoder
guest
Posted 3 months ago #
#define true 1
#define false 0
int check(int a1[],int a2[],int n1,int n2)
{
int i;
//n1 size of array a1[] and n2 size of a2[]
if(n1!=n2) return false;
//n1 and n2 must be same
for(i=0;i
What is preprocessor with example?
what is a function method?give example?
how we can make 3d venturing graphics on outer interface
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
Why do we need functions in c?
List some basic data types in c?
What is a union?
What is c standard library?