Sorry for the previous post it got a mistake here take a look again :-
In TRIE , we can store nodes by characters. So it is very easy to search by
names and hence their corresponding numbers :) .
TRIE saves a lot memory coz it stares a character only once.
LIKE :-
if i want to save "sagar" wi
In TRIE , we can store nodes by characters. So it is very easy to search by
names and hence their corresponding numbers :) .
TRIE saves a lot memory coz it stares a character only once.
LIKE :-
if i want to save "sagar" with phone no. 123456789 then we store it in TRIE
as :
s-NULL
|
a-NULL
|
g-NU
Sorry dave, your solution works.
Thanks for the answer, What I was assuming to be a Counting sort was a
variant of it
for integers.
On Thu, Jun 30, 2011 at 7:56 AM, Dave wrote:
> @Rizwan: I don't see the problem. Initialize an array of counters, one
> for each possible last character, to zero. I
scanf returns no of integers it read,not the read integer.
On 6/26/11, sameer.mut...@gmail.com wrote:
> It breaks out correctly when test condition value is 0 i.e when value of t
> is 1
>
> On Sat, Jun 25, 2011 at 4:41 PM, sunny agrawal
> wrote:
>
>> No, Read about the return type of scanf
>>
http://geeksforgeeks.org/?p=12000
--
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/-/OnLux79bj3MJ.
To post to this group, send email to algogeeks@googlegroups.
@bittu :
In your first approach which u pointed out :
What if the minimum element is poped out of the stack ?? We may have
to search the whole stack to get the minimum element. O(n) in
worst case
In your second approach which u pointed out :
If u use 2 stacks, consistency of 2 stacks in a
Thanks
On Wed, Jun 29, 2011 at 2:45 AM, aditya kumar
wrote:
> @sagar : it works perfectly fine.
>
>
> On Tue, Jun 28, 2011 at 3:29 PM, sagar pareek wrote:
>
>> Check out my solution above :)
>> Its reversing the string
>>
>>
>> On Tue, Jun 28, 2011 at 1:56 PM, shady wrote:
>>
>>> no, you are
No reverse is not possible
On Thu, Jun 30, 2011 at 5:58 AM, Dave wrote:
> @Bittu: When you are finishedm can you change the DLL back into the
> original BST?
>
> Dave
>
> On Jun 29, 5:54 pm, bittu wrote:
> > Algorithm:
> > 1.Convert BST into sorted DLL which Will Take O(N) Time(Check previous
>
---
hari wants to stay in better touch using some of Google's coolest new
products.
If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-6ef61f8152-0a1809a38a-VhQtjvDuk5tyOdsQd1DUn_Ec5dU
You'll need to c
I know that is not the best solution but here we go:
p [i] [j] = 1 if s [i.. j] is palindrome, 0 otherwise
p [i] [i] = 1
p [i] [i +1] = s [i] == s [i +1]
p [i] [k] = s [i] == s [k] & & p [i +1] [k-1], k> i +1
time complexity = O (n ^ 2)
Space complexity = O (n ^ 2)
You can modify the algorithm
yes that is the solution is also wrote, however one critical point in this
solution is if queue size is x then each stack needs to be of size x thereby
requiring overall 2x space.
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652
On Thu, Jun 30, 2011
kthlargest(a[],b[],lefta,righta,leftb,rightb,k)
{
mida=lefta+(righta-lefta)/2;
midb=leftb+(rightb-leftb)/2;
if(a[mida]bmidb])
kthlargest(a[],b[],lefta,mida-1,midb+1,rightb,);
else
return a[mida];
}
On 6/25/11, Anantha Krishnan wrote:
> Idea is like this since both the array
By traversing tree either preorder or inorder or postorder and storing the
partial sums along the way and comparing the partial sums with the required
sum can solve the problem
On Wed, Jun 29, 2011 at 7:56 PM, Akshata Sharma
wrote:
> How to find a path in a given binary tree which sums up to a gi
I don't have any alternative solution till now.
On Wed, Jun 29, 2011 at 8:05 PM, varun pahwa wrote:
> @ankit: ur space complexity will be too high. i think it will be ultimately
> 2^n where n is the number of the nodes.
>
> On Wed, Jun 29, 2011 at 1:10 PM, ankit sambyal wrote:
>
>> The idea is to
@ankit: ur space complexity will be too high. i think it will be ultimately
2^n where n is the number of the nodes.
On Wed, Jun 29, 2011 at 1:10 PM, ankit sambyal wrote:
> The idea is to traverse the binary tree in post order and find out all
> the path sums and store them. Use a hashtable or any
Well obviously. Were you suggesting using 4 stacks, each of size x/4
to enqueue x elements? Can you please share the algo for that?
On Jun 28, 7:54 pm, Ashish Goel wrote:
> sanket, if 2 stacks r of length x, then2x elements should be nqed
> Best Regards
> Ashish Goel
> "Think positive and find f
Hi Guys,
The @pacific solution is the best?
Wladimir Araujo Tavares
*Federal University of Ceará
*
On Tue, Jun 28, 2011 at 7:26 AM, sunny agrawal wrote:
> you can initialize it to (Max-Min+1)
> where Max = max of all elements
> Min = min of all elements
>
> Or simple initialise it to a larg
@Rizwan: I don't see the problem. Initialize an array of counters, one
for each possible last character, to zero. If there are no
restrictions on the last character, use an array of 256 counters.
Then, for each string, increment the counter corresponding to the last
character of the string by the l
@Rizwan: Not completely. What if ROW in your code is a variable (not a
constant) that is not known until run time? Then you need to
dynamically allocate space for your arr2D as well. So, contradicting
my earlier "No" response, maybe something like this would work to
allocate an array a with m rows
http://www.acmsolver.org/books/Programming_Challenges_Miguel_Skiena.pdf
Theres a chapter on Backtracking in this book..
On Thu, Jun 30, 2011 at 12:20 AM, Nitish Garg wrote:
> I have found many problems solvable using backtracking like Find
> permutations, 8 queens problem, 10*10 array maze etc.
http://ideone.com/MSLXT
The constraints are so less that you can brute force the solution..N<100.
My solution is O(N^3)
On Thu, Jun 30, 2011 at 1:13 AM, harshit pahuja wrote:
> http://en.wikipedia.org/wiki/Josephus_problem
> here there is an explanation of the derivation of josephus which is nt
I have solved this using one malloc find the code in http://ideone.com/BV9Kj
On Thu, Jun 30, 2011 at 1:20 AM, Piyush Sinha wrote:
> ohh sorrymy bad...i didnt read the whole question..i just read the
> subject...:P
>
> i think its not possible if u want other than hary's solution...
>
> On 6/3
@Dave: Think of it again counting sort won't work, If you are just
considering the last character as
the even though key is just last character, the value is the whole string..
On Tue, Jun 28, 2011 at 1:53 PM, juver++ wrote:
> List[letter] - linked list of all words with the last character as l
There is a very simple solution to this problem, Pseudo Code follows:
Inputs: str - string, c1,c2 are characters.
*MinDistance(str, c1, c2):
initialize RightMostIndex[127] with all entries as -1
initialize curMin as Len(str)+1
For i = 0 to Len(str) - 1
if str[i] is same c1 then
@Dumanshu: Your idea is definitely a good improvement, however the
SPOJ Runtimes are not reliable..
The code which was getting 0.00 AC with 512 KB Buffer now runs in 0.02 Seconds..
And I tried submitting the code with enhancement u suggested it runs
in 0.01 even with 8KB Buffer.
http://ideone.com/
for 2nd part of 1st question, when array has become sorted
for ex: 3 5 10 16 17 35 40 56 67 and num is 33
becomes : 3 5 10 16 16 ..
make array of 17 elements s[0,0,1,2..]
s[16] = 2 means we find a duplicate hense resultu
int m = (num%2==1)?(num/2+1):(num/2)
for (int i=0;im){arr
@Bittu: When you are finishedm can you change the DLL back into the
original BST?
Dave
On Jun 29, 5:54 pm, bittu wrote:
> Algorithm:
> 1.Convert BST into sorted DLL which Will Take O(N) Time(Check previous
> Posts Already Coded) you can see here "cslibrary.stanford.edu/109"
> 2.take find sum int
Apoorve: No.
Dave
On Jun 29, 2:34 pm, Apoorve Mohan wrote:
> @piyush: only one call to malloc...ur sol has 2
>
> On Thu, Jun 30, 2011 at 12:58 AM, Piyush Sinha
> wrote:
>
>
>
>
>
> > int **p;
> > p = (int **)malloc(sizeof(int *)*row);
> > for(i = 0;i > p[i] = (int *)malloc(sizeof(int)*col
O(n^2) and O(n^3) respectively.
On Jun 30, 3:47 am, Dumanshu wrote:
> if the output for the input "doomdoomdoom" is 8 then refer
> tohttp://ideone.com/kX8MV
> else if the output is 4 then refer tohttp://ideone.com/3tAKN
> the second one is having a higher complexity.
> ny suggestions?
>
> On Jun
Algorithm:
1.Convert BST into sorted DLL which Will Take O(N) Time(Check previous
Posts Already Coded) you can see here "cslibrary.stanford.edu/109"
2.take find sum into DLL two pointer start,end which points to
starting & end position of DLL.
3. start from start->data & end->data , keep checking u
if the output for the input "doomdoomdoom" is 8 then refer to
http://ideone.com/kX8MV
else if the output is 4 then refer to http://ideone.com/3tAKN
the second one is having a higher complexity.
ny suggestions?
On Jun 29, 9:54 pm, Swathi wrote:
> Given a string (assume there no spaces or punctuati
@ashish Dude you can Have a Look
http://shashank7s.blogspot.com/2011/04/wap-to-implement-queue-using-stack.html
do notify me if we can optimize the solution..:)
Thanks
Shashank "I Don't Do Code to Code But I Do Code to Build Product"
Computer Science & Engineering
Birla Institute of Technology,M
@juver++ correct
@ankit you can see here
1st Approach .
You can implement this by having each node in the stack keep track of
the minimum beneath itself. Then, to find the min, you just look at
what the top element thinks is the min.When you push an element onto
the stack, the element is given th
1.Use Haddop & Map Reduce Framework .Obviously We Need Distributed
Algo we will make one computer as master & assign the job to all
slave computer to do the crawling the web depending upon the
geographic area ( m thinking real time problem).to crawled the
maximum
pages in least time we need
use suffix array time will be O(N) e.g. in case of banana answer will
be ana
you can find more info here
http://shashank7s.blogspot.com/2011/06/longest-repeated-substring-eg-maximum.html
Thanks
Shashank "I Don't Do Code to Code But I Do Code to Build Product"
Computer Science & Engineering
Bi
for the input "doomdoomdoom"
output is 4 or 8?
On Jun 30, 2:04 am, Dumanshu wrote:
> I have used suffix arrays. Its easier to implement than trees.
> code here-http://ideone.com/kX8MV
> In case u find a test case givin wrong output plz do tell.
>
> On Jun 29, 9:54 pm, Swathi wrote:
>
>
>
>
>
>
>
I have used suffix arrays. Its easier to implement than trees.
code here- http://ideone.com/kX8MV
In case u find a test case givin wrong output plz do tell.
On Jun 29, 9:54 pm, Swathi wrote:
> Given a string (assume there no spaces or punctuations), write a code that
> returns the max. length of
The idea is to traverse the binary tree in post order and find out all
the path sums and store them. Use a hashtable or any other data
structure to store the possible paths rooted at a node and going
down-only. Now we can construct all paths going through a node from
itself and its childrens' paths
ohh sorrymy bad...i didnt read the whole question..i just read the
subject...:P
i think its not possible if u want other than hary's solution...
On 6/30/11, Apoorve Mohan wrote:
> @piyush: only one call to malloc...ur sol has 2
>
> On Thu, Jun 30, 2011 at 12:58 AM, Piyush Sinha
> wrote:
>
>>
http://en.wikipedia.org/wiki/Josephus_problem
here there is an explanation of the derivation of josephus which is nt very
clearcan some1 explain it plzz
On Wed, Jun 29, 2011 at 12:40 PM, harshit pahuja wrote:
> Hello guys...
> http://www.spoj.pl/problems/POCRI/
>
> this problem is using
Hello guys...
http://www.spoj.pl/problems/POCRI/
this problem is using a variant of josephus problem.
in josephus we for given n persons in a circle we start killing every kth
person and last person remaining is the survivor..kth 2kth 3kth...so
on
i solved it using *f(n,k)=(f(n-1,k)+k)%m
@sunny atof(ab) is giving me as zero.so it will not affect
the calculation i think so...
--
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 f
@piyush: only one call to malloc...ur sol has 2
On Thu, Jun 30, 2011 at 12:58 AM, Piyush Sinha wrote:
> int **p;
> p = (int **)malloc(sizeof(int *)*row);
> for(i = 0;i p[i] = (int *)malloc(sizeof(int)*column);
>
> On 6/30/11, Apoorve Mohan wrote:
> > though thankx :)
> >
> > On Thu, Jun 30
int **p;
p = (int **)malloc(sizeof(int *)*row);
for(i = 0;i wrote:
> though thankx :)
>
> On Thu, Jun 30, 2011 at 12:44 AM, Apoorve Mohan
> wrote:
>
>> @above: man i need a 2d array not a 1d array...
>>
>>
>> On Thu, Jun 30, 2011 at 12:38 AM, hary rathor
>> wrote:
>>
>>>
>>> #include
>>>
>>> int ma
though thankx :)
On Thu, Jun 30, 2011 at 12:44 AM, Apoorve Mohan wrote:
> @above: man i need a 2d array not a 1d array...
>
>
> On Thu, Jun 30, 2011 at 12:38 AM, hary rathor wrote:
>
>>
>> #include
>>
>> int main ()
>> {
>> int *mat;
>> int i,j;
>> int ROW=4;
>> int COL=3;
>>
@above: man i need a 2d array not a 1d array...
On Thu, Jun 30, 2011 at 12:38 AM, hary rathor wrote:
>
> #include
>
> int main ()
> {
> int *mat;
> int i,j;
> int ROW=4;
> int COL=3;
> int k=0;
> mat=(int *)malloc(ROW*COL*sizeof(int));
>
>for(i=0;ifor(j=0;jmat[
Sorry, didn't noticed that it was hard coded :)
On Thu, Jun 30, 2011 at 12:13 AM, oppilas . wrote:
> You code returns 1 for
>
>- input:
>
>
>abab1abab1
>
>output:
>
>
>1
>
>- input:
>
>
>abababab1abab:
>
>
>1
>
>
>
> On Thu, Jun 30, 2011 at 12:04 AM, Anantha Krishnan
#include
int main ()
{
int *mat;
int i,j;
int ROW=4;
int COL=3;
int k=0;
mat=(int *)malloc(ROW*COL*sizeof(int));
for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.
I have found many problems solvable using backtracking like Find
permutations, 8 queens problem, 10*10 array maze etc.
Can anyone point me to some source from where I can learn BackTracking?
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To
You code returns 1 for
- input:
abab1abab1
output:
1
- input:
abababab1abab:
1
On Thu, Jun 30, 2011 at 12:04 AM, Anantha Krishnan <
ananthakrishnan@gmail.com> wrote:
> http://ideone.com/oEfLE
>
>
> On Thu, Jun 30, 2011 at 12:04 AM, Anantha Krishnan <
> ananth
http://ideone.com/oEfLE
On Thu, Jun 30, 2011 at 12:04 AM, Anantha Krishnan <
ananthakrishnan@gmail.com> wrote:
> I wish to say that we should not use any inbuilt functions.
>
>
> On Wed, Jun 29, 2011 at 11:43 PM, oppilas . wrote:
>
>> What I wanted to say that, it's a trivial question for alg
I wish to say that we should not use any inbuilt functions.
On Wed, Jun 29, 2011 at 11:43 PM, oppilas . wrote:
> What I wanted to say that, it's a trivial question for algorithmic point of
> view.
> You could have just implemented a normal function without worrying about
> complexity because the
What I wanted to say that, it's a trivial question for algorithmic point of
view.
You could have just implemented a normal function without worrying about
complexity because the constraints were quite low.
I have not tested it for all corner cases. If it fails somewhere then give
the test case. I w
http://ideone.com/YlGCC
On Wed, Jun 29, 2011 at 10:47 PM, Swathi wrote:
> If you have any strong solution then write the pseudo code and explain your
> logic... please dont simply write like this.. it saves lot of time... code
> and explain
>
>
> On Wed, Jun 29, 2011 at 10:45 PM, oppilas . wrote
@Swathi :We can't use trie data structure to store the phone numbers.
The most sound reason is that the users require phone numbers to be
sorted by name, but by using the trie data structure we can't get the
phone numbers which are sorted by name. Again we can't use trie whose
nodes are numbers, be
hey how r u dealing with absent cases.
for each case u r directly converting string to float
but for absent u will call atof() for "ab" and compare it.
On Wed, Jun 29, 2011 at 11:02 PM, kartik sachan wrote:
> any one plzz reply
>
> --
> You received this message because you are subscr
how abt two passes
first one makes a multi map of char and its positions
second one a bit tricky to
eg
abcabcabc
first pass
a,0,3,6,
b,1,4,7
c,2,5,8
second pass
first char is a, its next position is 3(find thrugh the map)
repeated substring can be of length 3
for loop with this (count
Check this
http://ideone.com/o8gF2
On Wed, Jun 29, 2011 at 10:28 PM, Swathi wrote:
> This should be very simple... follow inorder..
>
> Inorder(Node* node, int counter, int N)
> {
> if(node == null)return;
> Inorder(node->left, counter, N);
> counter++;
> if(counter == N)
> {
> print(node
jokes apart...then i think it can be done using dynamic programming
using the similar approach of LCS but the time and space complexity
both will be N^2.i am working on the pseudocode and post it within
a few moments if it works..
On 6/29/11, Swathi wrote:
> I dont know why people reply in pl
I never said you don't have right but even after saying they asked me to
write the code.. you are asking the same question which is not at all good..
On Wed, Jun 29, 2011 at 11:01 PM, Ashish Goel wrote:
> chk this and try to write urself
> http://www.allisons.org/ll/AlgDS/Tree/Suffix/
>
> peopl
any one plzz reply
--
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 op
chk this and try to write urself
http://www.allisons.org/ll/AlgDS/Tree/Suffix/
people hv right to decide if they want to WAP or not.
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652
On Wed, Jun 29, 2011 at 10:55 PM, Swathi wrote:
> I dont know why
I dont know why people reply in plain words.. I personally had this
experience and i was asked to code but i couldn't
On Wed, Jun 29, 2011 at 10:53 PM, Piyush Sinha wrote:
> I dnt think any company is gonna ask u to code suffix tree..:P :P
>
> On 6/29/11, Swathi wrote:
> > It does but i am asked
I dnt think any company is gonna ask u to code suffix tree..:P :P
On 6/29/11, Swathi wrote:
> It does but i am asked to code.. if you know the code for suffix tree then
> please provide..
>
> On Wed, Jun 29, 2011 at 10:30 PM, Piyush Sinha
> wrote:
>
>> i think suffix tres will do the job if i hav
Is there any way to dynamically allocate a 2-D array using *using single
call to malloc* in C ?
--
regards
Apoorve Mohan
--
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 un
If you have any strong solution then write the pseudo code and explain your
logic... please dont simply write like this.. it saves lot of time... code
and explain
On Wed, Jun 29, 2011 at 10:45 PM, oppilas . wrote:
> Why are we thinking of suffix tree in this case. Does not make sense.
> It the pa
Why are we thinking of suffix tree in this case. Does not make sense.
It the password is valid then it is of length between 5-12 only.
Simple brute force approach will give decent time enough + we will not
waste necessary memory and large line of code.
On Wed, Jun 29, 2011 at 10:38 PM, Swathi wro
Please provide the psuedo code for suffix array or suffix trees which does
this.. I got this question in amazon online test... We need to write code,
compile and test in amazon online test..
On Wed, Jun 29, 2011 at 10:36 PM, rajat ahuja wrote:
> i think
> we need to form suffix array of the given
i think
we need to form suffix array of the given string with one extra information
tht is frm which index we are considerin suffix
then sort those uffixe pointres
after tht single scan wud do the job
thanks
rajat ahuja
On Wed, Jun 29, 2011 at 10:23 PM, Swathi wrote:
> Write the implementation o
It does but i am asked to code.. if you know the code for suffix tree then
please provide..
On Wed, Jun 29, 2011 at 10:30 PM, Piyush Sinha wrote:
> i think suffix tres will do the job if i have not misunderstood the
> question...
>
> On 6/29/11, Swathi wrote:
> > Given a string (assume there no
i think suffix tres will do the job if i have not misunderstood the question...
On 6/29/11, Swathi wrote:
> Given a string (assume there no spaces or punctuations), write a code that
> returns the max. length of the string that has repeated more than once.
>
> Thanks,
> Swathi
>
> --
> You receiv
This should be very simple... follow inorder..
Inorder(Node* node, int counter, int N)
{
if(node == null)return;
Inorder(node->left, counter, N);
counter++;
if(counter == N)
{
print(node->data);
return;
}
Inorder(node->right, counter, N);
}
On Wed, Jun 29, 2011 at 9:03 PM, piyush kapo
Please explain why you think TRIE use more space?
To my knowledge TRIE says lot of memory as the common numbers are saved only
once.. If you have any good reason then please explain and don't make any
single line statements.
On Wed, Jun 29, 2011 at 9:21 PM, MONSIEUR wrote:
> trie uses more space
Given a string (assume there no spaces or punctuations), write a code that
returns the max. length of the string that has repeated more than once.
Thanks,
Swathi
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send ema
Write the implementation of isPasswordValid() function which return true if
the following conditions matches
1) If password length is between 5 to 12 characters
2) It should be alpha numerics
3) There should not be any consecutive substrings
ex - ab12abc [valid as there are no consecutive substrin
@Juver++: Because the two-inorder-traversals approach is less work
than the one-inorder-traversal-plus-scan, since it only processes part
of the BST, until it finds the match. Furthermore, it is more elegant,
it that it doesn't use an extra array of size n. My guess is that the
total stack space re
ya..there can be other paths, like the on you mentioned..
On Wed, Jun 29, 2011 at 9:25 PM, Piyush Sinha wrote:
> 7+3 also give the sum to be 10???
>
> On 6/29/11, Akshata Sharma wrote:
> > How to find a path in a given binary tree which sums up to a given target
> > value?
> > for example if the
7+3 also give the sum to be 10???
On 6/29/11, Akshata Sharma wrote:
> How to find a path in a given binary tree which sums up to a given target
> value?
> for example if the given BT is
>
>5
> / \
> 3 2
> /
> 7
> and if the target is 10, then the path is root(5) + left node(3) +
>
trie uses more space
On Jun 29, 5:52 pm, sudheer kumar
wrote:
> USE TRIE
>
>
>
> On Wed, Jun 29, 2011 at 6:10 PM, shady wrote:
> > go through the archives you will definitely find the answer :)
>
> > On Wed, Jun 29, 2011 at 6:05 PM, MONSIEUR wrote:
>
> >> What is the most efficient way, memory
u r right buddy but problem is to save memory
On Jun 29, 7:33 pm, ankit sambyal wrote:
> Hey guys, phone usually has comparatively very less memory. So, we
> can't afford to have pointers for each phone no. So, the idea of
> having a tree is rooted out. The best way can be to use a fixed arra
if u have known the answer u would have probably answered rather than
writing this thing..:|
On Jun 29, 5:40 pm, shady wrote:
> go through the archives you will definitely find the answer :)
>
> On Wed, Jun 29, 2011 at 6:05 PM, MONSIEUR wrote:
> > What is the most efficient way, memory-wise,
Order Statistics Tree
On Wed, Jun 29, 2011 at 8:15 PM, sunny agrawal wrote:
> At each node if we store the Number of nodes in the left subtree.we can
> find kth smallest in O(lgn)
> else do a inorder traversal for k nodes
>
> On Wed, Jun 29, 2011 at 8:07 PM, Nishant Mittal <
> mittal.nishan..
@sunny oh... i cudnt understand.can u plz explain by an example
On Jun 29, 7:58 pm, sunny agrawal wrote:
> I am not using extra space as i am not allocating new memory for storing
> Nodes
> i m using just 2 pointers on the same list, i think that will be allowed
>
>
>
> On Wed, Jun 29, 2011 a
node *segregate(node *head)
{
node *even,*odd,*even1,*odd1;
even=odd=NULL;
while(head)
{
if((head->data)%2)
{
if(!odd)
{
odd = head;
@ashwini singh Printf() returns the number of values printed to the output
so printf("%d %d",2,2) returns 3 and the second printf returns 4 so bitwise
and of 3 and 4 is 0 so i is 0 . further printf statements print the values
and the last two printf statements have 3 & 3 so answer is 3.
Regards
@ashwini singh Printf() returns the number of values printed to the output
so printf("%d %d",2,2) returns 3 and the second printf returns 4 so bitwise
and of 3 and 4 is 0 so i is o . Similar explanation to further printf
statements .
Regards
Rajeev N B
I Blog @ www.opensourcemania.co.cc
On Wed,
in 1st printf no. of characters written are 3 and 4 and 3 & 4
is 0 which is equal to i
next 3 printf are easy...
now in last printf no. of characters written by 2 printf(s) are 3 and
3 and 3 & 3 is 3 which is printed by outer printf
On Jun 29, 7:40 pm, ashwini singh wrote:
> please ex-pla
I am not using extra space as i am not allocating new memory for storing
Nodes
i m using just 2 pointers on the same list, i think that will be allowed
On Wed, Jun 29, 2011 at 8:18 PM, Nishant wrote:
> @sunny plz tell me the solution without using extra list...i've solved
> it using extra list..
I have just copied ans pasted the code of OP.
And changed " ".
http://codepad.org/rBnx7z8V
On Wed, Jun 29, 2011 at 8:17 PM, udit sharma wrote:
> @Vaibhav: Sunny is also right bcz if u jst copy n paste d above code with
> (/ *jp) it'll show an error... And the error is in printf statement. jst cut
@sunny plz tell me the solution without using extra list...i've solved
it using extra list...
On Jun 29, 7:38 pm, sunny agrawal wrote:
> maintain two pointers one at the tail of even number list one at tail of odd
> Number list
> traverse the list and add the number at required list
>
> On Wed, J
@Vaibhav: Sunny is also right bcz if u jst copy n paste d above code with (/
*jp) it'll show an error... And the error is in printf statement. jst cut it
from the program n thn write it again.. It'll wrk properly
--
You received this message because you are subscribed to the Google Groups
"A
At each node if we store the Number of nodes in the left subtree.we can
find kth smallest in O(lgn)
else do a inorder traversal for k nodes
On Wed, Jun 29, 2011 at 8:07 PM, Nishant Mittal
wrote:
> how to find kth smallest element in BST...
>
> --
> You received this message because you are su
http://mukeshiiitm.wordpress.com/2010/04/07/finding-kth-smallest-element-in-binary/
I think this solves the problem :)
Rajeev
On Wed, Jun 29, 2011 at 8:07 PM, Nishant Mittal
wrote:
> how to find kth smallest element in BST...
>
> --
> You received this message because you are subscribed to the
please ex-plain the o/p of each line
o/p is
2 23 2
0
3
2 2 2 23 2
3
#include
#include
main()
{
int i;
i=printf("%d %d",2,2) & printf("%d %d ",3,2);
printf("\n%d",i);
printf("\n%d\n",3,4);
printf("%d %d ",2,2);
printf("\n%d",printf("%d %d",2,2) & printf(
maintain two pointers one at the tail of even number list one at tail of odd
Number list
traverse the list and add the number at required list
On Wed, Jun 29, 2011 at 8:04 PM, Nishant Mittal
wrote:
> segregate even and odd nodes in a singly linked list.Order of even and
> odd numbers must be same
how to find kth smallest element in BST...
--
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.
segregate even and odd nodes in a singly linked list.Order of even and
odd numbers must be same...
e.g:-
i/p list is 4->1->3->6->12->8->7->NULL
o/p list 4->6->12->8->1->3->7->NULL
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to th
Hey guys, phone usually has comparatively very less memory. So, we
can't afford to have pointers for each phone no. So, the idea of
having a tree is rooted out. The best way can be to use a fixed array
with circular indexing which is sorted by name, because the most
frequent query is to search a pe
How to find a path in a given binary tree which sums up to a given target
value?
for example if the given BT is
5
/ \
3 2
/
7
and if the target is 10, then the path is root(5) + left node(3) +
right node (2).
--
You received this message because you are subscribed to the Google Gro
@MONSIEUR Use Binary Search Tree as the data Structure to store the values
for the Phone numbers because insertion and deletion is easy plus you will
get the additional advantage of sorted list of phone numbers . So Binary
search tree is better than using hash data structure .
Regards
Rajeev N B
1 - 100 of 125 matches
Mail list logo