ya guys m sorry actually swap code within the function is working ryt and
swap code wasnt working ryt.. i did misunderstood sumthing..
@sandeep sir: thanku sir :)
On Thu, Jul 14, 2011 at 11:26 AM, Sandeep Jain sandeep6...@gmail.comwrote:
Your swap function is not correct. You are swapping p q
@shiv here we go
to find 2nd best player in array
Tournament tree is a form of min (max) heap which is a complete binary
tree. Every external node represents a player and internal node
represents winner. In a tournament tree every internal node contains
winner and every leaf node contains one
hi friends,
i have a doubt about this code. what will be its output and how.
int a=35,*b;
b=a;
++*b=++*b;
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
compilation error lvalue required
coz on lhs of ++*b=++*b is not a variable but a value
On Thu, Jul 14, 2011 at 11:58 AM, abhishek kumar
mailatabhishekgu...@gmail.com wrote:
hi friends,
i have a doubt about this code. what will be its output and how.
int a=35,*b;
b=a;
++*b=++*b;
--
@Nicks
*Problem 1*
%d is used to take a signed integer as input. To take a short integer as
input, use %hi. That way, you would get the correct answer as 2.
*Problem 2:*
a:1 means that variable a is of width *1 bit*
Similarly, b:2 means that b is of width *2 bits*
b = 6 sets the two bits as 10,
@sandeep
+1 for your answer of question 2 :)
On Tue, Jul 12, 2011 at 8:57 AM, Sandeep Jain sandeep6...@gmail.com wrote:
I'll put it in simple words, when printf is executed, it expects the
arguments to be of the same type and in the same order as they appear in the
format string.
Otherwise,
1st problem
format specifier is %d whereas memory is allocated only for short int
memory allocated-2bytes. but being stored in 4bytes.
so a is overwritten by b.
In dis case where u give a=1, b=1, a becomes become 0.
n so it gives:0+1=1
in d scanf if u use %hd instead u ll get d right output!!
@atul i think there is some problem with this code it is showing same
output for every input
On Thu, Jul 14, 2011 at 11:17 AM, kranthi kumar damarlakran...@gmail.comwrote:
@shilpa.. Can u tell me wat's the output for 4..?
--
Regards:
---
D Kranthi kumar
@kranthi.{} {} {} {}
{{}} {{}}
{{{}}} {}
{} {{{}}}
as according to sequence i think ..if it should be some thing else
than than tell me
On Thu, Jul 14, 2011 at 12:23 PM, shilpa gupta shilpagupta...@gmail.comwrote:
@atul i
Can any one please post the questions they faced during Amazon campus
recruitment both online test and the interview rounds??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To
@Nicks
*Problem 1*
%d is used to take a signed integer as input. To take a short integer as
input, use %hi. That way, you would get the correct answer as 2.
*Problem 2:*
a:1 means that variable a is of width *1 bit*
Similarly, b:2 means that b is of width *2 bits*
b = 6 sets the two bits as 10,
its failing for 9*12 with n=7, if i take max square considered of hcf(9,12),
left space is 6*6 and 3*3.
i'll have more left space than what i consider three 4*4 squares, four 1*1
squares. leftspace is 1*5.
i think needs different trick
surender
On Mon, Jul 11, 2011 at 9:59 PM, Yogesh Yadav
@nicks ---solving 295c questions .good dude..
On Thu, Jul 14, 2011 at 8:01 AM, nicks crazy.logic.k...@gmail.com wrote:
Hey Guys, plz help me in getting these 2 C output problems
*PROBLEM 1.*
*
*
*#*includestdio.h
int main()
{
short int a,b,c;
scanf(%d%d,a,b);
c=a+b;
Hope this blog helps a little:
http://amazon-interview-questions.blogspot.com/
On Thu, Jul 14, 2011 at 12:36 PM, sinhanurag sinhanu...@hotmail.com wrote:
Can any one please post the questions they faced during Amazon campus
recruitment both online test and the interview rounds??
--
You
I was going through this question : Printing Neatly (15.2, Cormen)
Consider the problem of neatly printing a paragraph on a printer. The input
text is a sequence of n words of lengths l1, l2, . . . , ln, measured in
characters. We want to print this paragraph neatly on a number of lines that
@Anika
The code executes just all right.
@Abhishek
This is related to one of those irritating issues about precedence of
operators.
++ and * have the same precedence and have right-to-left associativity. So
your expression reads as
++(*b) = ++(*b)
RHS evaluates to 36 which gets stored in (*b)
Err.. I think the question must be to print all the balanced
parenthesizations given a number n. As the total number of
balanced parentheses are given by Catalan Numbers, I think the answer for 3
must be ((())) ()(()) ()()() (())() (()()) for a total of 5.
If not can you please
I think Nitish is right. The output shoud be as mentioned by Nitish.
And the code for that
#includestdio.h
int n;
void f(int *,int,int,int);
int main()
{
scanf(%d,n);
int arr[n];
f(arr,0,0,0);
getchar();
getchar();
return 0;
}
void f(int arr[], int open, int close, int
I just read that had the cost of a line be defined as just the number of
extra spaces and not as the cube of the number of extra spaces, then the
greedy approach I mentioned in the above post, can anybody explain why not
in the first case?
--
You received this message because you are
Just replace the 1's with { and 0's with }
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/H1GtxuX8Zq4J.
To post to this group, send email to
// File Handling
#includestdio.h
#includestdlib.h
int main()
{
unsigned char ch; // I think there is problem somewhere in this
line ! Help !!
FILE *fp;
fp = fopen(abc,r);
if(fp==NULL)
{
printf(Unable to Open);
exit(1);
}
while((ch = getc(fp)!=EOF))
printf(%c,ch);
fclose(fp);
then the version of spoj compiler for d must be belonging to an entirely
different world.I have solved a few problems using D and it had entirely
different syntax
On Thu, Jul 14, 2011 at 9:39 AM, shilpa gupta shilpagupta...@gmail.comwrote:
if you have any doubt than run it i have done
i think i should be like this
while((c=fgetc(fp))!=EOF) and not getc
On Thu, Jul 14, 2011 at 2:41 PM, rShetty rajeevr...@gmail.com wrote:
// File Handling
#includestdio.h
#includestdlib.h
int main()
{
unsigned char ch; // I think there is problem somewhere in this
line ! Help !!
FILE
@sunny iam asking minimum no of comaparisons.
On Jul 14, 10:22 am, sunny agrawal sunny816.i...@gmail.com wrote:
n+lgn-2 no of comparisions will do
On Thu, Jul 14, 2011 at 10:19 AM, shiv narayan
narayan.shiv...@gmail.comwrote:
Describe an optimal algorithm to find the second minimum
ignore anything i wrote above.I am an idiot anyway.
On Thu, Jul 14, 2011 at 2:42 PM, saurabh singh saurab...@gmail.com wrote:
then the version of spoj compiler for d must be belonging to an entirely
different world.I have solved a few problems using D and it had entirely
different syntax
yeah i just figured it out
On Thu, Jul 14, 2011 at 2:47 PM, rajeev bharshetty rajeevr...@gmail.comwrote:
@Aniket Its getc itself !!
On Thu, Jul 14, 2011 at 2:45 PM, Aniket Dutta aniketdutt...@gmail.comwrote:
i think i should be like this
while((c=fgetc(fp))!=EOF) and not getc
On Thu,
Yes, Sunny mentioned just the right number of comparisons required. Read the
tournament method to find the second largest or second smallest number in
your case.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the
@Abhi
Have a look at this.
http://codepad.org/zMV45iFY
On Thu, Jul 14, 2011 at 2:26 PM, Abhi abhi123khat...@gmail.com wrote:
@gaurav jain:
http://ideone.com/mRS9N
lvalue is required as LHS of assignment operator is a constant 'value'.
--
You received this message because you are
@sunny how did you arrive at the bit wise operation thing1
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
addtion to previous post while((ch=getc(fp))!=EOF) then 2 case will occur
On Thu, Jul 14, 2011 at 3:16 PM, Aniket Dutta aniketdutt...@gmail.comwrote:
2. the value of EOF is an integer which equals -1 (0x)
and not 0xff becoz this is a valid Ascii character
for this reason of
2. the value of EOF is an integer which equals -1 (0x)
and not 0xff becoz this is a valid Ascii character
for this reason of tructation the while loop will always be true.
On Thu, Jul 14, 2011 at 3:13 PM, Aniket Dutta aniketdutt...@gmail.comwrote:
1. in ur program it will
by what least no. 675 be multiplied to obtain a no. which is a perfect cube?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
#includeiostream
using namespace std;
int main(void)
{
int a=10 ,b=4;
int c=a;
cout\n-a;
a+=20;
cout\n-c;
a=4;
b=999; // :P
cout\n-c;
c=999;
cout\n-b;
cin.get();
return 0;
}
On
dis s just becoz u ve declared as unsigned char(i.e.) EOF valu is -1 and the
range of ch will be form 0 to 255...so -1 is never reached...dis is
error...if i'm wrong correct me...
//BE COOL// kavi
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
its 5
On Thu, Jul 14, 2011 at 3:38 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
5
On Thu, Jul 14, 2011 at 3:28 PM, anshul mehta
monsteranshul...@gmail.comwrote:
by what least no. 675 be multiplied to obtain a no. which is a perfect
cube?
--
You received this message because you
oh common take HASH of the image whuch need less space compare to
original one
:)
On Wed, Jul 13, 2011 at 1:01 AM, DK divyekap...@gmail.com wrote:
@Santosh: It depends on the type of the image. An image cannot be
represented in a (lossy) compressed format using fourier or wavelet
3
625/3=225 =15*15
On Thu, Jul 14, 2011 at 3:44 PM, shilpa gupta shilpagupta...@gmail.comwrote:
its 5
On Thu, Jul 14, 2011 at 3:38 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
5
On Thu, Jul 14, 2011 at 3:28 PM, anshul mehta monsteranshul...@gmail.com
wrote:
by what least no. 675
On Thu, Jul 14, 2011 at 3:52 PM, bagaria.ka...@gmail.com
bagaria.ka...@gmail.com wrote:
3
625/3=225 =15*15
sorry i divided question was multipied
On Thu, Jul 14, 2011 at 3:44 PM, shilpa gupta shilpagupta...@gmail.comwrote:
its 5
On Thu, Jul 14, 2011 at 3:38 PM, Piyush Sinha
i think he asked for cubenot square and btw if we can divide by
something then smallest no will b 1/675. by multiplying this we will get 1
which is cube of itself...
On Thu, Jul 14, 2011 at 3:52 PM, bagaria.ka...@gmail.com
bagaria.ka...@gmail.com wrote:
3
625/3=225 =15*15
On Thu, Jul
@ all
This code is error in C as pre-increment operator in C returns rvalue but it
will work fine in C++ as it returns lvalue in C++ which is required as LHS
of assignment operator
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this
ya i too think de same...
//BE COOL// kavi
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Yup...
*In C++*
Pre-Increment Pre-Decrement return LValue
Post-Increment Post-Decrement return RValue
*In C*
Pre-Increment Pre-Decrement return RValue
Post-Increment Post-Decrement return RValue
Regards,
Sandeep Jain
On Thu, Jul 14, 2011 at 4:08 PM, T3rminal piyush@gmail.com wrote:
thank fr ur help reynald
On Jul 14, 12:41 pm, Reynald Suz reynaldsus...@gmail.com wrote:
Hope this blog helps a little:http://amazon-interview-questions.blogspot.com/
On Thu, Jul 14, 2011 at 12:36 PM, sinhanurag sinhanu...@hotmail.com wrote:
Can any one please post the questions they faced
ya i have posted na just nw i m sorry tht i misunderstood it.. swap code
within the func is working ryt n swap func itself is working wrong..
On Thu, Jul 14, 2011 at 4:20 PM, kavitha nk kavithan...@gmail.com wrote:
ya i too think de same...
//BE COOL// kavi
--
You received this
Hey guys , is amazon conducting online test for SDE post?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
thnx all...i got it :)
On Thu, Jul 14, 2011 at 2:13 AM, Anika Jain anika.jai...@gmail.com wrote:
As in base 10 we say 552.5 is same as 5.525 *10^2 , here 2 is the exponent
of base 10.. so similarly in binary nos. for base 2 here if i make
101.00110011.. to 1.0100110011.. *2^2 my exponent
where is the link man
On Thu, Jul 14, 2011 at 5:28 PM, mohit mohit89m...@gmail.com wrote:
Hey guys , is amazon conducting online test for SDE post?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
I've been using Google Talk and thought you might like to try it out.
We can use it to call each other for free over the internet. Here's an
invitation to download Google Talk. Give it a try!
---
Aniket Dutta wants to stay in
i extend anurag's idea, instead of using an extra array,use map with keys
(k-ai , ai). while traversing through a, check if element found in map. if
found print pairs else add entry in map.
surender
2011/7/12 ●αηυяαg ∩ ℓιƒє ≈ Φ anuragmsi...@gmail.com
In order traversal results in a sorted list
Sending a test mail after re-joining the group. Please ignore.
--
Regards,
Navneet
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
successfully ignored :P
On Thu, Jul 14, 2011 at 6:57 AM, Navneet Gupta navneetn...@gmail.com wrote:
Sending a test mail after re-joining the group. Please ignore.
--
Regards,
Navneet
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
It worked fine on sorted input.
On Wed, Jul 13, 2011 at 5:46 AM, Navneet Gupta navneetn...@gmail.com wrote:
OOPS..Bad miss :(
On Tue, Jul 12, 2011 at 11:53 PM, sunny agrawal sunny816.i...@gmail.com
wrote:
Algorithm in the paper says works only on sorted arrays
it is mentioned in the
OR
10
/ \
5 15
/ \/ \
@Dave: You said *a ^= *b ^= *a ^= *b violates the sequence point rule
in swap(). But it's the same as in main function. Why doesn't it
violates the rule in main() ?
On Jul 13, 1:30 am, Don dondod...@gmail.com wrote:
To make it into valid code, break it into three operations:
void swap(int *a,
We are given n by n boolean matrix ( n = 20). Output of matrix should
be such that every row and every column should have only one true
value ( true=1, false=0). Input matrix can have any number of 1's and
there will be no row or column having all zero values. Example: let
n=4
Input Matrix:
1 0 1
Will a Back-tracking solution suffice..??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
if we have to find out no of possible outputs ...then we can do this
for(i=1;i=n;i++)
{
ans=ans * no of 1s in ith row
return(ans);
}
On Thu, Jul 14, 2011 at 11:46 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote:
Will a Back-tracking solution suffice..??
--
You received this message
It can be done in O(2^n)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options,
@Shilpa:
following your proposed algorithm answer to input matrix:
1 1 1
1 1 1
1 1 1
should be 27
but correct answer would be 6. It's an easy task to check out all
possible 6 states manually.
If you find the seventh way please post it.
On Jul 14, 11:31 pm, Rishabh Maurya poofiefoo...@gmail.com
#includeiostream
#includevector
#includecstring
using namespace std;
bool mark[20];
vectorint v[20];
int count=0,n;
void solve(int row)
{
if(row==n)count++;
else
for(int i=0;iv[row].size();i++)
{
if(!mark[v[row][i]])
{
#includestdio.h
#includestdlib.h
struct node
{
int data;
struct node *left;
struct node *right;
}*root=NULL;
main()
{
root=(struct node *)malloc(sizeof(struct node));
root-data=10;
root-left=NULL;
root-right=NULL;
شكرا للقبول بالانظمام اليكم مع تحياتي
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For
the expression *root causes the structure to be printed,which
prints,(root-data=),10,(root-left=)0,(root-right)=0
and then the last value is (root-data),other remaining values are ignored
On Fri, Jul 15, 2011 at 12:16 AM, sagar pareek sagarpar...@gmail.comwrote:
#includestdio.h
@Tendua: It does. The result of erroneous code is undefined. It might
work as the coder intended, or it might do something else entirely. It
might even do the intended thing in some cases but fail in others in
the same source file.
Dave
On Jul 14, 12:51 pm, tendua 6fae1ce6347...@gmail.com wrote:
Change the printf statement to :
printf(root-%x--root--%x--(root-data)=%x--(root-left)=%x--(root--right)=%x--*root--%d,root,root,(root-data),(root-left),(root-right),*root);
Actually printf behaves unexpectedly when we use %d before %x in the
same printf statement.
root and (root-data) will
banned
2011/7/15 المصلاوي salimali...@gmail.com
شكرا للقبول بالانظمام اليكم مع تحياتي
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send
#includestdio.h
int main()
{
char str[] = Zingle Bell Zingle Bell;
printf(%.#s %.2s\n,str,str);
return 0;
}
I need the help to figure out the output of the program and please
expalin the behaviour of the printf statement here ?
--
You received this message because you are subscribed to the
yx - xy = x0y - yx
= (10y + x) - (10x + y) = (100x + y) - (10y + x)
9y - 9x = 99x - 9y
18y = 108x
y=6x
Since, x comes in hundreds place, we know it can only be 1 as the difference
between the 3 digit number and two digit number is difference of two 2 digit
numbers only.
thus, y=6*1 = 6
a
I think u should have read the translated version first..
what he meant was: Thank you for your acceptance to join you, Regards
should warn him though..
Regards,
Priyanshu Gupta
2011/7/14 shady sinv...@gmail.com
banned
2011/7/15 المصلاوي salimali...@gmail.com
شكرا للقبول بالانظمام
1)
getchar must be a function in that case . Check /usr/include/stdio.h . It
must have contained an extern definition (it is on my machine).
2)
Machines generally have separate registers for floating point values(let say
%fr). While executing this line *printf(%d\n,t); *that register is loaded
@Sagar: And how would you resolve hash collisions?
--
DK
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/wmjP3AkyfocJ.
To post to this group, send email to
@tendua.ya i was wrong i got it...
2011/7/15 ●αηυяαg ∩ ℓιƒє ≈ Φ anuragmsi...@gmail.com
#includeiostream
#includevector
#includecstring
using namespace std;
bool mark[20];
vectorint v[20];
int count=0,n;
void solve(int row)
{
if(row==n)count++;
else
you can't expect me to translate mails from people, anyway i have unbanned
him/her. :)
Please use English to communicate, and no SMS language as seen in many posts
my people.
2011/7/15 Priyanshu priyanshuro...@gmail.com
I think u should have read the translated version first..
what he meant
@Gaurav Jain
in turbo c++,(this was a c program).
it is giving output 36.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/uuO64oNqACMJ.
To post to this
@ALL: Turbo C is one of the most pathetic compilers I've seen. It has
tremendous skills to ruin your concepts.
Regards,
Sandeep Jain
On Fri, Jul 15, 2011 at 10:35 AM, abhishek kumar
mailatabhishekgu...@gmail.com wrote:
@Gaurav Jain
in turbo c++,(this was a c program).
it is giving
@Gaurav Jain
but in Turbo C++ (as a c++ program)
it is giving output a=36.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/ORNJxARkBIoJ.
To post to this
@Sandeep Jain
sandeep, please be more clear about lvalue rvalue assignment.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/42bIvZNRPRYJ.
To post to this
77 matches
Mail list logo