Re: [algogeeks] Re: swap objects without temp variable

2012-11-04 Thread Ashok Varma
Try this: a = a + b - (b = a); //single line code to swap On Mon, Nov 5, 2012 at 4:53 AM, Dave wrote: > @Manish: Sure. > > a = a + b; > b = a - b; > a = a - b; > > In 2-s complement arithmetic, it works even if a + b overflows. > > Dave > > On Sunday, November 4, 2012 2:32:43 PM UTC-6, manish

[algogeeks] Make File

2012-11-04 Thread Ashok Varma
Friends, Please clarify this. What is a Make file ? & What is its use ? -- 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+

Re: [algogeeks] Re: C prog o/p

2012-10-16 Thread Ashok Varma
i - j is giving -3 as output. why is this so ? On Tue, Oct 16, 2012 at 11:18 PM, iwill wrote: > how to explain the output if instead of j-i we try to print i-j ? > > > On Saturday, October 13, 2012 3:36:49 PM UTC+5:30, bharat wrote: >> >> #include >> main() >> { >> int *i,*j; >> i=(int*)60; >>

Re: [algogeeks] C prog o/p

2012-10-13 Thread Ashok Varma
where right? > 0x11 = 3 in decimal format not 11 base 10. > > typecasting to (int*) needs an address right? > I mean > int b=10; > int * a=(int*)&b; > > > > On Sat, Oct 13, 2012 at 9:10 PM, Ashok Varma wrote: > >> This gives a clear explanation: >>

Re: [algogeeks] C prog o/p

2012-10-13 Thread Ashok Varma
This gives a clear explanation: #include main(){ int *i,*j; i=(int*)60; j=(int*)71; printf ("%p %p %d",i,j,j-i);} op: 0x3c 0x47 2 0x47 - 0x3c = 0x11 and hence j-1 = 2 (11/4 = 2, size of int = 4 bytes) On Sat, Oct 13, 20

Re: [algogeeks] Assembly Output ADOBE question

2012-10-13 Thread Ashok Varma
what does the stack initially hold ? On Sat, Oct 13, 2012 at 4:18 PM, Akshat Sapra wrote: > > DETERMINE THE OUTPUT R1,R2,R3 ARE THREE REGISTERS > > START :POP R1 > POP R2 > COMPARE R2,0 > JUMP_EQ DONE_Z > PUSH R2 > PUSH R1 > SUBTRATCT R2,1 > PUSH R2 > CALL START > POP R3 > POP R1 > POP R2 > MULT

[algogeeks] Data Cache implementation problem

2012-08-10 Thread Varma Selvaraj
the right data structure and find the right algorithm for the scenario? Can anyone help on this question? Thanks and Regards, Varma -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@google

[algogeeks] SPOJ TLE

2011-12-05 Thread varma C.S.P
I am getting a lot of tle's for this problem. https://www.spoj.pl/problems/BUGLIFE/ Here is my code #include #include #include using namespace std; int g[2001][2001]; int color[2001]; short stack[5001]; int bugs, rel; int inline complement(int n); bool inline dfs(); int v1, v2; int main() {

[algogeeks] Re: STRING help

2011-09-30 Thread Mohan Varma
There's no data type called string in C. Strings are represented as plain char arrays with a null character '\0' at the end.All the string functions like strlen() rely upon this convention. I'm not much familiar to C++, but C++ has a string data type. On Sep 30, 10:27 am, rahul sharma wrote: > w

[algogeeks] Link on Interview Questions

2011-06-19 Thread Shivaji Varma
Hi folks, Please take a look at this link on Interview questions. Hope it will be useful for you folks! http://mycsinterviewsexperiences.blogspot.com/ -- Shivaji "Never Say Never!!" -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to

Re: [algogeeks] Re: Difference btwn elements in a sorted array a-b=k

2011-06-07 Thread Shivaji Varma
h for 6 using ur algo > > On 6/7/11, Shivaji Varma wrote: > > How about this? > > > > Take two pointers, one pointing to the first element in the array and > second > > one pointing to second element in the array. If the difference is less > than > > 'k&

Re: [algogeeks] repeted element

