Re: [algogeeks] Implement a Queue using a stack

2010-02-08 Thread MOHIT ....
but question is how to implement using one stack not two S1 and S2 -- 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

Re: [algogeeks] Can you try your own implementation of a mymalloc function

2010-02-08 Thread Sathaiah Dontula
Hi, You can allocate memory for multiple of 16 bytes ( 16 * n, where is the your desired size) + some extra memory to track which is allocated or freed, and then use your mymalloc and get the memory from allocated block and use it, this way it will be efficient I feel. Thanks, Sathaiah Dontula

Re: [algogeeks] Implement a Queue using a stack

2010-02-08 Thread atul verma
I dont think its possible to implement a queue using a single stack. Atul On Mon, Feb 8, 2010 at 7:48 AM, MOHIT mohit...@gmail.com wrote: but question is how to implement using one stack not two S1 and S2 -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Implement a Queue using a stack

2010-02-08 Thread MOHIT ....
@atul : what u think about this method suppose if we implemented in array 1. for insert push in stack 2.for pop use a variable nd reverse stack in array -pop element form stack -again reverse ; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

Re: [algogeeks] Implement a Queue using a stack

2010-02-08 Thread Pravin sinha
I guess you can do it using recursion(if allowed). Insert is any way straight forward(just by pushing onto the stack) but for removal you can do something like. remove() { topVal = stack.pop(); if(stack.isEmpty()) { //this is the only element return topVal } // get the last element

Re: [algogeeks] Implement a Queue using a stack

2010-02-08 Thread MOHIT ....
On Mon, Feb 8, 2010 at 2:13 PM, MOHIT mohit...@gmail.com wrote: @atul : what u think about this method suppose if we implemented in array 1. for insert push in stack 2.for pop use a variable nd reverse stack in array -pop element form stack -again reverse ; -- You received this

Re: [algogeeks] Implement a Queue using a stack

2010-02-08 Thread CHERUVU JAANU REDDY
This is code for queue using single stack #includestdio.h #includestdlib.h #define MAX 30 int stack[MAX],top=-1; void push(int num) { top++; if(top==MAX-1) { printf(Queue overflow\n); exit(0); } stack[top]=num; } int pop() { if(top==-1) {

Re: [algogeeks] Implement a Queue using a stack

2010-02-08 Thread chandra sekhar varma
As we have the standard implementation for the Queue using two stacks, i think we can use that logic here. by using the Operating system stack as the second stack, i mean to say using recursion we can achieve it. Suppose we call the stack as S1 and it has two functions namely push and pop, The

[algogeeks] Cartesian Product in set theory

2010-02-08 Thread pinco1984
Hi all, I have came across a problem and I am not aware if there is such a thing in set theory and if so what is it called. Mainly I have several sets that I am interested in their cartesian product. But this cartesian product should not be a set of ordered pairs but a set of sets. Basically

Re: [algogeeks] Re: Find parent/grandparent relationship of nodes in binary tree in O(1) time

2010-02-08 Thread saurabh gupta
@Manisha can u pls elaborate, ith node index lies in a range ? extending Bijlwan's solution, node numbering on each new level begins by multiplying the index of the leftmost node in previous level by 2^k and then in incrementing it by one. and while one checks one shifts by k. On Sat, Feb 6,

[algogeeks] Call for Papers: CGVR'10 (The 2010 International Conference on Computer Graphics and Virtual Reality), USA, July 2010

2010-02-08 Thread A. M. G. Solo
It would be greatly appreciated if this announcement could be shared with individuals whose research interests include computer graphics and virtual reality. Thanks. --- CALL FOR PAPERS CGVR'10 The 2010 International Conference on