In regular expr, even a space is also a character. so u can exclude all
those spaces(stay in the same state if u encounter a space character) in a
word.
On Wed, Apr 4, 2012 at 5:05 PM, atul anand wrote:
> i am not sure , but wont x.trim() will remove extra spaces from the
> string...
>
>
> On We
i am not sure , but wont x.trim() will remove extra spaces from the
string...
On Wed, Apr 4, 2012 at 12:32 AM, Debabrata Das <
debabrata.barunhal...@gmail.com> wrote:
> Hi All,
>
> I was looking for an regular expression such that given a string X,it
> should exclude a token in single quote prec
Hi All,
I was looking for an regular expression such that given a string X,it
should exclude a token in single quote preceded by a particular
string.
e.g in java say.
String X=" 'abc ' like'abc ' ='abc'"
N.replaceall("reg expression" "??") would transform it to : ??
thnx buddy...according to algo c is the answer.
On Sat, Mar 17, 2012 at 8:42 PM, sunny agrawal wrote:
> C itself
>
> On Sat, Mar 17, 2012 at 8:39 PM, rahul sharma wrote:
>
>> in binary tree..
>> suppose c is parent of dnow if i want to find least common ancesor of
>> c and dwhther it is p
C itself
On Sat, Mar 17, 2012 at 8:39 PM, rahul sharma wrote:
> in binary tree..
> suppose c is parent of dnow if i want to find least common ancesor of
> c and dwhther it is parent of c or c itself
>
> --
> You received this message because you are subscribed to the Google Groups
> "
in binary tree..
suppose c is parent of dnow if i want to find least common ancesor of c
and dwhther it is parent of c or c itself
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@goog
@moheed i got it.
@Dave...Thnx a lot..i got it all now...
On Sat, Mar 10, 2012 at 5:56 PM, Moheed Moheed Ahmad wrote:
> @Rahul:
> As Dev said:
> Now start the fast pointer at the head and take m single steps with both
> pointers. The fast pointer is at the beginning of the cycle, and the slow
>
@Rahul:
As Dev said:
Now start the fast pointer at the head and take m single steps with both
pointers. The fast pointer is at the beginning of the cycle, and the slow
pointer has traversed the cycle (2*t - u) times and is back at the
beginning of the cycle.
k= (2*t-u)p -m
When fast pointer is b
1-2-3-4-5-6-7-8-9-10-11
fast and slow meet at 11
m=6;
k=4
...i cant get last two lineswhen k= sometimes around the circle -
m..
then after that taking fast at begining and slow within circle ..i cant get
this...@ dave plz explain with this example...will b of gr8 help..thnx in
advance..
Hi
On Mar 9, 2012 3:48 PM, "rahul sharma" wrote:
> i have 2 pointers fast and slow.now if tehy meet there is a loop...
>
> now keep one ptr at meeting point and take other one to the begining of
> listmove both at speed of one..they will meet at start of loophow
> this happens???why t
itz ryt...loop starts from 4 n not from 5...
On Fri, Mar 9, 2012 at 8:58 PM, sanjiv yadav wrote:
> I think u r making mistake i.e. after 7,5 will com not 4 because loop
> starts from 5.check it again
>
> On 3/9/12, rahul sharma wrote:
> > @sanjiv...how can u take q at c.they will meet at
I think u r making mistake i.e. after 7,5 will com not 4 because loop
starts from 5.check it again
On 3/9/12, rahul sharma wrote:
> @sanjiv...how can u take q at c.they will meet at some position ...
> suppose u have
>
> 1-2-3-4-5-6-7-4
>
> now initialy
>
> slow and fast both at 1
> start
@sanjiv...how can u take q at c.they will meet at some position ...
suppose u have
1-2-3-4-5-6-7-4
now initialy
slow and fast both at 1
start incrementing slow by 1 and fast by 2
slow @2 ...fast @3
slow @3fast @5
s...@4...fast@7
slow @5...fast@5
both are equalmeans dere is loo
suppose linked list is
a->b->c->d->e
and suppose loop starts from 'c'
according to u let one pointer be at 'c' say *q and another be at 'a' say
*p. Now if we move both at the speed of one then
After first pass
p will be at b
q will be at d
After second pass
p will be at c
q will be at e
A
@terencei cant get..can u eleboratethnx for the sol..but plz
elaborate...
On Fri, Mar 9, 2012 at 5:59 PM, Terence wrote:
> @ rahul sharma:
> the linked list is a combination of a list a->b->...->p->q and a cycle
> q->r->...->z->q. (z != p).
> noting that the start of cycle q is the only
@ rahul sharma:
the linked list is a combination of a list a->b->...->p->q and a cycle
q->r->...->z->q. (z != p).
noting that the start of cycle q is the only node with 2 predecessor: p
and z.
if 2 pointers meet at some node x, different from q, in last step they
must have met at x', the predec
No They will not meet at the start in a case containing 5 nods and having
loop at the third node. once check this
On Fri, Mar 9, 2012 at 3:48 PM, rahul sharma wrote:
> i have 2 pointers fast and slow.now if tehy meet there is a loop...
>
> now keep one ptr at meeting point and take other one
i have 2 pointers fast and slow.now if tehy meet there is a loop...
now keep one ptr at meeting point and take other one to the begining of
listmove both at speed of one..they will meet at start of loophow
this happens???why they meet at start..plz tell logic behind this???thnx in
adva
Yep..that's correct.
In this context, I would like to understand a little more about inline
functions?
Other than they being a type sensitive compared to macro, what else differs
them from macro, and does each call to inline function, does get replaced
by its definition!.
Any link, that can giv
int main ()
{
int g= 1, h= 2;
int t; t=g;g=h;h=t;
}
hope this helps
On 2/4/12, rahul sharma wrote:
> swap(a,b,c) c t;t=a;a=b;b=t;
>
>
> int main()
> {
> int g=1,h=2;
> swap(g,h,int);
> }
>
> how the actual values are replace???
> a and b are replaced with g and hactual are replace..can some
yeahjust wana cnfm that parameters are replaced actually...thnx
On Sat, Feb 4, 2012 at 4:40 PM, sharad dixit wrote:
> Think #define as a simple text substitution macro.
>
> Assume you are the preprocessor. Copy/paste the exact code for the macro
> into the places where your program tried to u
Think #define as a simple text substitution macro.
Assume you are the preprocessor. Copy/paste the exact code for the macro
into the places where your program tried to use and then replace the macro
parameters with the arguments that you used to invoke the macro.
The advantage of a macro is that
swap(a,b,c) c t;t=a;a=b;b=t;
int main()
{
int g=1,h=2;
swap(g,h,int);
}
how the actual values are replace???
a and b are replaced with g and hactual are replace..can somebody tell
me expanded source code???
--
You received this message because you are subscribed to the Google Groups
"Algo
I just have a basic doubt..does the string s1,s2 statement call any default
constructor?or is it that it is not performed since parameterised
constructor is present?
On Wed, Sep 21, 2011 at 1:31 AM, vijay singh wrote:
> It is because of the presence of the single parameterised constructor in
> th
No homework post please.
On Sat, Dec 17, 2011 at 6:26 PM, rameshbabu kovuru <
rameshbabukv...@gmail.com> wrote:
> hai friends this is ramesh .
> i need c or cpp code for normalisation ,how the normlaiztion will be
> performed on a realtion up to third normal formplease...
> if any one knows a
hai friends this is ramesh .
i need c or cpp code for normalisation ,how the normlaiztion will be
performed on a realtion up to third normal formplease...
if any one knows about it please send that code ..please please...
--
You received this message because you are subscribed to the
this is my almost working code for spoj mayca ...can anyone suggest me
anytest cases.for which it is not working.tnx in advance
#include
#include
#include
using namespace std;
char
maya[][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac"
limit is just v.smll can ny1 help me with this code: [ c code ] get it
under 120 bytes .
is there any way to take inputs. without using scanf ??? in c . m
thinking about inputs getting into
argc array directly.???
#define s(n) scanf("%d",&n);
f(int n){return n==1?1:(n*f(n-1));}
main()
{
i
#include
#define s(n) scanf("%d",&n)
#define I int
I a[14][14];
I d(I m,I n)
{
I s=a[m][n];
I k;
if(!m||!n)
k=1;
else if(s)
k=s;
else
{
k=d(m-1,n)+d(m,n-1);
s=k;
}
return k;
}
main()
{
I t,n,k;s(t);
while(t--)
{
s(n);
k=d(n,n);
printf("%d\n",k);
}
}
@saurav:this is the actual and very simple code.
yup it can be further reduced but i think u need a new approach. (m,m) is a
big hint . try some nCp type of solution.
#define s(n) scanf("%d",&n)
#define I int
I a[14][14],t,n;
I d(I m,I n)
{ I s=a[m][n],
k=(!m||!n)?1:(s?s:d(m-1,n)+d(m,n-1));
s=k;return k;
}
main()
{
s(t);
while(t-
Post the formatted code too.(With proper indents)Then it would be easier
for others to work on it,
On Thu, Dec 15, 2011 at 11:47 PM, anubhav raj wrote:
> we have to submit it in 120 byte cn ne 1 tl me dat whr z the chances of
> further byte reduction in this code.
> #include
> #define s(
we have to submit it in 120 byte cn ne 1 tl me dat whr z the chances of
further byte reduction in this code.
#include
#define s(n) scanf("%d",&n)
#define I int
I a[14][14];I d(I m,I n){I s=a[m][n];I k;if(!m||!n)k=1;else
if(s)k=s;else{k=d(m-1,n)+d(m,n-1);s=k;}return k;}main(){I
t,n,k;s(t);wh
hey guys ,i am trying to solve TSUM ..on spoj...
http://www.spoj.pl/problems/TSUM/.in which we have to find the sum of any
triplets in n numbers.can any one suggests me any approach other
than brute-force of (n^3)..
..thanks in advance
--
Y
I have a doubt in calculating LCA. While calculating LCA of two
nodes, should those two nodes can also be ancestor. As wikipedia
states that
"The lowest common ancestor is defined between two nodes v and w as
the lowest node in T that has both v and w as descendants (where we
allow a node to be a
Shreyas solution would work. semaphores can be released for a thread
that has not acquired it .
Thanks,
Balaji
On Wed, Sep 28, 2011 at 7:41 PM, anshu mishra wrote:
> You cant do.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To p
Use 2 semaphores.
pseudo code
sem_1(1);
sem_2(0);
THREAD A;THREAD B
sem_1_wait(); sem_2_wait();
...
sem_2_signal();
You cant do.
--
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
There are two threads, one produces even number and other produces
odd
number, how will you print the consecutive numbers.
--
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 uns
Hi
I have written a simple template class.
#include
using namespace std;
template
class vector
{
T *arr;
int size;
public:
vector(int len)
{
arr = new T[size=len];
for(int i=0;iarr[i]*obj.arr[i];
return sum;
It is because of the presence of the single parameterised constructor in the
class definition.
So, if we are writing the following statement...
string s1;
s1="test";
It'll call the single parameterised constructor.
But this only true in the case of single value assignment as in the above
statemen
Consider a class
class string
{
char *p;
int len;
public:
string(char *a);
};
string::string(char *a)
{
length = strlen(a);
p= new char[length +1];
strcpy(p,a);
}
string s1,s2;
char *name ="test";
s2=name; // statement
Why does constructor gets called in state
the following is a function which computes the double tree of a given tree.
here is the description of a double tree.
doubleTree()
For each node in a binary search tree, create a new duplicate node, and
insert the duplicate as the left child of the
original node. The resulting tree should still be
ya code is perfectly fine.no error
On Mon, Aug 29, 2011 at 12:07 AM, sagar pareek wrote:
> Success
>
> http://www.ideone.com/ZFgEh
>
>
> On Sun, Aug 28, 2011 at 3:13 PM, Aditya Virmani
> wrote:
>
>> it runs perfectly for me on both 64 bit & 32 bit... check again
>>
>>
>> On Sun, Aug 28, 2011
Include the stdlib.h it would work on a 64 bit compiler.
http://cboard.cprogramming.com/c-programming/112306-malloc-segfault.html
On Mon, Aug 29, 2011 at 12:07 AM, sagar pareek wrote:
> Success
>
> http://www.ideone.com/ZFgEh
>
>
> On Sun, Aug 28, 2011 at 3:13 PM, Aditya Virmani
> wrote:
>
>>
Success
http://www.ideone.com/ZFgEh
On Sun, Aug 28, 2011 at 3:13 PM, Aditya Virmani wrote:
> it runs perfectly for me on both 64 bit & 32 bit... check again
>
>
> On Sun, Aug 28, 2011 at 2:20 PM, Nikhil Gupta
> wrote:
>
>> The following C program segfaults of IA-64, but works fine on IA-32.
>>
How can I store an escape sequence at each character of the string
when i give the string as an input to the program? Can anybody suggest
me something other than the method i mention below
#include
#include
#include
using namespace std;
int main()
{
char s[100];
for(int i = 0 ; i < 100
it runs perfectly for me on both 64 bit & 32 bit... check again
On Sun, Aug 28, 2011 at 2:20 PM, Nikhil Gupta wrote:
> The following C program segfaults of IA-64, but works fine on IA-32.
>
> *int* main()
>
> {
> *int p;
> p *=* (*int)malloc(*sizeof*(*int*));
>
> ***
The following C program segfaults of IA-64, but works fine on IA-32.
*int* main()
{
*int p;
p *=* (*int)malloc(*sizeof*(*int*));
***p *=* 10;
*return* 0;
}
Why does it happen so?
--
Nikhil Gupta
Senior Co-ordinator, Publicity
CSI, NSIT Students' Branch
NSIT
Its 2 2 on gcc compiler.
Some compilers support overwriting of the const variables which is usually a
bug if program expects the value of a variable to be constant .
Usually newer compilers don't show such bugs.
On Sun, Aug 21, 2011 at 8:59 PM, Sanjay Rajpal wrote:
> i was also amazed to see th
i was also amazed to see the mystery behind 'const' keyword.
Sanju
:)
On Sun, Aug 21, 2011 at 8:27 AM, shady wrote:
> woh, thought provoking, it giving 2 2 when there is not const
> i think it has something to do with how 'const' modifies the behaviour of
> storage
>
>
> On Sun, Aug 21, 2011
woh, thought provoking, it giving 2 2 when there is not const
i think it has something to do with how 'const' modifies the behaviour of
storage
On Sun, Aug 21, 2011 at 8:33 PM, Kamakshii Aggarwal
wrote:
> But on dev c it is showing o/p as 2 2 ..
> I too have a doubt,a similar question was asked i
But on dev c it is showing o/p as 2 2 ..
I too have a doubt,a similar question was asked in atrenta's written paper.
On Sun, Aug 21, 2011 at 8:14 PM, Ankur Khurana wrote:
> can somebody please explain this ?
>
>
> On Sun, Aug 21, 2011 at 8:08 PM, Nikhil Gupta
> wrote:
>
>> http://www.ideone.com/
can somebody please explain this ?
On Sun, Aug 21, 2011 at 8:08 PM, Nikhil Gupta wrote:
> http://www.ideone.com/kRaMj
>
> I found this in the algogeeks forum only. Can anyone explain how value of i
> is still 0, but *p shows 2 although their addresses are the same.
>
> --
> Nikhil Gupta
>
> --
>
http://www.ideone.com/kRaMj
I found this in the algogeeks forum only. Can anyone explain how value of i
is still 0, but *p shows 2 although their addresses are the same.
--
Nikhil Gupta
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To po
@anika and sagar : Thanks Got it.
On Sun, Aug 14, 2011 at 6:25 PM, sagar pareek wrote:
> @rshetty
>
> for the first code
> u have array as : --_ _ _ _ _ _ _ _ _ _ ( _ denotes block of int)
> so sizeof(*p) is ofcourse give you sze of int
>
>
> now u have int *p[10][20];
>
> which can be view
@rshetty
for the first code
u have array as : --_ _ _ _ _ _ _ _ _ _ ( _ denotes block of int)
so sizeof(*p) is ofcourse give you sze of int
now u have int *p[10][20];
which can be viewed as
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _
in the first code the output is 4 bcoz *p means *&p[0] that means p[0] that
is some address so for 32 bit machine its coming to be 4 bytes..
in the 2nd it is 80 as 20*sizeof(int *) and not as you mentioned..
On Sun, Aug 14, 2011 at 6:12 PM, rShetty wrote:
> Please explain this ...
>
> #include
>
Please explain this ...
#include
int main()
{
int *p[10];
printf("%d",sizeof(*p));
return 0;
}
Output is 4
For this program
#include
int main()
{
int *p[10][20];
printf("%d",sizeof(*p));
return 0;
}
Output is 80 (10*20*sizeof(int))
--
You received this message because you are subs
public class JoyOfHex {
public static void main(String[] args) {
System.out.println(
Long.toHexString(0x1L + 0xcafebabe));
}
}
I got the problem from Java Puzzlers Book
Here Is Their Explanation ::
Decimal
actually the questn should go like this.wud that be good
/optimised with space because we can use more storages for a tree
without freeing them
On Thu, Aug 4, 2011 at 10:09 AM, rajeev bharshetty wrote:
> Since you are maintaining two different data structures ,one for the old
> tree and t
Since you are maintaining two different data structures ,one for the old
tree and the other for new tree . I think this isn't considered in-place
algorithm . The algorithm to be in-place should not use any additional data
structures .
Correct me if I am wrong .
On Thu, Aug 4, 2011 at 2:52 AM, Gaur
good quesn.i also want to knowjust in case
On Thu, Aug 4, 2011 at 2:50 AM, Anurag Narain wrote:
> suppose there is a binary tree and i am creating another tree which is same
> as the previous one.
> but while creating the new tree i am freeing the nodes of my old tree(i.e.,
> i create one
suppose there is a binary tree and i am creating another tree which is same
as the previous one.
but while creating the new tree i am freeing the nodes of my old tree(i.e.,
i create one node in new tree and delete the corresponding node in old tree
and continue the process till the new tree is form
@nikhil..yea do ones complement by using ~ operator and thn add 1...
On Fri, Jul 29, 2011 at 7:16 PM, Nikhil Gupta wrote:
> Thanks.
>
> Is there any way to implement 2's compliment on binary numbers?
>
>
> On Fri, Jul 29, 2011 at 7:13 PM, rajeev bharshetty
> wrote:
>
>> ~ does bitwise not on the
Thanks.
Is there any way to implement 2's compliment on binary numbers?
On Fri, Jul 29, 2011 at 7:13 PM, rajeev bharshetty wrote:
> ~ does bitwise not on the operand .
> It simply inverts all the bits .
>
>
> On Fri, Jul 29, 2011 at 7:09 PM, Nikhil Gupta
> wrote:
>
>> And what does "~" operator
Things can go very bad in case the string length is large and mostly of non
priniting chars.
and wat if there are chars with negative ascii value?does ur logic handles
this situation?I doubt it does,
On Fri, Jul 29, 2011 at 8:21 PM, snehi jain wrote:
> no problem ..
> but can u find a bug in thi
no problem ..
but can u find a bug in this technique ..
On Fri, Jul 29, 2011 at 8:17 PM, saurabh singh wrote:
> ignore above status...i was looking at two problems
> simulataneously...posted on the wrong one...
> apologies...really its embarrasing.
>
> On Fri, Jul 29, 2011 at 8:11 PM, snehi jain
ignore above status...i was looking at two problems simulataneously...posted
on the wrong one...
apologies...really its embarrasing.
On Fri, Jul 29, 2011 at 8:11 PM, snehi jain wrote:
> thanks ..
> @siddhartha : i know the hashing technique ... and the problem of longer
> strings can be reduced
thanks ..
@siddhartha : i know the hashing technique ... and the problem of longer
strings can be reduced by subtracting a large constant value from the ASCII
value of all the characters .. and its not only with cubes even if u add
squares of ascii values ... i think it will work .
@saurabh : in w
use a bitfield to optimize space
On Fri, Jul 29, 2011 at 7:14 PM, Siddharth kumar <
siddhartha.baran...@gmail.com> wrote:
> #include
> #include
>
> using namespace std;
>
> int main()
> {
> char str1[] = "sdfgkirertyujvcheddirtyutrdfgrtyuigfkrertyuijhgfdshh";
> char str2[] = "redirtyhgfds
#include
#include
using namespace std;
int main()
{
char str1[] = "sdfgkirertyujvcheddirtyutrdfgrtyuigfkrertyuijhgfdshh";
char str2[] = "redirtyhgfdshhrtyrsujvcheierdutrdfgrtyuigfkdfgktyuij";
int len1 = strlen(str1), len2 = strlen(str2);
if(len1 != len2)
{
cout<<"Both
~ does bitwise not on the operand .
It simply inverts all the bits .
On Fri, Jul 29, 2011 at 7:09 PM, Nikhil Gupta wrote:
> And what does "~" operator do?
>
>
> On Fri, Jul 29, 2011 at 5:59 PM, aditi garg wrote:
>
>> >> right shift.^ Xor,& and,| OR operators...
>> the statement means u r anding t
And what does "~" operator do?
On Fri, Jul 29, 2011 at 5:59 PM, aditi garg wrote:
> >> right shift.^ Xor,& and,| OR operators...
> the statement means u r anding the bits of num wid the bits in the
> hexadecimal number x000FF and thn right shifting the bits by 0 number of
> times( effectively
for long strings, the values will be larger.
a simple approach could be to store occurrence of each char of both the
strings in an integer array of size 26 and if both the arrays are same then
the two strings are anagrams.
--
You received this message because you are subscribed to the Go
>> right shift.^ Xor,& and,| OR operators...
the statement means u r anding the bits of num wid the bits in the
hexadecimal number x000FF and thn right shifting the bits by 0 number of
times( effectively in this case u wont be shifting)
On Fri, Jul 29, 2011 at 5:50 PM, Nikhil Gupta wrote:
> W
What is meant by the statement :
byte0 = (num & x00FF) >> 0
And what is meant by the operators ">>" , "^" , "&" , "|" and how are they
used?
--
Nikhil Gupta
Senior Co-ordinator, Publicity
CSI, NSIT Students' Branch
NSIT, New Delhi, India
--
You received this message because you are subs
i was looking for techniques for checking if two words are anagrams ... and
i did get a lot of techniques with sorting and then comparing ...
but will this work...
add the ASCII values of the characters and add the cube of ASCII value of
the same characters ..
if for 2 strings both the correspon
I already asked a question regarding evaluation of expression in this
forum like
int y,x=3;
y = x++ + x++ ;
i got reply that
the above statement would be interpreted as
y = x+x;
x = x+2;
i.e the effect of post fix takes place only after the statement , i
then agreed it .
it perfectly worked with th
pass a address of pointer.
void insert(bst **head, int data);
call it using insert(&record,8).
try this.
On Thu, Jan 27, 2011 at 4:47 PM, nishaanth wrote:
> Hi guys,
>
> I have a small doubt regarding pointers and functions.
>
> Consider the following prototype
>
> void insert(bst * head, int
Hi guys,
I have a small doubt regarding pointers and functions.
Consider the following prototype
void insert(bst * head, int data);
This function creates a node and inserts the data in the node. Lets say i
call this function iteratively from main.
main(){
bst* record=NULL;
insert(record, 5);
hi everyone,
1.Can topological sorting be stated as an application of depth first search(DFS)...
2.What is inorder predecessor?how wil i find it???
pls reply
Sriram
--~--~-~--~~~---~--~~
You received this message because y
hi guys,
i wrote a program for arrays and i declared only a[3]. but my array accepts a[5]=10; statements and other statements...how is that possible..arrays are considered as continuous memory of same datatype isnt it...but the array a[3] becomes discontinuous...
wat could be the pos
hi guys,
When we use the pop function in stacks are the values deleted from the memory or not...that means we must be able to ovewrite in that spaces right...Can anyone clear my doubt...
Sriram
--~--~-~--~~~---~--~~
You received this message because y
83 matches
Mail list logo