@shashi: once we have two pointer where anomalies exist, we can exchange
their data value to obtain original BST...
On Wed, Sep 5, 2012 at 12:38 PM, shashi kant shashiski...@gmail.com wrote:
Is it required only to retain the BST property ?? or to retain the
original BST (tree)
*Shashi
that what i mentioned finding original BST or a correcting the BST property
...
my method will only maintains the BST property...
--
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.
Is it required only to retain the BST property ?? or to retain the
original BST (tree)
*Shashi Kant *
***Think positive and find fuel in failure*
http://thinkndoawesome.blogspot.com/
*System/Software Engineer*
*Hewlett-Packard India Software Operations.
*
On Tue, Sep 4, 2012 at 1:56 PM,
@Shashi : i dont see any differencebcoz only 2 nodes are swapped
..after correcting it...it shud maintain BST property wich automatically
retain original tree
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
well in that case there can be simpler ways to do it
do an inorder traversal while checking prevcurnext ordering maintained
if not then make it in proper order ,although whole tree has to be
traversed to fix it.
*Shashi Kant *
***Think positive and find fuel in failure*
@Shashi : please check previous discussion on this thread.
On Wed, Sep 5, 2012 at 2:09 PM, shashi kant shashiski...@gmail.com wrote:
well in that case there can be simpler ways to do it
do an inorder traversal while checking prevcurnext ordering maintained
if not then make it in proper order
@atul: correctly caught...
here you have to notice that if u get only one violation not second
violation ill the last... then sure the violation is created because of
swapping of previous and current of first violation...
so when you got first violation and put first marker on previous time put
while doing in-order traversal, we have to check if(prev current) --
then mark prev element for swapping in the first time violation..
if it happens for the second time..then mark current element for swapping.
swap both ..
If we don't get the violation for the second time .. means both are
@bharat: +1
i have tried some test cases.. working finely.. @anyone pls verify??
On Mon, Sep 3, 2012 at 11:58 AM, bharat b bagana.bharatku...@gmail.comwrote:
while doing in-order traversal, we have to check if(prev current) --
then mark prev element for swapping in the first time violation..
@rahul : Here are the boundary cases need to be taken care of :-
suppose given BST is the following :-
root=allocate(70);
root-right=allocate(75);
root-left=allocate(50);
root-left-left=allocate(20);
root-left-left-right=allocate(25);
root-left-left-left=allocate(10);
i guess i missed this part of bharat post :-
/*
If we don't get the violation for the second time .. means both are
side-by-side elements .. swap them ..
*/
i was saying the same.so it will work.
On 9/4/12, atul anand atul.87fri...@gmail.com wrote:
@rahul : Here are the boundary cases need
help to solve the following..
Question: Two of the nodes of a BST are swapped. Correct the BST (taken
from GeekforGeeks http://www.geeksforgeeks.org/archives/23272 2nd online
test 3rd question)
--
Thanks and Regards:
Rahul Kumar Patlehttp://www.linkedin.com/profile/view?id=106245716trk=tab_pro
void correctBST(struct node *root)
{
int flag =0;
static struct node *temp1, *temp2, *temp3, *prev;
static int found;
if(found) return;
if(root) {
correctBST(root-left);
if(!temp1 prev root-data prev-data) {
temp1 = prev;
temp2 = root;
@navin: can u explain ur algorithms in words pls..
On Sun, Sep 2, 2012 at 5:53 PM, Navin Kumar algorithm.i...@gmail.comwrote:
void correctBST(struct node *root)
{
int flag =0;
static struct node *temp1, *temp2, *temp3, *prev;
static int found;
if(found) return;
if(root) {
dis was asked in MS written
U r given a string u need to print all cases of letters without
changing the order
eg:-
ABC,Abc,ABc,aBC,abC etc...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
void allCase(string r)
{
int n = s.sise();
string s;
for (i = 0; i (1 n); i++)
{
s = r;
for ( j = 0; j n; j++)
{
if ( i ( 1 j) )
{
s[j] = s[j] + ('a' - 'A');
}
}
@bharat: When each step of nishant's algo is O(n) how can it sum up to
O(nlogn)???
On Tue, Sep 13, 2011 at 9:18 AM, bharatkumar bagana
bagana.bharatku...@gmail.com wrote:
@nishant : your algo takes O(nlogn) time with higher constant behind
this. can't we write better than this ?
@sairam
@jai gupta : merge sort for 2 sorted arrays --O(nlogn) right?
On Tue, Sep 13, 2011 at 1:03 PM, jai gupta sayhelloto...@gmail.com wrote:
@bharat: When each step of nishant's algo is O(n) how can it sum up to
O(nlogn)???
On Tue, Sep 13, 2011 at 9:18 AM, bharatkumar bagana
@ bharat: merging 2 sorted arrays is O(n)
On Tue, Sep 13, 2011 at 12:42 AM, bharatkumar bagana
bagana.bharatku...@gmail.com wrote:
@jai gupta : merge sort for 2 sorted arrays --O(nlogn) right?
On Tue, Sep 13, 2011 at 1:03 PM, jai gupta sayhelloto...@gmail.comwrote:
@bharat: When each
Hey guys!
I wanted to know what questions microsoft has asked in subjective test
of the apti?
Normally they have 3 different Qs for 3 profiles namely, s/w
developer, tester program manager.
Hence, it is typical to find 3 Qs like Write a prog for this... Find
the o/p of this... Design the system
@nishant : your algo takes O(nlogn) time with higher constant behind
this. can't we write better than this ?
@sairam : will u pls provide implementation logic of u'r idea ..
On Mon, Sep 12, 2011 at 12:43 PM, Sairam Ravu ravu...@gmail.com wrote:
By merging smaller trees into larger trees we
MERGE 2 BINARY SEARCH TREES?
HOW TO DO IT?(POST AN EFFICIENT ALGORITHM)
--
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
convert the binary search tree into a sorted linked list. After flattening
construct the tree out of it.
And please don't use capital letters unnecessarily. It reflects bad on you.
On Sun, Sep 11, 2011 at 7:29 AM, teja bala pawanjalsa.t...@gmail.comwrote:
MERGE 2 BINARY SEARCH TREES?
HOW TO
If you're familiar with the ? operator x ? y : z
you have to implement that 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
There are set of coins of {50,25,10,5,1} paise in a box.Write a
program to find the number of ways a 1 rupee can be created by
grouping the paise.
post ur code.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
O(n/a)
where n is the required sum which is to be created by grouping the coins
and a is the coin of smallest denomination
so, O(n) in the worst case
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
On Sat, Sep 10, 2011 at 11:22 AM, Neha Singh neha.ndelhi.1...@gmail.com wrote:
O(n/a)
For every n, it would add values for W(n-v1), W(n-v2),..., W(n-vm), if
there are m denominations of coins. So the complexity would be O(nm).
Also, this can be implemented in two ways. Top-down (which is what I
@Gaurav
wat if here is n=1
den
W(0)=?
i dint get that
--
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
On Sat, Sep 10, 2011 at 11:28 AM, teja bala pawanjalsa.t...@gmail.com wrote:
@Gaurav
wat if here is n=1
den
W(0)=?
i dint get that
See, when you get to W(0) state, that means, you have created a valid
combination. That means, you have gone through one 'path' through the
various
we hv to just fill an array of size n, so complexity should be O(n) in worst
case
--
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
No. I think you should revisit complexity. That's not how it works.
Factoring a million digit number outputs two numbers. It should take
O(1), right? :D
On Sat, Sep 10, 2011 at 11:56 AM, Neha Singh neha.ndelhi.1...@gmail.com wrote:
we hv to just fill an array of size n, so complexity should be
Write a C code to find Leftmost right cousin at the same level.
For ex:
10
/\
2 3
/\ /\
8 56 9
Leftmost right cousin of 5 is 6. Leftmost right cousin of 3 is NULL
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*
--
You received this message because you are subscribed to the
They also asked us to find the output of 2 C pgm involving pointers for 5
marks.
On Wed, Feb 2, 2011 at 3:04 PM, Ricky rajeevpo...@gmail.com wrote:
Hi Guys,
I want to know about questions asked in written test for Microsoft.
I come to know that it will be for 1.5 hours and it will consists
Hi Guys,
I want to know about questions asked in written test for Microsoft.
I come to know that it will be for 1.5 hours and it will consists of
questions from c,C++ and data structure. I am writing the test this
weekend only. So please send me questions ASAP.
--
You received this message
Hi there, can you share some of the Microsoft phone interview questions.?
On Thu, Jan 27, 2011 at 6:47 AM, Ankit Babbar ankitbabba...@gmail.comwrote:
Hey all...Can anyone provide me with the recent (/most common) written test
questions(or links ) of Microsoft IDC and Microsoft IT SDE
http://www.cracktheinterview.org/category/company-wise/microsoft/
but these are all subjective type...need MCQ's..!!
On Thu, Jan 27, 2011 at 9:39 AM, Umer Farooq the.um...@gmail.com wrote:
Hi there, can you share some of the Microsoft phone interview questions.?
On Thu, Jan 27, 2011 at 6:47
Hey all...Can anyone provide me with the recent (/most common) written test
questions(or links ) of Microsoft IDC and Microsoft IT SDE positions...??
Thanks in advance..
Regards,
Ankit.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
37 matches
Mail list logo