[algogeeks] Re: 2D arrays

2007-01-24 Thread aakash mandhar
for(int i=0;i<=n/2;i++) { for(int j=0;j<=i;j++) { a[i][j]=='*'; } for(int j=i+1;j wrote: > > > OK, I need to write an algorithm to populate a 2D array A(i,j) of size > n x n. There is 1 '*' in the 1st row, increasing to n/2 in the middle > row, this decreases back to 1'*' in the last row. We can a

[algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread luhong
You got it, praveen. On Jan 24, 7:07 pm, "praveen Jain" <[EMAIL PROTECTED]> wrote: > sorry my previous mail was incomplete > > according to my thinking this could be the solution. > take the summation of both the element and compare it with either of the > element if it is more then overflow won'

[algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread praveen Jain
sorry my previous mail was incomplete according to my thinking this could be the solution. take the summation of both the element and compare it with either of the element if it is more then overflow won't happen. if it is less it means oveflow has happened. Regards Praveen On 1/25/07, pravee

[algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread praveen Jain
hi abid , I think this could be the solution. if u take the summation of both the element and co On 1/24/07, Abid <[EMAIL PROTECTED]> wrote: > > > This is an interview question. > What is the simples way to check if the sum of two unsigned integers > has resulted in an overflow. ? >

[algogeeks] Re: Fwd: [algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread Lego Haryanto
Well, consider the max unsigned value is MAX. *if MAX-A > B then print "A + B will overflow."* The trick is scalable to detecting multiplication overflow as well. *if MAX/A > B then print "A x B will overflow."* -Lego On 1/24/07, Ming (Amos) Zhang <[EMAIL PROTECTED]> wrote: > > This is not co

[algogeeks] Re: Fwd: [algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread Ming \(Amos\) Zhang
This is not correct. Given unsigned char A=255, B=1; A+B overflows, but ur alg fail to detect it. _ From: algogeeks@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Santhosh Suresh Sent: Wednesday, January 24, 2007 8:02 AM To: algogeeks@googlegroups.com Subject: [algogee

[algogeeks] Re: 2D arrays

2007-01-24 Thread delboy
OK, I need to write an algorithm to populate a 2D array A(i,j) of size n x n. There is 1 '*' in the 1st row, increasing to n/2 in the middle row, this decreases back to 1'*' in the last row. We can also assume that n is odd. *-- **- ***--- -- *- -- ***-

[algogeeks] Re: 2D arrays

2007-01-24 Thread Sandesh
Not clear, give the full explanation . Sandesh Hegde On Jan 24, 8:32 pm, "delboy" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to input the following values into a 2D array via some sort > of method / algorithm. Any ideas on the best way to approach this? > > *-- >

[algogeeks] Re: 2D arrays

2007-01-24 Thread delboy
Hi, I'm trying to input the following values into a 2D array via some sort of method / algorithm. Any ideas on the best way to approach this? *-- **- ***--- -- *- -- ***--- **- *-- Thanks, Del --~--~-~--~~

[algogeeks] Fwd: [algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread Santhosh Suresh
say, given the limit of the unsigned as k bits. Find log to base 2^k. If it's one in both, it'll result in an overflow. -- Forwarded message -- From: aravind kumar <[EMAIL PROTECTED]> Date: Jan 24, 2007 7:10 PM Subject: [algogeeks] Re: the sum of two unsigned integers To: algogeeks

[algogeeks] Re: the sum of two unsigned integers

2007-01-24 Thread aravind kumar
check if the sum is less than any of the two numbers that means the sum resulted in a overflow. On 1/24/07, Abid <[EMAIL PROTECTED]> wrote: > > > This is an interview question. > What is the simples way to check if the sum of two unsigned integers > has resulted in an overflow. ? > > > > > -- R

[algogeeks] the sum of two unsigned integers

2007-01-24 Thread Abid
This is an interview question. What is the simples way to check if the sum of two unsigned integers has resulted in an overflow. ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to

[algogeeks] Re: need help regarding problem..

2007-01-24 Thread mukesh tiwari
Hi Minhaz thnkx for help and pointing me to my mistake but now one thing i know ... is the number of points in the input will be distinct or there may be some duplicate point . like suppose the input is like this... 9 0 1 0 2 1 2 1 3 2 3 3 3 3 0 1 0 1 1 now the output of this program will (0 1)

[algogeeks] Re: need help regarding problem..

2007-01-24 Thread mukesh tiwari
Hi Minhaz thnkx for help and pointing me to my mistake but now one thing i know ... is the number of points in the input will be distinct or there may be some duplicate point . like suppose the input is like this... 9 0 1 0 2 1 2 1 3 2 3 3 3 3 0 1 0 1 1 now the output of this program will (0 1