You are given two integers n and k
k signifies number of set bits i.e. if k = 3 then output should have 3
set bits.
Output should be the nth smallest number having k set bits
for example
k=1 and n=3
output should be
4 (0100)
--
You received this message because you are subscribed to the
write a C program to create a bitmap of any size as determined by user. Say
user says 64k bitmap, then create 64k long bitmap. Have set and unset
methods
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Here is my approach :
int main()
{
int a=1,k=1,n=3;
while(k1)
{
k--;
a=(a1) | 1;
}
while(n1)
{
a=a1;
n--;
}
printf(%d,a);
return 0;
}
On Sat, Jul 9, 2011 at 11:14 PM, anurag anurag19aggar...@gmail.com wrote:
You are given two
6,24,60,120,210,336..
(N^3 - N) where N=2,3,4
--
Regards
UDIT
DU- MCA
--
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
or it can be
2^3-2=6
3^3-3=24
4^3-4=60
5^3-5=120
6^3-6=210...
On Sun, Jul 10, 2011 at 9:35 AM, Abhishek Soni ab.abhish...@gmail.comwrote:
6,24,60,120,210,336..
Explaination:
0 + (6*1) = 6,
6 + (6*3) = 24,
24+ (6*6) = 60,
60+ (6*10) = 120,
120 + (6*15) = 210,
210 + (6*21) = 336,...
A[n] = n*(n+1)*(n+2)
1*2*3 = 6
2*3*4 = 24
3*4*5 = 60
4*5*6 = 120
so next numbers are 210,336
--
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,
Hi,
this is the code i came up with..
#includestdio.h
#includeconio.h
int doMyWork(int k,int n);
int main()
{
int k,n,nth_number;
printf(\nEnter k and n\n);
scanf(%d%d,k,n);
nth_number=doMyWork(k,n);
printf(\nThe nth number is %d\n,nth_number);
getch();
Try this
1. Find the min and max in O(n) time.
2. For A.P. = mix to max/N , we find max possible subsequence.
For example
1,2,3,0,4,7,19,6,8,10,24.(could be more but trying to show the approach)
We see min = 1 and max = 8 hence we need to try for diff = 1 to 8/size(arr)
In this case, we
Sorry typo below
On Sun, Jul 10, 2011 at 12:49 PM, Navneet Gupta navneetn...@gmail.comwrote:
Try this
1. Find the min and max in O(n) time.
2. For A.P. = mix to max/N , we find max possible subsequence.
For example
1,2,3,0,4,7,19,6,8,10,24.(could be more but trying to show
the
n*n! = (n+1)! - 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, visit
sorry ankit... ur solution works only for.. k=1 and n=3...
try for k=2 and n=6.. then the output should be 12...
similarly for k=3 n=1.. the output should be...7...
so plz correct ur code..
On Sun, Jul 10, 2011 at 12:38 PM, ankit sambyal ankitsamb...@gmail.comwrote:
Here is my approach :
int
For,
[ n*n!+(n+1)*(n+1)!+.+(n+m)*(n+m)! ] / (n+m+1)! = 1 - n!/(n+m+1)!
On Sun, Jul 10, 2011 at 1:00 PM, Puneet Ginoria punnu.gino...@gmail.comwrote:
n*n! = (n+1)! - n!
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
how about this?
take pointer p1 set to end of array A and pointer p2 set to end of
array B.
while(you get n values)
{
print A(p1),B(p2)
now if( A(p1-1)+B(p2)A(p1)+B(p2-1) ) then print A(p1-1),B(p2)
followed by print A(p1),B(p2-1)
decrement p2 and p1 both
}
m i missing something?
On Jul 9,
Sunny
Don.t you think your method is very slow as you are checking every number
that for number of set bits and if it is a equal to desired than you are
decreasing n i.e. required number.
Even if when n=1 and k=32 your solution will start with 0 and go up to 2^31
but the answer could be found in
Smallest Number with k bits set will be the number with least significant k
bits set
ie. K=3 000111
K=4 000
and to find nth
we can use thishttp://groups.google.com/group/algogeeks/msg/2b64c4f96fa3598e
TC: O(n)
On Sun, Jul 10, 2011 at 2:13 PM, Sunny T sunny.1...@gmail.com wrote:
thanks sunny
On Sun, Jul 10, 2011 at 2:19 PM, sunny agrawal sunny816.i...@gmail.comwrote:
Smallest Number with k bits set will be the number with least significant k
bits set
ie. K=3 000111
K=4 000
and to find nth
we can use
#includestdio.h
void main(){
signed x;
unsigned y;
x = 10 +- 10u + 10u +- 10;
y = x;
if(x==y)
printf(%d %d,x,y);
else if(x!=y)
printf(%u %u,x,y);
}
OUTPUT?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
X and Y are equal and both are zeroes
So the output is 0 0
On Sun, Jul 10, 2011 at 3:03 PM, radha krishnan
radhakrishnance...@gmail.com wrote:
#includestdio.h
void main(){
signed x;
unsigned y;
x = 10 +- 10u + 10u +- 10;
y = x;
if(x==y)
printf(%d %d,x,y);
else
@Anurag: See
http://groups.google.com/group/algogeeks/msg/d90353c759125384?hl=en.
Dave
On Jul 10, 1:14 am, anurag anurag19aggar...@gmail.com wrote:
You are given two integers n and k
k signifies number of set bits i.e. if k = 3 then output should have 3
set bits.
Output should be the nth
For the code, here u go
http://ideone.com/js1yV
On Wed, Jun 29, 2011 at 10:49 AM, Dave dave_and_da...@juno.com wrote:
@Sanket: You are wrong. Let T(n) be the time to solve the problem of
size n. Then T(n) satisfies a recurrence T(n) = n + T(n/2). That is
because after you have done n reads,
array a[] stores numbers
for(i=1;in;i++)
{
diff[i-1]=a[i]-a[i-1];
}
maxcount=1;
tempcount=1;
for(j=1;jn-1;j++)
{
if(diff[j]==diff[j-1])
tempcount++;
else
{
if(tempcountmaxcount)
maxcount=tempcount;
tempcount=1;
}
}
On Sat, Jul 9, 2011
Thats wonderful para :)
On Sat, Jul 9, 2011 at 10:50 AM, John Hayes agressiveha...@gmail.comwrote:
refer KRit's clearly mentioned in it
On Sun, Jul 10, 2011 at 12:12 AM, parag khanna
khanna.para...@gmail.comwrote:
no text substitution occurs if the identifier is within the quotes
Thats wonderful parag :)
On Sun, Jul 10, 2011 at 4:56 AM, Yogesh Yadav medu...@gmail.com wrote:
Thats wonderful para :)
On Sat, Jul 9, 2011 at 10:50 AM, John Hayes agressiveha...@gmail.comwrote:
refer KRit's clearly mentioned in it
On Sun, Jul 10, 2011 at 12:12 AM, parag khanna
good one Parag ...
On Sun, Jul 10, 2011 at 12:20 AM, John Hayes agressiveha...@gmail.comwrote:
refer KRit's clearly mentioned in it
On Sun, Jul 10, 2011 at 12:12 AM, parag khanna
khanna.para...@gmail.comwrote:
no text substitution occurs if the identifier is within the quotes
--
@yogesh- can u explain with an example pls?
--
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.
Can think of a O(n^2) solution
On Sun, Jul 10, 2011 at 6:53 PM, raj singh ankurkaku...@gmail.com wrote:
@yogesh- can u explain with an example pls?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@raj :
array a[]= 2,3,5,6,7,8,10,12
diff[]= 1,2,1,1,1,2,2
maxcount=tempcount=1 // because am not takin in consideration of 0th index
value of diff[]
now in for loop
for j=1
check diff[j]==diff[j-1] //not equal
so check tempcountmaxcount or not //its also not
so maxcount remains same
i thinks mine is just O(n)
On Sun, Jul 10, 2011 at 5:31 AM, Yogesh Yadav medu...@gmail.com wrote:
@raj :
array a[]= 2,3,5,6,7,8,10,12
diff[]= 1,2,1,1,1,2,2
maxcount=tempcount=1 // because am not takin in consideration of 0th
index value of diff[]
now in for loop
for j=1
check
@Yogesh
your solution will give maximum Contiguous AP only
it will fail for the array A[] = {1,2,3,4,5,6,8,10,12,14}
your algo will give output that there is an Longest AP of 6 elements which
is wrong
checkout this http://theory.cs.uiuc.edu/%7Ejeffe/pubs/pdf/arith.pdf for an
O(n^2) algorithm
On
@sunny: my algo will give 5 as answer and i guess its right... if am
wrong plz explain where and why my logic is wrong
On Sun, Jul 10, 2011 at 5:37 AM, sunny agrawal sunny816.i...@gmail.comwrote:
@Yogesh
your solution will give maximum Contiguous AP only
it will fail for the array A[] =
@sunny: my algo will give 5 as answer and i guess its right... if am
wrong plz explain where and why my logic is wrong
On Sun, Jul 10, 2011 at 5:37 AM, sunny agrawal sunny816.i...@gmail.comwrote:
@Yogesh
your solution will give maximum Contiguous AP only
it will fail for the array A[] =
@sunny: my algo will give 6 as answer and i guess its right... if am
wrong plz explain where and why my logic is wrong
On Sun, Jul 10, 2011 at 5:37 AM, sunny agrawal sunny816.i...@gmail.comwrote:
@Yogesh
your solution will give maximum Contiguous AP only
it will fail for the array A[] =
Longest AP for that Example is of 7 elements
2,4,6,8,10,12,14
now see your mistake ...
as i have already told you that u r looking for only contiguous AP's and
that won't work
On Sun, Jul 10, 2011 at 7:18 PM, Yogesh Yadav medu...@gmail.com wrote:
@sunny: my algo will give 6 as
@sunny : thanks ..i got it...
On Sun, Jul 10, 2011 at 5:55 AM, sunny agrawal sunny816.i...@gmail.comwrote:
Longest AP for that Example is of 7 elements
2,4,6,8,10,12,14
now see your mistake ...
as i have already told you that u r looking for only contiguous AP's and
that won't
yeah then it will be possible in O(n^2)
On Sun, Jul 10, 2011 at 5:57 AM, Yogesh Yadav medu...@gmail.com wrote:
@sunny : thanks ..i got it...
On Sun, Jul 10, 2011 at 5:55 AM, sunny agrawal sunny816.i...@gmail.comwrote:
Longest AP for that Example is of 7 elements
2,4,6,8,10,12,14
try Matrix search...
On Sun, Jul 10, 2011 at 7:34 PM, Yogesh Yadav medu...@gmail.com wrote:
yeah then it will be possible in O(n^2)
On Sun, Jul 10, 2011 at 5:57 AM, Yogesh Yadav medu...@gmail.com wrote:
@sunny : thanks ..i got it...
On Sun, Jul 10, 2011 at 5:55 AM, sunny agrawal
Step 1: first make a diff[][]
Step 2: search the diff in matrix
Complexity will be O(n^2)
On Sun, Jul 10, 2011 at 6:24 AM, JAIDEV YADAV jaid...@gmail.com wrote:
try Matrix search...
On Sun, Jul 10, 2011 at 7:34 PM, Yogesh Yadav medu...@gmail.com wrote:
yeah then it will be possible in
Write a code in C/C++ to find the largest BST sub-tree in a binary tree .
Eg:-
10
/ \
5 15
thanx
--
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, visit this
Given a rectangle with known width and height, design an algorithms to fill
the rectangle using n squares(n is integer, also given) and make sure in the
result the wasting area is minimized. Length of square doesn't have to be
integer.
I.e, given width=3,height=2,n=5, one solution is that
Thanks :)
On Sun, Jul 10, 2011 at 6:26 PM, JAIDEV YADAV jaid...@gmail.com wrote:
good one Parag ...
On Sun, Jul 10, 2011 at 12:20 AM, John Hayes agressiveha...@gmail.comwrote:
refer KRit's clearly mentioned in it
On Sun, Jul 10, 2011 at 12:12 AM, parag khanna
jaidev aur yogesh swaad na lo saalo ... padha tha maine ye kabhi isliye bta
diya
--
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
awesome parag... i hope you will keep contributing to the group
~~~ this thread ends here
On Sun, Jul 10, 2011 at 9:24 PM, parag khanna khanna.para...@gmail.comwrote:
jaidev aur yogesh swaad na lo saalo ... padha tha maine ye kabhi isliye bta
diya
--
You
wastage can be minimized if side of square is maximized.
so largest size of square would be = H.C.F of width and height .
and also number of squares needed will be = (width*height)/side^2 .
On Sun, Jul 10, 2011 at 9:11 PM, Akshata Sharma
akshatasharm...@gmail.comwrote:
Given a rectangle with
@vaibhav this fails as n will be provided in the question.
On Sun, Jul 10, 2011 at 9:56 PM, vaibhav shukla vaibhav200...@gmail.comwrote:
wastage can be minimized if side of square is maximized.
so largest size of square would be = H.C.F of width and height .
and also number of squares needed
with n=(height*width)/side^2 .. u can calculate the side if n would be
given.
On Sun, Jul 10, 2011 at 10:37 PM, vaibhav agarwal
vibhu.bitspil...@gmail.com wrote:
@vaibhav this fails as n will be provided in the question.
On Sun, Jul 10, 2011 at 9:56 PM, vaibhav shukla
Define Largest:
Total no of nodes in sub-tree
or
Height of sub-tree
On Sun, Jul 10, 2011 at 8:50 PM, Decipher ankurseth...@gmail.com wrote:
Write a code in C/C++ to find the largest BST sub-tree in a binary tree .
Eg:-
10
#includestdio.h
int main()
{
int i=0,j=1,k=1,z=0;
z = j || k i ;
printf(%d,z);
return 0;
}
The output is 1 for the above program .
But according to associativity of logical operators , the evaluation
should be from left to right , But is it taking from right to left ?
What is the exact
no of nodes
--
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/-/MuNISw2QkYIJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe
associativity comes into play when operators are of same precedence.
On Sun, Jul 10, 2011 at 11:08 PM, vaibhav shukla vaibhav200...@gmail.comwrote:
has higher precedence than ||
the expression is evaluated as
z=j || ( k i );
hence the output i.e 1 ;)
On Sun, Jul 10, 2011 at 11:06 PM,
@Sunny: Can you please explain that paper in simple english please?? Thoda
zyaada complex ho gaya hai.
O(N^3) DP is simple and understandable.
--
DK
http://twitter.com/divyekapoor
http://www.divye.in
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
can be done using some modification in postorder traversal
call to left subtree will return that if left subtree is a BST of not
call to right subtree will return that if right subtree is a BST of not
if both subtrees are BST's check for curr and return its status
2 additional pass by ref.
I donno if my idea is efficient.
I'll do a breath-first traversal and check IsBST on each node(modified
to also get the count of nodes)
So at each level, the largest BST is kept track of and end of the
level, the largest subtree can be returned.
If there is no BST at that level go down one level
Got it Thanks .
On Jul 10, 10:40 pm, vaibhav shukla vaibhav200...@gmail.com wrote:
associativity comes into play when operators are of same precedence.
On Sun, Jul 10, 2011 at 11:08 PM, vaibhav shukla
vaibhav200...@gmail.comwrote:
has higher precedence than ||
the
Never mind. Figured it out, though in possibly different from the paper.
Principle of optimality to the rescue! :)
O(n^2)
DP equations:
LAP[i, j] = Longest AP in range [i,j] of the sequence
LAP[0, j] = max{LAP[0, k] (for all k in range [0, j-1]) extended with a[j],1
(the element a[j] itself)}
Today I attended an interview.
Just wanna share a good Q.
Rows are represented using alphabets.
Example:
first row - 'A'
second row: 'B'
.
.
.
26th row : 'Z'
27th: 'AA'
.
.
Now given a number, we need to find the corresponding alphabet
representation.
Say Given 78
Answer should be BZ
Given 26
class a
{
int x;
public:
a()
{
}
a(int i){x=i;coutin a xendl;}
a(a obj){coutin copy cons of aendl;}
};
a obj1=14; //error no matching call to a::a(a)
why.
and just adding a const in the constructor saves me from error...but
how
--
use a(int arg)
{
x = arg;
}
ur call will work...:)
On Sun, Jul 10, 2011 at 11:46 PM, himanshu kansal
himanshukansal...@gmail.com wrote:
class a
{
int x;
public:
a()
{
}
a(int i){x=i;coutin a xendl;}
a(a obj){coutin copy cons of aendl;}
my badadd const in copy construcori think...that compiler expect...
On Sun, Jul 10, 2011 at 11:48 PM, rahul rahulr...@gmail.com wrote:
use a(int arg)
{
x = arg;
}
ur call will work...:)
On Sun, Jul 10, 2011 at 11:46 PM, himanshu kansal
himanshukansal...@gmail.com wrote:
a obj3(obj1);but this statement works fine.so it means it is calling
copy constt. perfectly...
On Sun, Jul 10, 2011 at 11:49 PM, rahul rahulr...@gmail.com wrote:
my badadd const in copy construcori think...that compiler expect...
On Sun, Jul 10, 2011 at 11:48 PM, rahul
The reason is... that when u write
a obj1=14;
it is same as writing a obj1 = a(14);
So first a temporary object is created using the constructor
a(int i)
And this temporary object is passed in the copy constructor. BUT since it is
temp object it must be referred by a const alias.
Regards,
thanku sir...sir 1 more thngcn u gv a link or some pdf for studying
virtual inheritance elaborating the vptr mechanism more clearly...
On Sun, Jul 10, 2011 at 11:56 PM, Sandeep Jain sandeep6...@gmail.comwrote:
The reason is... that when u write
a obj1=14;
it is same as writing a obj1 =
http://www.parashift.com/c++-faq-lite/virtual-functions.html
Its one of my favorite sites... :)
Regards,
Sandeep Jain
On Mon, Jul 11, 2011 at 12:02 AM, himanshu kansal
himanshukansal...@gmail.com wrote:
thanku sir...sir 1 more thngcn u gv a link or some pdf for studying
virtual
@Divye Sir
I just came to know this is not a general Algorithm
This works only for sorted Array
this is Some description about the algo in paper
this algo uses the property of a AP that for every 3 consecutive elements of
an AP(a1,a2,a3)
a1+a3 = 2*a2
*L[i j] stores the maximum length of an
Largest value is of course A(n) + B(n).
Second largest value is either A(n) + B(n-1) or A(n-1) + B(n).
Select the largest among both and continue down that array.
Maintain 2 pairs:
Pair 1: Hold first value constant, go down the second array. Pair 2: Hold
2nd value const. and go down the first
The answer is a simple encoding of the number in base 26.
There is no need to calculate anything else.
--
DK
http://twitter.com/divyekapoor
http://www.divye.in
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the
Someone please help me in understanding the following output -
Problem *1.*
#includestdio.h
#ifdef getchar //this expression is evaluated to zero.why is so
happening ??getchar is defined as macro in stdio.h.i mean else
part shouldn't be executed which is happening
#undef
Agreed.
On 11 Jul 2011 00:38, DK divyekap...@gmail.com wrote:
The answer is a simple encoding of the number in base 26.
There is no need to calculate anything else.
--
DK
http://twitter.com/divyekapoor
http://www.divye.in
--
You received this message because you are subscribed to the Google
*Problem 2:*
I think u are using TurboC, since you have written void main()
Secondly, printf (since based on macros) scans through the format string.
And the it process arguments one by one depending on the format specifiers
given in this string.
I've observed that whenever there is a mismatch
@DK sir
I was just assuming n^2 values as the 2D matrix..not creating
although i am using a O(n^2) space that keep track of which cell is already
in heap and need not be inserted againso initially all the need to
be initialized..that will make it O(n^2)
Now I have a Doubt - Is
for the first question...it will take #ifdef getchar to be '1' only when it
is defined as a MACRO in your program..if u dont define macro it will not
take it into consideration even if it is defined in header file.
On Mon, Jul 11, 2011 at 12:38 AM, nicks crazy.logic.k...@gmail.com wrote:
Hi,
Has anyone attended PeP (Particiaptory exam for palcement).Can
u give me some guidance..??
--
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
Sry it is Participatory exam for placement.
On Mon, Jul 11, 2011 at 1:16 AM, swetha rahul swetharahu...@gmail.comwrote:
Hi,
Has anyone attended PeP (Particiaptory exam for palcement).Can
u give me some guidance..??
--
You received this message because you are subscribed to the
probelm 5:It must be giving runtime error not segmentation fault coz it is
an infinite recursion
On Mon, Jul 11, 2011 at 1:09 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:
for the first question...it will take #ifdef getchar to be '1' only when it
is defined as a MACRO in your
@Sunny: We don't need ever to calculate generic L[i,j] as we can do this
problem by simply calculating L[0,j] which reduces the dimensionality of the
problem. Here's a modified solution on the same lines as the one originally
proposed. Version 2 uses hash table. Complexity is O(N^2) (if hash
These are the various ways to swap 2 variables
a) Using temporary Variable
b) Usnig some Arithmentic operation
c) Using bitwise XOR operation
Explain which operation is better and Why? What if we need to swap -ive as
well as floating point numbers also.
--
Regards,*
Aanchal Goyal*.
--
You
Well, technically, if you have to initialize O(N^2) space with *any*
value, then your algo is O(N^2).
In practice, memset is pretty fast, however, that just reduces the constant
factor - it will not (eventually) beat an O(N) algo.
BTW, my solution is O(N).
--
DK
http://twitter.com/divyekapoor
On Mon, Jul 11, 2011 at 1:51 AM, aanchal goyal goyal.aanch...@gmail.comwrote:
These are the various ways to swap 2 variables
a) Using temporary Variable
always inefficient. using extra memory.
b) Usnig some Arithmentic operation
works for all numbers even floating points
@Dave: Thanks for the link.
Just a point of discussion - this kind of code would probably never pass
code-review (or would be heavily documented with references and warnings
that say HANDS OFF ;) )
--
DK
http://twitter.com/divyekapoor
http://www.divye.in
--
You received this message because
@Vaibhav: Your method b doesn't work for floating point numbers
because they have finite precision. E.g.,as an extreme example, try it
on a = 1 and b = 1d-25. When you form a+b, the result is 1, not 1 +
1d-25. Then 1 - 1d-25 gives 1 (which is correct), and 1 - 1 = 0. The
latter should be 1d-25, so
@DK. Yes. But you must admit that it is a bit-twiddler's delight!
Dave
On Jul 10, 3:58 pm, DK divyekap...@gmail.com wrote:
@Dave: Thanks for the link.
Just a point of discussion - this kind of code would probably never pass
code-review (or would be heavily documented with references and
using a temp variable is considered to be the best option..
On 7/11/11, Dave dave_and_da...@juno.com wrote:
@Vaibhav: Your method b doesn't work for floating point numbers
because they have finite precision. E.g.,as an extreme example, try it
on a = 1 and b = 1d-25. When you form a+b, the
Quite new to java what do you think of mine?
import java.util.*;
public class RemoveDuplicates {
public static void main(String[] args){
while(true) {
System.out.println(Enter String);
Scanner input = new Scanner(System.in);
String str =
@sandeep,kamakshiithanks both...your replies were really helpfuli
understood my fault in 3,4,5...they are clea now..but i am still stuck
with problem 1 and 2
@sandeepwhat if i am using turbo C...though i am using gcc on terminal
in my linux system.
moreover acc. t KR printf
TurboC has many flaws, one of the simplest examples would be
char *p;
scanf(%s, p);
In gcc/g++ this will surely lead to segmentation fault as memory has not
been allocated. Whereas in TC it will execute fine in most of the cases.
Infact this will crash when your code is really large.
As for
@vigneshr, no your method is not that efficient since you will be calling
IsBST for a node many times in the process. It will be O(nlogn) assuming
complete Binary Tree, Sunny's algorithm runs in O(n) time.
On Sun, Jul 10, 2011 at 11:25 PM, vigneshr rvignesh1...@gmail.com wrote:
I donno if my
A = 0 1 4 5 9 11 20
B = 0 2 3 6 8 13 15
(20, 15) (20, 15) - (20,15)
(20,13) (11,15) - (20,13)
(20,8) (11,15) - (20,8)
(20,6) (11,15) - assume (20,6)
(20,3) (11,15) - (11,15)
(20,3) (9,15)-
On Mon, Jul 11, 2011 at 1:06 AM, sunny agrawal sunny816.i...@gmail.comwrote:
A = 0, 1, 4, 5, 9, 11, 20
B = 0, 2, 3, 6, 8, 13, 15
(20, 15) (20, 15) - (20,15)
(20,13) (11,15) - (20,13)
(20,8) (11,15) - (20,8)
(20,6) (11,15) - assume (20,6)
(20,3) (11,15) - (11,15)
(20,3) (9,15)- (9,15)
(20,3) (5,15)- (20,3) .problem (11,13) has higher
88 matches
Mail list logo