@piyush:what does this two virtual pointers storing???nd how does they help
in eliminating ambiguity??
On Mon, Jul 4, 2011 at 4:08 AM, T3rminal piyush@gmail.com wrote:
@abc abc
4th class= two ints from X and Y classes + one int from base class( as
this class is shared ) + 2 virtual
class A
{ public:
void g(int i)
{ coutin a;
}
};
class B:public A
{ public:
void f()
{ coutin b;
}
};
int main()
{ B b;
b.f(); //vl call b::f()
b.g(4); //vl call a::g()
}
but
class A
{ public:
#Iincludestdio.h
#includestring.h
main()
{
char str[]=S\061AB;
printf(\n%d,strlen(str));
}
output:4
why?
--
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
because \061 is considered as a single char in ur string..
On Mon, Jul 4, 2011 at 12:52 PM, Sangeeta sangeeta15...@gmail.com wrote:
#Iincludestdio.h
#includestring.h
main()
{
char str[]=S\061AB;
printf(\n%d,strlen(str));
}
output:4
why?
--
You received this message because you are
when u use post increment operator in an expression and there is sequence
point like || or then value of post increment counted in expression other
wise not
On Mon, Jul 4, 2011 at 11:24 AM, Navneet Gupta navneetn...@gmail.comwrote:
I think one rule of thumb for reading pre and post increment
ok,thanx
On Jul 4, 12:29 pm, Vishal Thanki vishaltha...@gmail.com wrote:
because \061 is considered as a single char in ur string..
On Mon, Jul 4, 2011 at 12:52 PM, Sangeeta sangeeta15...@gmail.com wrote:
#Iincludestdio.h
#includestring.h
main()
{
char str[]=S\061AB;
This happens because the Derived class's member *hides* the base class's
member.
Irrespective of the number/type of parameters.
The solution to solve this problem is to either add an using declaration in
the derived class.
e.g. *using A::f;*
this will bring f(int) of class A within the scope of
Continuous memory allocation is used for 2-d array.
So a[2][5] will assign 10 continuous memory spaces.
Hello will be stored on the 1st 5 spaces. Hi will be saved on the next 2
consecutive spaces itself.
There is no null character saved for the 1st string so while printing it
prints until it finds
If you try to visualize the internal representation.
You've allocated 10 bytes.
| h | e | l | l | o |
| h | i |\0 |\0 |\0 |
Since these are stored in linear form, so the actual representation would be
| h | e | l | l | o | h | i |\0 |\0 |\0 |
Now a[0] points to 'h' in the first row, and printf
Lets conclude this post.Shall we?
.An o(n) seems infeasible without any significant extra memory
If extra memory is allowed,hash maps can be used to bring it down to
o(logn).But hash maps would eat up serious memory if numbers occupy a large
range.
--
You received this message because you
@Sagar
if it has a large no of data fields than don't u think just changing
pointers will be much better than swapping all the data contained in the
node
On Mon, Jul 4, 2011 at 11:13 AM, sagar pareek sagarpar...@gmail.com wrote:
@Anantha Krishnan
Well be specific
just read the question
thanx i got it :)
On Mon, Jul 4, 2011 at 2:05 PM, Sandeep Jain sandeep6...@gmail.com wrote:
If you try to visualize the internal representation.
You've allocated 10 bytes.
| h | e | l | l | o |
| h | i |\0 |\0 |\0 |
Since these are stored in linear form, so the actual representation would
chk_bst doesnt works as its checking only for its immediate child's values.
i think inorder non decreasing sequence checking would require here which is
iteratively programmed
surender
On Thu, Jun 30, 2011 at 4:05 PM, Apoorve Mohan apoorvemo...@gmail.comwrote:
1.
int chk_bst(node *root)
{
-- Forwarded message --
From: geek forgeek geekhori...@gmail.com
Date: Mon, Jul 4, 2011 at 2:58 PM
Subject: segment tree
To: algog...@googlegroups.com
can any1 plz tell some gud tutorial for segment tree?
--
You received this message because you are subscribed to the Google
@surender: in the while loop all the nodes are being checked...please tell
me where u r stuck???
On Mon, Jul 4, 2011 at 2:13 PM, surender sanke surend...@gmail.com wrote:
chk_bst doesnt works as its checking only for its immediate child's values.
i think inorder non decreasing sequence
seems its failing for
3
2 5
1 4 N N
Surender
On Mon, Jul 4, 2011 at 3:12 PM, Apoorve Mohan apoorvemo...@gmail.comwrote:
@surender: in the while loop all the nodes are being checked...please tell
me where u r stuck???
On Mon, Jul 4, 2011 at 2:13 PM, surender sanke
CLRS Exercises 32.2-2
How would you extend the Rabin-Karp method to the problem of searching a
text string for
an occurrence of any one of a given set of k patterns? Start by assuming
that all k patterns
have the same length. Then generalize your solution to allow the patterns to
have different
@surender: ok man...got it...thanks :)
On Mon, Jul 4, 2011 at 3:28 PM, surender sanke surend...@gmail.com wrote:
seems its failing for
3
2 5
1 4 N N
Surender
On Mon, Jul 4, 2011 at 3:12 PM, Apoorve Mohan apoorvemo...@gmail.comwrote:
@surender: in the while loop
think it might work.. its a variant of in order iterative version.. checking
each time previous value from current node's data
bool isBST(tree *t)
{
if(!t)
return true;
bool done = false;
int last_value = INT_MIN;
Stack s;
while(!done)
{
if(t)
{
s.push(t);
t=t-left;
}
else
Thanku sir...:)
On Mon, Jul 4, 2011 at 1:59 PM, Sandeep Jain sandeep6...@gmail.com wrote:
This happens because the Derived class's member *hides* the base class's
member.
Irrespective of the number/type of parameters.
The solution to solve this problem is to either add an using declaration
can any one give the algo to produce school time table?
--
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 Mon, Jul 4, 2011 at 3:54 PM, amit the cool amitthecoo...@gmail.comwrote:
main()
{
int i=0;
while(+(+i--)!=0)
Here the value passed of i is 0 only. So the next statement does not
execute. But after using, I gets decremented to -1
i-=i++;
printf(%d,i);
}
output sud be 1
bt it is -1;
any1
--
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 group at
in this actually whats happening is :
int i=0;
while((i--)!=0)
i-=i++;
printf(%d\n,i);
here when i is compared to 0 i is 0 and then it is decremented to -1, while
loop never gets executed.
On Mon, Jul 4, 2011 at 3:54 PM, amit the cool amitthecoo...@gmail.comwrote:
main()
{
int i=0;
In while loop, the value of i will be used as 0 as it is post decrement so
the value of i will decrement after the while loop is executed.
so 0!=0 will fail and the value of i will get decrement and will be printed
as -1.
On Mon, Jul 4, 2011 at 3:54 PM, amit the cool amitthecoo...@gmail.comwrote:
Hi All,
I want to know which data structure will be efficient for a desktop search
tool similar to Ava Find http://www2.think-less-do-more.com/avafind/.
Thanks Regards
Anantha Krishnan
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
Try this:
http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor
On Jul 4, 5:15 pm, geek forgeek geekhori...@gmail.com wrote:
any1
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
I'm trying to solve this problem: www.spoj.pl/problems/TAILS
I tried of eliminating 1's from left to right and from right to left
and printed the minimum among them.
I got WA. Any other ideas to proceed this problem?
--
You received this message because you are subscribed to the Google Groups
How to implement a QUEUE using a singly link list such that the operations
ENQUEUE and DEQUEUE takes O(1) time ?
--
best wishes!!
Vaibhav Shukla
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
thanx @991..
yeah i read it..
but i didnt get how to update the tree they havnt hav given tht.
is their any good pdf file with any1 on the grup...
plz share it !!
On Mon, Jul 4, 2011 at 6:50 PM, 991 guruprakash...@gmail.com wrote:
Try this:
always maintain front and rear pointers, updating them accordingly during
insertion and deletion can achieve this in O(1)
surender
On Mon, Jul 4, 2011 at 9:59 PM, vaibhav shukla vaibhav200...@gmail.comwrote:
How to implement a QUEUE using a singly link list such that the operations
ENQUEUE
bss bss.. i got it... :)
no more answers to this post now.
thank you
On Mon, Jul 4, 2011 at 10:20 PM, surender sanke surend...@gmail.com wrote:
always maintain front and rear pointers, updating them accordingly during
insertion and deletion can achieve this in O(1)
surender
On Mon, Jul 4,
How bout I say, the insertion and deletion functions have the following
prototype?
void enqueue(NODEPTR q, int data)
int deque(NODEPTR q)
You are not allowed to maintain two pointers, i.e. no front and no rare
pointers...
Regards,
Sandeep Jain
Member of Technical Staff, Adobe Systems, India
thanx guys...
On Mon, Jul 4, 2011 at 5:11 PM, mahesh.jnumc...@gmail.com
mahesh.jnumc...@gmail.com wrote:
In while loop, the value of i will be used as 0 as it is post decrement so
the value of i will decrement after the while loop is executed.
so 0!=0 will fail and the value of i will get
Tree has an extra pointer next apart from left and right. Objective
is to set next pointer to point to node successor in the tree.
Following the next pointer, we would be able to produce sorted list.
Looking for both a recursive and non-recursive approach.
--Navneet
--
You received this
I think Threaded Binary Tree solves your Problem
see this http://en.wikipedia.org/wiki/Threaded_binary_tree
On Mon, Jul 4, 2011 at 11:34 PM, Navneet Gupta navneetn...@gmail.comwrote:
Tree has an extra pointer next apart from left and right. Objective
is to set next pointer to point to node
Use the concept used in Morris traversal (same as TBT concept)...
On 7/4/11, sunny agrawal sunny816.i...@gmail.com wrote:
I think Threaded Binary Tree solves your Problem
see this http://en.wikipedia.org/wiki/Threaded_binary_tree
On Mon, Jul 4, 2011 at 11:34 PM, Navneet Gupta
http://geeksforgeeks.org/?p=6358
On 7/4/11, Piyush Sinha ecstasy.piy...@gmail.com wrote:
Use the concept used in Morris traversal (same as TBT concept)...
On 7/4/11, sunny agrawal sunny816.i...@gmail.com wrote:
I think Threaded Binary Tree solves your Problem
see this
@t3erminal u r right!!!
thanks
surender
On Mon, Jul 4, 2011 at 4:16 PM, T3rminal piyush@gmail.com wrote:
@himanshu: http://en.wikipedia.org/wiki/Virtual_inheritance
Go through the last paragraph before reference.
On Jul 4, 12:02 pm, himanshu kansal himanshukansal...@gmail.com
wrote:
@Piyush, it is not about the traversal, you actually have to establish
those links such that once they are established, inorder traversal
would be just like traversing a list.
@Sunny - thanks, exactly what i was looking for
On Mon, Jul 4, 2011 at 11:45 PM, Piyush Sinha ecstasy.piy...@gmail.com
I know its not about the traversali just suggested that one can
use the trick used by Morris traversal to locate the next node of the
inorder traversal...
On 7/4/11, Navneet Gupta navneetn...@gmail.com wrote:
@Piyush, it is not about the traversal, you actually have to establish
those links
U only mentioned in ur question that we have to use next pointer to
connect the nodes...while TBT used the left and right pointers
On 7/5/11, Piyush Sinha ecstasy.piy...@gmail.com wrote:
I know its not about the traversali just suggested that one can
use the trick used by Morris traversal
This is a problem of attribute evaluation. Pick the right attributes,
and it's not hard.
Note this code is not tested, but it ought to work fine.
// return value is the last node visited in reverse order.
// prev is the previous node in reverse order
NODE *inorder_set(NODE *node, NODE *prev)
{
convert BST into DLL
refer stanford tree recursion problem
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Mon, Jul 4, 2011 at 11:34 PM, Navneet Gupta navneetn...@gmail.comwrote:
Tree has an extra pointer next apart from left and right.
Binary Tree sorting entries on lexicographic order O(logn) search
On Mon, Jul 4, 2011 at 8:40 AM, Anantha Krishnan
ananthakrishnan@gmail.com wrote:
Hi All,
I want to know which data structure will be efficient for a desktop search
tool similar to Ava Find
Here is the modified version of Morris inorder tree traversal
algorithmhttp://stackoverflow.com/questions/5502916/please-explain-morris-inorder-tree-traversal-without-using-stacks-or-recursion
inordermorrisiterative(Tnode *root) {
Tnode *current = root, *pred = NULL, *succesor = NULL;
what abt this...
check length of the array if same then we make a min heap of both the
arrays which can be done in O(n) and call extraxtmin(). in this way we can
find whether they r equal.
othwersie nt equal.
correct me if i am wrong!!
On Mon, Jul 4, 2011 at 4:35 AM, saurabh singh
@sandeep what is ptr q in case of enqueue?
On Mon, Jul 4, 2011 at 12:53 PM, Sandeep Jain sandeep6...@gmail.com wrote:
How bout I say, the insertion and deletion functions have the following
prototype?
void enqueue(NODEPTR q, int data)
int deque(NODEPTR q)
You are not allowed to maintain
Again heap will require extra space.
On Tue, Jul 5, 2011 at 8:25 AM, vaibhav agarwal
vibhu.bitspil...@gmail.comwrote:
what abt this...
check length of the array if same then we make a min heap of both the
arrays which can be done in O(n) and call extraxtmin(). in this way we can
find
@saurabh bt we need only one extra array
On Mon, Jul 4, 2011 at 11:02 PM, saurabh singh saurab...@gmail.com wrote:
Again heap will require extra space.
On Tue, Jul 5, 2011 at 8:25 AM, vaibhav agarwal
vibhu.bitspil...@gmail.com wrote:
what abt this...
check length of the array if same
@Vaibhav: Construction of a heap can be done in-place, but time
complexity is O(n log n).
Dave
On Jul 4, 9:55 pm, vaibhav agarwal vibhu.bitspil...@gmail.com wrote:
what abt this...
check length of the array if same then we make a min heap of both the
arrays which can be done in O(n) and call
@Saurabh: Nope. You can construct a heap in-place. But it is not O(n).
Dave
On Jul 4, 10:02 pm, saurabh singh saurab...@gmail.com wrote:
Again heap will require extra space.
On Tue, Jul 5, 2011 at 8:25 AM, vaibhav agarwal
vibhu.bitspil...@gmail.comwrote:
what abt this...
check
Its the queue in which you want to add a an element.
Small correction in the enqueue signature.
void enqueue(NODEPTR q, int data) // made it a reference, I missed it
And the usage would be something like
NODEPTR myQueue = NULL;
enqueue(myQueue, 10);
enqueue(myQueue, 20);
coutdeque(myQueue);
@sandeep
if enqueue is pass by reference and dequeue as pass by value
then i think enqueue will be on headjust like stack so it will be O(1)
but for dequeue we need to traverse down the list and remove the last node
O(n)
and if enqueue is made to pass by value and dequeue as pass by
@Sandeep: Without storing explicit pointer to last element, how would you be
able to access last element in a Singly Linked List in O(1) ??? Is there
any parallel data structure that needs to be maintained ?? and if it is
larger than size of 2 explicit pointers to last and first elements then 2
OOPS... I missed again, my bad... both enqueue and deque can take reference.
(Sincere apologies...)
NO separate data structure is needed.
And both operations can definitely be done, in O(n).
BTW even if you don't take the reference variable in deque, it can be
solved. :) :)
Regards,
Sandeep Jain
56 matches
Mail list logo