now its clear.. thank you..
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more
@Nikhil
I am clear with your first 2 algos but not with the change u introduced ie.,
adding a check. please give a working example
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@Divya :
Does the algo you gave work for the set { 6,5,9,111} ?
I hope it doesnt... Correct me if i am wrong
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe
You have an abstract computer, so just forget everything you know
about computers, this one only does what I'm about to tell you it
does. You can use as many variables as you need, there are no
negative
numbers, all numbers are integers. You do not know the size of the
integers, they could be
Ternary operator- x? y : z
Implement it in a function: int cond(int x, int y, int z); using only
~, !, ^, , +, |, , no if statements, or loops or anything else,
just those operators, and the function should correctly return y or z
based on the value of x. You may use constants, but only 8 bit
XOR has the following problem...
assume array is 2,3,3,2,1,2
here the unique element is 1 but using XOR we get
2^3^3^2^1^2=3
XOR works only when all the elements except the unique element occur even
number of times.
--
You received this message because you are subscribed to the Google
sort the input and then compare each element i with its adjacent neighbors
ie., i-1 and i+1 if both are different then that element is the unique
one...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
try this one..
make a level order traversal and store the elements in array... on the other
system reconstruct it using right element for the left and left element for
the right...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
In the first post the problem was that m_speed is not public also u should
access m_speed using Scope resolution operator as m_speed is not a member of
B.
class A
{
public:
virtual int speed()=0;
int m_speed;
};
class B:public A
{
public:
int speed()
{
return A::m_speed;
}
};
For ur second
For the 1st qn..
the o/p will print the code in the file and then print an infinite sequence
of empty spaces. the reason is...
In C EOF is defined to hold a value -1 which when assigned to unsigned
becomes 255. So it goes in an unending loop even after encountering the end
of file.
In second qn..
I missed out the condition that it should never be negative... Sorry for the
comment... Thanks for correcting...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe
I hope using a backtracking solution suits the problem well...
maxsum( int arr[] , int n,int i,int sum, int last)
{
if(in)
{
int s1= 0,s2= 0,s3;
if(last ==i-1)
{
s1=maxsum(arr,n,i+2,sum,last);
}
else
{
s2= maxsum(arr,n,i+1,sum+arr[i],i);
I hope u can do better... try this..
use a hash table and try inserting all elements of 1st list and then
insert the elements of second list. if u find an element already
existing when u insert from second list then add it to a new list. the
new list has the common elements...
--
You received
The increment and decrement method wont work correctly for all
cases
Ex:-
))a+b((
This is not a well formed parenthesis... But satisfies the algorithm.
The better way is to use a stack... When u find a ' ( ' push it into
the stack and when u find a ' )' pop off the top element. Finally the
14 matches
Mail list logo