2011-06-07 Thread Shivaji Varma
This problem of finding first non-repeating element in an array is different from finding the first non-repeating character in a string. The latter is a pretty easy one. On Wed, Jun 8, 2011 at 12:12 AM, Anand wrote: > > http://anandtechblog.blogspot.com/2011/06/first-repeating-character-in-strin

Re: [algogeeks] Re: Difference btwn elements in a sorted array a-b=k

2011-06-07 Thread Shivaji Varma
nd search for 6 using ur algo > > On 6/7/11, Shivaji Varma wrote: > > How about this? > > > > Take two pointers, one pointing to the first element in the array and > second > > one pointing to second element in the array. If the difference is less > than > > &

Re: [algogeeks] Re: Difference btwn elements in a sorted array a-b=k

2011-06-07 Thread Shivaji Varma
How about this? Take two pointers, one pointing to the first element in the array and second one pointing to second element in the array. If the difference is less than 'k', increment the second pointer and if the difference is greater, increment the first pointer. And if pointer 1 exceeds pointer

Re: [algogeeks] MS interview question

2011-05-31 Thread Shivaji Varma
Hi, Please take a look at this link. http://mycsinterviewsexperiences.blogspot.com/ -- Shivaji On Wed, Jun 1, 2011 at 6:26 AM, Anand wrote: > Given a linked list of the form, 1->2->3->4->5->6, convert it into the form > 2->1->4->3->6->5. Note that the nodes need to be altered and not the dat

[algogeeks] Link to my Interview Experiences Blog

2011-05-21 Thread Shivaji Varma
http://mycsinterviewsexperiences.blogspot.com/ -- 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.

[algogeeks] Re: pointer and array

2010-07-26 Thread Varma
1.Array name is nothing but a const pointer to the first element of an array. 2.subscripting of an array can be visualized as incrementing a pointer . Pointer always increments by the size of the type of data it holds. 3. so, always sizeof(arr) is the sizeof a pointer , and sizeof(*arr) is the si

Re: [algogeeks] Re: isbst

2010-07-05 Thread CM Saikanth Varma
@Divya Jain: In the algorithm I gave, please note that, the *max value in left subtree* should be *smaller than* the current node's key, which inturn should be *smaller than* the *min value in right subtree*. That way, my algorithm would return "false" for the example which you gave. On Sun, Jul 4

Re: [algogeeks] Re: isbst

2010-07-01 Thread CM Saikanth Varma
Hi, The idea is like this: Isbst(node *t){ if(t==NULL){ return true; } if ( Isbst(t->left) && Isbst(t->right) && (maxValue(t->left) <=(t->data) ) && (minValue(t->right) >= (t->data) ) return true; else return false; } I hope it makes s

[algogeeks] Call a function before main() in C

2010-06-29 Thread Varma
Hi All, Is there any way to call our function before main() is called ? I know there is a way in C++ as below , but Is there a standard way in C ? #include class CStatic { public: CStatic() { cout << "Before Main!" << endl; } ~CStatic() { cout << "After Main!" << endl; } }; CStatic cs

Re: [algogeeks] Where does OS scheduling run??

2010-05-02 Thread CM Saikanth Varma
interrupt occurs, the kernel will get to know that the time quantum assigned to the current process has expired and then it loads the next waiting process to execute on the CPU. Hope this helps. -- CM Saikanth Varma On Sun, May 2, 2010 at 10:25 PM, praba garan wrote: > @ Pradeep >

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 imp

[algogeeks] Re: Design a stack to perform push(), pop() and retrieve minimum in constant time.

2009-10-16 Thread chandra sekhar varma
Hi Guys A more space efficient solution is here push(x) { if stack.empty() { stack.push(x); stack.push(x); } else { if x > stack.top() { min = stack.pop() stack.push(x) stack.push(min) } else

[algogeeks] Re: Citrix interview question

2009-09-15 Thread CM Saikanth Varma
The answer is indeed 56. Explanation: Increment operator has highest priority so (i++)*(i++) will be evaluated as (7)*(8)=56 This is valid only in C On Tue, Sep 15, 2009 at 6:45 PM, nitin mathur wrote: > @ Tanmoy > Same logic I explained..interviewer didn't give me any clue whether > the explaina