[algogeeks] Median Finding in Sorted Arrays

2014-01-05 Thread Sanjay Rajpal
Hi guys, Please help me in finding median of two sorted arrays of length m and n in minimum possible time. Thanks, Sanjay -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, sen

Re: [algogeeks] Re: Highest reminder

2013-05-30 Thread Sanjay Rajpal
23 = 11 * 2 + 1 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] Re: Highest reminder

2013-05-29 Thread Sanjay Rajpal
Hi Ankit, for 23, how can the remainder be 12 ? Can you elaborate more ? *Regards,* *Sanjay Kumar* *Software Engineer(Development)* *Winshuttle Softwares(India) Pvt. Ltd.* *Mobile +91-89012-36292, +91-80535-66286* *Email: sanjay.ku...@winshuttle.com* * *** * * ** * * On Thu, May 30, 2013 at 9

[algogeeks] Missing Number Problem

2012-10-04 Thread Sanjay Rajpal
We are given 300 million 9-digit numbers and 2 MB of RAM. We have to find the missing number. How do we approach this problem ? *Regards,* *Sanjay Kumar* * * ** * * -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, se

Re: [algogeeks]

2012-07-18 Thread Sanjay Rajpal
Segmentation fault occurs when you try to access a memory which doesn't belong to your program. You are trying to cast a memory location of one byte to 4 byte(assuming size of long int to be 4). It is possible that other three bytes belong to some other process. That is why you are getting segment

Re: [algogeeks] thanx to all

2012-02-29 Thread Sanjay Rajpal
many congratulations :) * Sanjay Kumar * On Wed, Feb 29, 2012 at 10:59 AM, mohit mishra wrote: > congrats :-) > > > On Wed, Feb 29, 2012 at 10:56 AM, shady wrote: > >> congrats :) >> keep participating and keep learning. >> >> >> On Wed, Feb 29, 2012 at 9:19 AM, atul anand wrote: >> >>> congo

[algogeeks] Literati 2012

2012-02-03 Thread Sanjay Rajpal
LITERATI - the national level annual technical fest of NIT- Kurukshetra(1-4 March 2012) We Promise you 4 days non stop Fun. Mark your presence as a participant, spectator and a witness. For more details, log on to Literati Website and find us on Facebook

Re: [algogeeks] Re: Amazon ques

2012-01-26 Thread Sanjay Rajpal
+1 * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Thu, Jan 26, 2012 at 6:28 PM, Ashish Goel wrote: > replace all 0s by -1 > keep additional array to get the sumHer

[algogeeks] Minimum number of jumps to reach end

2012-01-25 Thread Sanjay Rajpal
Given an array of integers where each element represents the max number of steps that can be made forward from that element. Write a function to return the minimum number of jumps to reach the end of the array (starting from the first element). If an element is 0, then cannot move through that elem

Re: [algogeeks] Lets Discuss About Some More Practical Application of Data Structure & Algorithm , Problem Solving - How You WIll The Mutual Friends Between each m*n friends

2012-01-22 Thread Sanjay Rajpal
Sorry to interrupt Guyzz.. I need ur help. I am not getting the Failure Function of Knuth Morris Pratt Algo for string matching... Plz reply asap Thanx in advance. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, s

[algogeeks] KMP Failure Function Problem

2012-01-21 Thread Sanjay Rajpal
Below is the code for KMP failure function : int F[]; //assume F is a global arary. int Fill-Prefix-Table(int P[], int m) { int i,j; F[0]=0; j=0; i=1; while(i < m) { if(P[i] == P[j]) { F[i]=j+1; i++; j++; } else if(j > 0) { j = F[j-1]; } else { F[i]=0; i++; } } } In the above function,

Re: [algogeeks] sort 2D array

2012-01-11 Thread Sanjay Rajpal
Where do we store the sorted list ? How do we do it in place ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Wed, Jan 11, 2012 at 12:34 AM, Sanjay Rajpal wrote

Re: [algogeeks] sort 2D array

2012-01-11 Thread Sanjay Rajpal
PM, Ankur Garg wrote: > >> @Shady Rows are already sorted ... >> >> >> On Wed, Jan 11, 2012 at 1:53 PM, shady wrote: >> >>> ^^ true, sort the rows and then a K-way merge. >>> >>> >>> On Wed, Jan 11, 2012 at 1:00 PM, Sanjay Rajpal wr

Re: [algogeeks] sort 2D array

2012-01-11 Thread Sanjay Rajpal
Garg wrote: > @Shady Rows are already sorted ... > > > On Wed, Jan 11, 2012 at 1:53 PM, shady wrote: > >> ^^ true, sort the rows and then a K-way merge. >> >> >> On Wed, Jan 11, 2012 at 1:00 PM, Sanjay Rajpal wrote: >> >>> I guess sort the

Re: [algogeeks] sort 2D array

2012-01-10 Thread Sanjay Rajpal
I guess sort the array such that elements are sorted finally in such a way that if we print them row by row, the result is a sorted array. K-way merge can be useful. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 13611

Re: [algogeeks] Maximum size square sub-matrix with all 1s

2012-01-10 Thread Sanjay Rajpal
, atul anand wrote: > i dint get...you should provide more details , if it is all 1 then whole > matrix is a max square.. > > anyways equation to find max sub square is this. > > M[i,j]=R[i,j]==0 ? 0 : 1+min(M[i-1][,j] , M[i][j-1], M[i-1][j-1] ) > > On Tue, Jan 10, 2012 at

[algogeeks] Maximum size square sub-matrix with all 1s

2012-01-10 Thread Sanjay Rajpal
Suggest an algorithm guyzzz. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * -- You received this message because you are subscribed to the Google Groups "Algorith

Re: [algogeeks] Binary Search Problem

2012-01-08 Thread Sanjay Rajpal
int_Max range which was assumed 300.. > > > > On Sun, Jan 8, 2012 at 4:41 PM, Sanjay Rajpal wrote: > >> actually book pages are images. >> >> My question is why second statement may result in overflow ? >> * >> >> Sanjay Kumar >> B.Tech Fin

Re: [algogeeks] Binary Search Problem

2012-01-08 Thread Sanjay Rajpal
, Jan 8, 2012 at 3:07 AM, saurabh singh wrote: > not clear what you are trying to ask...can you quote exactly from the > book? > Saurabh Singh > B.Tech (Computer Science) > MNNIT > blog:geekinessthecoolway.blogspot.com > > > > On Sun, Jan 8, 2012 at 4:34 PM, Sanjay

[algogeeks] Binary Search Problem

2012-01-08 Thread Sanjay Rajpal
In binary search, mid = start + (end-start)/2 is used to avoid overflow, as said by a book. why can't we use mid = (start + end)/2, it says this statement may result in overflow ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kuru

Re: [algogeeks] what is the use of fflush ?

2011-10-09 Thread Sanjay Rajpal
Sorry for previous email, did not read the question properly. Sanju :) On Sun, Oct 9, 2011 at 7:12 PM, Sanjay Rajpal wrote: > After scanning the variable a, you will give a whitespace > character(space,tab or newline), which will also get stored into stdin file. > So next statement

Re: [algogeeks] what is the use of fflush ?

2011-10-09 Thread Sanjay Rajpal
After scanning the variable a, you will give a whitespace character(space,tab or newline), which will also get stored into stdin file. So next statement will scan this whitespace character. fflush(stdin) flushes(clears) the contents of stdin file, so this time scanf will not get whitespace charact

Re: [algogeeks] Attention All Members

2011-10-08 Thread Sanjay Rajpal
This will reduce the no. of people coming to post on this group Sanju :) On Sat, Oct 8, 2011 at 2:33 PM, Ankur Garg wrote: > +1 > > > On Sun, Oct 9, 2011 at 2:07 AM, Sunny wrote: > >> Now All of the messages are being Moderated and will be posted on the >> group only if they are found re

Re: [algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread Sanjay Rajpal
se* > *while* node.parent ≠ *null* *and* node == node.parent.right *do* > node = node.parent > node = node.parent > *while* node ≠ *null* > > Source: Wikipedia > > On Tue, Sep 27, 2011 at 9:13 PM, Sanjay Rajpal wrote: > >> Recursion also requires

Re: [algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread Sanjay Rajpal
Recursion also requires space, so the problem is how to traverse without extra space. Once this is done, nothing is left in the problem. Sanju :) On Tue, Sep 27, 2011 at 8:35 AM, Dheeraj Sharma wrote: > @anshu > can middle element can be found if the no. of nodes are not given... > > > On Tue

Re: [algogeeks] Re: output expalnation?

2011-09-26 Thread Sanjay Rajpal
Compilation error. Definition of b is skipped by Switch statement. so 'b' not declared/defined error will occur. Correct me if m wrong. Sanju :) On Mon, Sep 26, 2011 at 6:38 PM, deepikaanand wrote: > junk value cz b=6 will not get executed > > -- > You received this message because you are su

Re: [algogeeks] Re : Non Decreasing Numbers

2011-09-25 Thread Sanjay Rajpal
Or in other words... for n=2 , answer= (10*11)/2 for n=3, answer= (10*11*12)/(2*3) for n=4, answer = (10*11*12*13)/(2*3*4) Sanju :) On Sat, Sep 24, 2011 at 11:58 PM, Sanjay Rajpal wrote: > let the number of digits be n > then answer would be ((n+9)! ) / (9! * n!) > > > Sanju

Re: [algogeeks] Re : Non Decreasing Numbers

2011-09-24 Thread Sanjay Rajpal
7 7! >> 4 6 6! >> 5 5 5! >> 6 4 4! >> 7 3 3! >> 8 2 2! >> 9 1 1! >> sum 10 55

Re: [algogeeks] Amazon OS question

2011-09-24 Thread Sanjay Rajpal
yah rite answer would be 5 and 4 resp. Sanju :) On Sat, Sep 24, 2011 at 10:04 PM, Dheeraj Sharma < dheerajsharma1...@gmail.com> wrote: > 5 & 4? > > > On Sun, Sep 25, 2011 at 9:33 AM, sivaviknesh s wrote: > >> >> >> >> A parallel program consists of 8 tasks – T1 through T8. Each task requires >>

Re: [algogeeks] Re : Non Decreasing Numbers

2011-09-24 Thread Sanjay Rajpal
Can you plz tell the answer for for 3 answer=? nd for 4 answer=? Sanju :) On Sat, Sep 24, 2011 at 10:39 PM, Dheeraj Sharma < dheerajsharma1...@gmail.com> wrote: > can u plz be more..clear ..with wat the input will consist of.. > wat does this mean > "for 2 answer=55" > does that mean..that how

Re: [algogeeks] Re: MICROSOFT IDC

2011-09-22 Thread Sanjay Rajpal
Saurabh : Thank u very much :) Sanju :) On Thu, Sep 22, 2011 at 6:15 AM, saurabh wrote: > thanx to all > > @sanjay I have shared my interview experience at > http://msidcinterview.blogspot.com/ > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Gee

Re: [algogeeks] MICROSOFT IDC

2011-09-21 Thread Sanjay Rajpal
Hey saurabh, many many congratulations to u. Would u plz tell about the level of difficulty of questions asked in Interview round and also the kind of people they want ? Sanju :) On Wed, Sep 21, 2011 at 8:26 PM, saurabh wrote: > I sincerely thank this group as i got selected in MSIDC only bec

[algogeeks] C Problem

2011-09-17 Thread Sanjay Rajpal
#include int main() { int a=5; printf("Size : %d\n",sizeof( a =15/2)); printf("A is %d.",a); } What will be the value of a now ? Plz explain. Sanju :) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algo

Re: [algogeeks]

2011-09-13 Thread Sanjay Rajpal
A dynamic programming problem . Sanju :) On Tue, Sep 13, 2011 at 9:34 AM, prasanth n wrote: > use dynamic programming.. > > > On Sun, Sep 4, 2011 at 6:46 PM, aditya kumar > wrote: > >> How to find longest common substring in two strings ? >> i want efficent code and iff possible any method

Re: [algogeeks] String

2011-09-13 Thread Sanjay Rajpal
#include #include #include void Swap(char *a,char *b) { char c; c=*a; *a=*b; *b=c; } int main() { char input[100]; printf("Enter a string (Length < 100) : "); scanf("%[^\n]",input); //Reversing the string int len=strlen(input); int i=0,j=len-1; while(i < j) { Swap(input+i,input+

Re: [algogeeks] ASP problem

2011-09-12 Thread Sanjay Rajpal
Same is available in VB also. Sanju :) On Mon, Sep 12, 2011 at 3:46 AM, himanshu kansal < himanshukansal...@gmail.com> wrote: > i have that book:P:P > is there any other good book relating to VB. > > On Mon, Sep 12, 2011 at 4:15 PM, Sanjay Rajpal wrote: >

Re: [algogeeks] ASP problem

2011-09-12 Thread Sanjay Rajpal
to asp > it would be very great if someone could also provide the link of the book > here..' > thanx in advance. > > On Mon, Sep 12, 2011 at 1:05 PM, Sanjay Rajpal wrote: > >> Post ur connection string here. >> >> >> Sanju >>

Re: [algogeeks] Book for C++

2011-09-12 Thread Sanjay Rajpal
C++ Primer Plus by Stephen Prata. Sanju :) On Mon, Sep 12, 2011 at 1:15 AM, sukran dhawan wrote: > Bjarne stroustroup > > > On Mon, Sep 12, 2011 at 1:43 PM, Ankuj Gupta wrote: > >> Hi >> >> Which is a good book for C++ ( Robert Lafore or Bjarne Stroustrup or >> Herbert Schildt) ? >> >> Ankuj

Re: [algogeeks] Data Structures

2011-09-12 Thread Sanjay Rajpal
Last Statement will perform bitwise copy of the operand on RHS in LHS. It is mereley an assignment, not changing pointers. For that u need double pointer here. Sanju :) On Mon, Sep 12, 2011 at 12:38 AM, Sanjay Rajpal wrote: > Run-Time error for Segmentation Fault. > > Sanju > :

Re: [algogeeks] Data Structures

2011-09-12 Thread Sanjay Rajpal
Run-Time error for Segmentation Fault. Sanju :) On Mon, Sep 12, 2011 at 12:29 AM, Anshul Khandelwal < anshul.dans1...@gmail.com> wrote: > @ teja bala - segmentation fault > U hav to allocate memory for c and t pointers of node type. > > > On Mon, Sep 12, 2011 at 12:29 PM, surender sanke wrote:

Re: [algogeeks] ASP problem

2011-09-12 Thread Sanjay Rajpal
Post ur connection string here. Sanju :) On Mon, Sep 12, 2011 at 12:24 AM, himanshu kansal < himanshukansal...@gmail.com> wrote: > I established a connection to a database in sql server 2008 through > asp. > the connection string is ok. > i have checked it and even i have generated th

Re: [algogeeks] Pgm

2011-09-11 Thread Sanjay Rajpal
Use Backtracking for this problem. Sanju :) On Sun, Sep 11, 2011 at 3:24 AM, parag khanna wrote: > output : >> > > >> 1234 >> 127 >> 136 >> 145 >> 19 >> 235 >> 28 >> 37 >> 46 >> > > > -- > Parag Khanna > B.tech Final Year > NIT,Kurukshetra > > -- > You received this message because you are

Re: [algogeeks] Re: c output .. help plz

2011-09-07 Thread Sanjay Rajpal
+1 dave. Sanju :) On Tue, Sep 6, 2011 at 3:40 PM, Dave wrote: > @Srivastav: Yeah. You need more parens: > > printf("%d",(int)(3.14*6.25*6.25)); > > Without the extra parens, the 3.14 is cast to an int, but then > implicitly recast to a double for the multiplications. With the > parens, the p

Re: [algogeeks]

2011-09-06 Thread Sanjay Rajpal
with void as return type, it shows 4. Whats happening here ? Sanju :) On Tue, Sep 6, 2011 at 10:51 AM, siddharam suresh wrote: > *main()* is an address/probably the function pointer, > Thank you, > Sid. > > > > On Tue, Sep 6, 2011 at 11:19 PM, Sanjay Rajpal wrote

[algogeeks]

2011-09-06 Thread Sanjay Rajpal
#include #include int main() { printf(" %d",sizeof(main())); ... getche(); return 0; } o/p is 4..how ??? Sanju :) -- 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 unsubscr

Re: [algogeeks] determine error..!!

2011-09-05 Thread Sanjay Rajpal
In the max function, return statement can't be present as an expression in ternary conditional operator. it should be like return x > y ? x ; y; In the second question, p is a pointer to a pointer to a const char, but argv is a pointer to a pointer to a char. The difference lies in the type of ope

Re: [algogeeks] explain the output..!!

2011-09-05 Thread Sanjay Rajpal
gt;> >> >> On Mon, Sep 5, 2011 at 7:59 PM, Sanjay Rajpal wrote: >> >>> Fourth number is not octal. >>> >>> >>> Sanju >>> :) >>> >>> >>> >>> On Mon, Sep 5, 2011 at 7:28 AM, Mohit Goel wrote: >>&g

Re: [algogeeks] DE shaw question- urgent

2011-09-05 Thread Sanjay Rajpal
I think when we have to create a singleton class, we can use private constructor. Objects of such classes can be constructed using static functions that can be accessed using class name and scope resolution operators. This is useful because user can create only one object of that class, which is so

Re: [algogeeks] MS question

2011-09-05 Thread Sanjay Rajpal
Will u plz elaborate more ? Sanju :) On Mon, Sep 5, 2011 at 8:44 AM, Neha Singh wrote: > You are given a date in the format DD/MM/ > You have to convert to it to the nearest palindromic date. > > Write a function to do the above task ? > > -- > You received this message because you are s

Re: [algogeeks] explain the output..!!

2011-09-05 Thread Sanjay Rajpal
Fourth number is not octal. Sanju :) On Mon, Sep 5, 2011 at 7:28 AM, Mohit Goel wrote: > got it ..!! thnks everyone > > -- > 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.c

Re: [algogeeks] explain the output..!!

2011-09-05 Thread Sanjay Rajpal
Answers are : arr[i] : 1 arr[i] : 8 arr[i] : 64 arr[i] : 1000 Sanju :) On Mon, Sep 5, 2011 at 7:26 AM, sukran dhawan wrote: > the answers > are > > poy[i] = 1 > pot[i] = 2 > pot[i] = 8 > pot[i] = 64 > > On Mon, Sep 5, 2011 at 7:55 PM, sukran dhawan wrote: > >> well >> >> >> #define SIZEOF(a

Re: [algogeeks] Request for crack coding book ebook

2011-09-04 Thread Sanjay Rajpal
Send it to me also. Thanx in advance .. :) Sanju :) On Sat, Sep 3, 2011 at 9:58 AM, UMESH KUMAR wrote: > hi > anybody do you have CrackCoding ebook pls send . > > thanks > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to t

Re: [algogeeks] what is the error???

2011-09-01 Thread Sanjay Rajpal
@ link time corresponding defn is looked for by the > linker. nd if the defn is nt ther, it will raise a linker error, as in case > of this prog > > @rahul, ya off course, for a variable to be global it hs to be defined at > file scope. > > > > > On Wed, Aug 31, 20

Re: [algogeeks] SEEK advice very urgent

2011-09-01 Thread Sanjay Rajpal
I think u should go and have experience in latest technologies, after all Japan is known for new technologies. You will get many things to learn there. Sanju :) On Thu, Sep 1, 2011 at 12:39 AM, vaibhav shukla wrote: > if there is no bond then u must go... after all its money and technology >

Re: [algogeeks] Re: microsoft interview

2011-08-31 Thread Sanjay Rajpal
I think this code is perfect. Sanju :) On Thu, Sep 1, 2011 at 6:54 AM, Piyush Grover wrote: > What's wrong with this?? > > > for( i = 0 ; i < n ; ++i ) >for( j = 0 ; j < m ; ++j ) >if( a[i][j] != 0 ) >a[i][0] = a[0][j] = 1; > for( i = 0 ; i < n ; ++i ) >for( j = 0 ;

Re: [algogeeks] print level by level withoust recursion

2011-08-31 Thread Sanjay Rajpal
We can use concept of threaded binary tree, bu we'll have to store a pointer to LEVEL Order Successor of each node. So the problem is reduced to find the level order successor of a node. Sanju :) On Wed, Aug 31, 2011 at 9:52 AM, manish kapur wrote: > i think hint is mentioned in the ques..ther

Re: [algogeeks] Re: Two Pointers Missing

2011-08-31 Thread Sanjay Rajpal
Chris : he said first, right pointer is missing, how can u repair that left pointer first as you can't go forward ? Sanju :) On Wed, Aug 31, 2011 at 9:39 AM, Chris wrote: > When you say missing, I assume the left or right pointer is null. If > that's the case, this could be a possible soluti

Re: [algogeeks] Two Pointers Missing

2011-08-31 Thread Sanjay Rajpal
What we are given about the Linked List, pointer to start or to the end ? Sanju :) On Wed, Aug 31, 2011 at 9:37 AM, Dheeraj Sharma wrote: > no no.. > First right pointer is missing then after few nodes..left pointer is > missing > > > On Wed, Aug 31, 2011 at 9:57 PM, Sa

Re: [algogeeks] Re: Static variable

2011-08-31 Thread Sanjay Rajpal
Thank u swathi for making me clear about static variables. Sanju :) On Wed, Aug 31, 2011 at 9:10 AM, Swathi wrote: > Google it.. you will find the answer, > > http://www.velocityreviews.com/forums/t443436-where-is-a-static-variable-stored.html > > > > On Wed, Aug 31, 20

Re: [algogeeks] Two Pointers Missing

2011-08-31 Thread Sanjay Rajpal
Is it given that first left pointer is missing and there after right pointer is missing ? Or first right pointer may also be missing ? Sanju :) On Wed, Aug 31, 2011 at 9:23 AM, Dheeraj Sharma wrote: > A doubly linked list has one Left pointer missing and at some point..one > Right pointer mis

Re: [algogeeks] Re: Static variable

2011-08-31 Thread Sanjay Rajpal
Static variables are always stored in the data section. Sanju :) On Wed, Aug 31, 2011 at 9:04 AM, Swathi wrote: > C standard doesn't define where static variables has to be stored. All it > says is to persist the data across the multiple function calls. So I think > the answer varies based o

Re: [algogeeks] C output

2011-08-31 Thread Sanjay Rajpal
o/p will be 4 3. Sanju :) On Wed, Aug 31, 2011 at 8:57 AM, SANDEEP CHUGH wrote: > its 4 3 i think > > > On Wed, Aug 31, 2011 at 9:25 PM, aditi garg wrote: > >> 8 3 >> >> >> On Wed, Aug 31, 2011 at 9:22 PM, rohit wrote: >> >>> output?? >>> >>> int main() >>> { >>> char *d = "abc\0def\0"; >>

Re: [algogeeks] Re: memory allocation

2011-08-31 Thread Sanjay Rajpal
new/malloc/calloc : Heap Memory. Sanju :) On Wed, Aug 31, 2011 at 7:00 AM, Abhishek Mallick < abhishek.mallick2...@gmail.com> wrote: > heap memory is allocated using new/malloc. memory from stack is > allocated for local variables/objects for a function. > Correct me if I am wrong. > > On Aug

Re: [algogeeks] what is the error???

2011-08-31 Thread Sanjay Rajpal
Linker error, failed to find symbol 'var'. Sanju :) On Wed, Aug 31, 2011 at 8:25 AM, rahul sharma wrote: > but it is defined inside mainu mean to say for varibale to be gloabal > it must be defines outsyd all fxns?? > > > On Wed, Aug 31, 2011 at 8:35 PM, Ashima . wrote: > >> u hv just de

Re: [algogeeks] c doubt

2011-08-31 Thread Sanjay Rajpal
The result will depend on alignment : byte alignment or Word alignment. Sanju :) On Wed, Aug 31, 2011 at 2:51 AM, PRATEEK VERMA wrote: > oh i'm sorry guys & galz,its my mistake..actually i forgot to add one > more field in struct > this is the correct one > typedef struct > { > int bit1:

Re: [algogeeks] Help ! - Explain Sscanf

2011-08-30 Thread Sanjay Rajpal
't there be a % before that ?? >> >> >> On Tue, Aug 30, 2011 at 11:22 PM, Sanjay Rajpal wrote: >> >>> Run the following program : >>> >>> main() >>> { >>> int a,b; >>> scanf("%d %*d",&a,&b); >&

Re: [algogeeks] Help ! - Explain Sscanf

2011-08-30 Thread Sanjay Rajpal
> > On Tue, Aug 30, 2011 at 10:45 PM, Sanjay Rajpal wrote: > >> only year gets scanned here, * suppresses assignment of day and month. >> >> Sanju >> :) >> >> >> >> On Tue, Aug 30, 2011 at 9:08 AM, sukran dhawan wrote: >> >>&g

Re: [algogeeks] Help ! - Explain Sscanf

2011-08-30 Thread Sanjay Rajpal
only year gets scanned here, * suppresses assignment of day and month. Sanju :) On Tue, Aug 30, 2011 at 9:08 AM, sukran dhawan wrote: > sscanf is similar to scanf except that input is read from string rather > than keyboard or i/o > *c -supression character.it reads character and discards it.d

Re: [algogeeks] Re: Find square root a number

2011-08-30 Thread Sanjay Rajpal
Binary Search kind of mathod is useful here : float SquareRoot(float n,float start,float end) { float s=(start+end)/2; if(n - sqr(s) < 0.001) && (n - sqr(s) > -0.001)) return (end+start)/2; else if(sqr(s) > n) return SquareRoot(n,0.0,s); else return SquareRoot(n,s,end); } Sanju :

Re: [algogeeks] Let's see if U can find the bug...

2011-08-30 Thread Sanjay Rajpal
This program is working fine. No bugs. Sanju :) On Mon, Aug 29, 2011 at 11:06 PM, Mohit Gupta wrote: > *1.* > /* Print armstrong numbers from 1 to 500 */ > /*1st version of prgrm: I am using pow function*/ > #include > #include > #include > int main() > { > int num=1,temp,sum,r; > while(num<=5

Re: [algogeeks] Probability

2011-08-29 Thread Sanjay Rajpal
It should be 1 - no one hits, i.e. 1 - 0.3*0.6*0.5*0.6 = 1 - 0.0540=0.9460. Correct me if m wrong.. Sanju :) On Mon, Aug 29, 2011 at 5:19 AM, Abhishek Yadav wrote: > i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 > =.964.correct me if i am wrong.?? > > > On Mon,

Re: [algogeeks] Explanation

2011-08-29 Thread Sanjay Rajpal
Utkarsh : according to you, in second printf also, f(1,2) has to be expanded first since its value is taken by g ? Sanju :) On Mon, Aug 29, 2011 at 1:53 AM, UTKARSH SRIVASTAV wrote: > it is evaluated first because it's value is taken by the h function > -- > *UTKARSH SRIVASTAV > CSE-3 > B-Tec

Re: [algogeeks] Explanation

2011-08-29 Thread Sanjay Rajpal
Why in the first case f(1,2) is evaluated first ? Any plausible explanation for that ? Sanju :) On Mon, Aug 29, 2011 at 12:50 AM, Vrashabh Irde wrote: > Hi, > > See Question 11.17 of C FAQ . > http://c-faq.com/ansi/stringize.html > > > In the first case f(1,2) happens first and in the second

[algogeeks] Explanation

2011-08-28 Thread Sanjay Rajpal
#include #define f(a,b) a##b #define g(a) #a #define h(a) g(a) int main() { printf("%s\n",h(f(1,2))); printf("%s\n",g(f(1,2))); return 0; } o/p : 12 f(1,2) friends, a valid explanation is required. Sanju :) -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: Adding Two no without using any operator...??

2011-08-28 Thread Sanjay Rajpal
But it works only for +ve numbers. Sanju :) On Sun, Aug 28, 2011 at 9:57 AM, Abhishek Yadav wrote: > Very nice solution sourabh. > > > On Sun, Aug 28, 2011 at 9:52 PM, Dave wrote: > >> @Shravanthi: Write a and b in binary, and then apply the bitwise >> exclusive-or to them and you will see w

Re: [algogeeks] Re: Adding Two no without using any operator...??

2011-08-28 Thread Sanjay Rajpal
@Saurabh : awesome solution... Sanju :) On Sun, Aug 28, 2011 at 9:22 AM, Dave wrote: > @Shravanthi: Write a and b in binary, and then apply the bitwise > exclusive-or to them and you will see why. > > Dave > > On Aug 28, 9:24 am, Shravanthi U M wrote: > > if we give a=10, b=5 we get a^b=15

Re: [algogeeks] Re: Print tree like a tree

2011-08-28 Thread Sanjay Rajpal
e calculated from parent positions. > > leftchildX = parentX - value(based on level) > rightchildY = parentY + value(based on level) > > > > On Aug 28, 7:57 pm, Sanjay Rajpal wrote: > > It is basically BFS for this tree, just maintain spaces at each level > &g

Re: [algogeeks] Print tree like a tree

2011-08-28 Thread Sanjay Rajpal
It is basically BFS for this tree, just maintain spaces at each level provided tree is a complete binary tree. Sanju :) On Sun, Aug 28, 2011 at 7:46 AM, Navneet Gupta wrote: > Hope the question is clear. Basically you need to print a given tree > such that spaces will depict the left/right re

Re: [algogeeks] Que of Tejas Network

2011-08-28 Thread Sanjay Rajpal
This is a classic dynamic problem. Search it on www.geeksforgeeks.org for "Finding Largest Non-Contiguous Sum" in an array. Sanju :) On Sun, Aug 28, 2011 at 6:21 AM, Kamakshii Aggarwal wrote: > let arr[] stores the value of max amount upto each shop that they can rob. > > arr[1]=x[1]; > arr[2]

Re: [algogeeks] Re: How to save a binary search tree space efficiently

2011-08-28 Thread Sanjay Rajpal
Does ur tree has parent pointer ? Sanju :) On Sun, Aug 28, 2011 at 1:09 AM, Navneet wrote: > Store any two traversals (inorder must) and reconstruct it later. > Total space 2n (n = number of nodes) > > On Aug 28, 11:29 am, rohit wrote: > > How to save a binary search tree space efficiently

Re: [algogeeks] c program explain

2011-08-27 Thread Sanjay Rajpal
It is checking the MSB of the integer and, it is 1(checked by Bitwise AND with 1 at MSB), it prints 1 else 0. Sanju :) On Sat, Aug 27, 2011 at 9:25 PM, rohit wrote: > how is this program convert number to binary equivalent > int main() > { > unsigned int num =23 ; > int i; > for(i=0;i<16;i+

Re: [algogeeks] Rotating 1D array clockwise

2011-08-26 Thread Sanjay Rajpal
u have mentioned clockwise, but o/p u r giving is anti-clock wise. solution for clockwise : See Reverse last k and first n-k numbers e.g. 5 4 3 2 1 8 7 6 now reverse whole array. 6 7 8 1 2 3 4 5. solution for anti-clockwise : See Reverse first k and last n-k numbers e.g. 3 2 1 8 7 6 5 4 now r

Re: [algogeeks] maximum XOR

2011-08-26 Thread Sanjay Rajpal
+1 t jai. Sanju :) On Fri, Aug 26, 2011 at 9:46 PM, raj kumar wrote: > good test case jai > > -- > 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 thi

Re: [algogeeks] apti!

2011-08-26 Thread Sanjay Rajpal
If it is 10 days originally, answer is 20 for sure. Sanju :) On Fri, Aug 26, 2011 at 11:27 AM, Sanjay Rajpal wrote: > In this question, instead of 10, it is 100. > Check it again. > > > Sanju > :) > > > > On Fri, Aug 26, 2011 at 11:26 AM, Sanjay Rajpal wrote

Re: [algogeeks] apti!

2011-08-26 Thread Sanjay Rajpal
In this question, instead of 10, it is 100. Check it again. Sanju :) On Fri, Aug 26, 2011 at 11:26 AM, Sanjay Rajpal wrote: > Sry for prrevious post . > > It is question of R S Aggarwal, and solved using conecpt of direct and > indirect proportions. > > Originally,

Re: [algogeeks] apti!

2011-08-26 Thread Sanjay Rajpal
Sry for prrevious post . It is question of R S Aggarwal, and solved using conecpt of direct and indirect proportions. Originally,let there be x men. Less men,more days(indirect proposition) (x-10) : x :: 100 : 110 (x-10) * 110 = x * 100 ANS : x = 110 Sanju :) On Fri, Aug 26, 2011 at 11:2

Re: [algogeeks] apti!

2011-08-26 Thread Sanjay Rajpal
20 men ? (x-10)20=10x Sanju :) On Fri, Aug 26, 2011 at 11:17 AM, gmagog...@gmail.com wrote: > 20? > > Yanan Cao > > > > On Fri, Aug 26, 2011 at 1:12 PM, priya ramesh < > love.for.programm...@gmail.com> wrote: > >> A certain number of men can finish a piece of work in 10 days. If however >> the

Re: [algogeeks] Re: unsorted array problem

2011-08-26 Thread Sanjay Rajpal
XOR all the elements in the array, the result will be the XOR of the two numbers occuring odd number of times. Now take any set bit of th result(u can determine the position of any bit set in the number). Divide the array such that for the numbers for which at this location(where the bit is set in

Re: [algogeeks] Re: inorder predecessor

2011-08-26 Thread Sanjay Rajpal
{ > root=root->left; > } >else if(root->data< node->data) > { >parent=root; >root=root->right; > } > } >return

Re: [algogeeks] Re: inorder predecessor

2011-08-26 Thread Sanjay Rajpal
Vikram : will u plz elaborate more on ur solution ? Sanju :) On Fri, Aug 26, 2011 at 5:24 AM, Vikram Singh wrote: > ya thats one option but that gives ans in O(n), requires additional > memory... and unnecessarily finds for all which is not required... > my sol doesnt require any extra space

Re: [algogeeks] reverse

2011-08-24 Thread Sanjay Rajpal
assuming unsigned integers and 8-bit size,and n to be the number, logic is : n << 4 | n >>4. Correct me if m wrong. Sanju :) On Wed, Aug 24, 2011 at 8:51 AM, aditi garg wrote: > though im very unsure abt this,but how abt converting the number to BCD and > then normal swapping of the two nibb

Re: [algogeeks] Re: C Trick

2011-08-24 Thread Sanjay Rajpal
nice solution priyanka :) Sanju :) On Wed, Aug 24, 2011 at 6:03 AM, priyanka raju wrote: > > > int a,b,max,min; > max=(a+b+abs(a-b))/2; > min=(a+b-abs(a-b))/2; > > > -- > cheers > priyanka > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks"

Re: [algogeeks] C code scanf problem

2011-08-24 Thread Sanjay Rajpal
after first scanf, place a call to fflush(stdin). you will get the result. Sanju :) On Wed, Aug 24, 2011 at 5:58 AM, Mehnaaz wrote: > #include > #define max 30 > int no_p; > int main() { > >char p[no_p][max]; >char x; >int i=0; >printf("enter the no of produc

Re: [algogeeks] Re: Find the non-duplicate element in sorted array in < O(n) time

2011-08-24 Thread Sanjay Rajpal
t?? > For your input Xor all numbers - will give you the result:) > but its O(n) > > Anyway your input allow everyone to think little wider than Binay > search. > > > Thanks > Venkat > > > On Aug 24, 4:05 pm, Sanjay Rajpal wrote: > > @Venkat : suppose

Re: [algogeeks] Re: Find the non-duplicate element in sorted array in < O(n) time

2011-08-24 Thread Sanjay Rajpal
@Venkat : suppose if the array were : 1 2 2 2 2 2 2 2 2 2 2, would ur solution work ? Sanju :) On Wed, Aug 24, 2011 at 3:58 AM, Ankit Minglani wrote: > How about this : > We use a divide and conquer approach and since the array is sorted. > We find the middle element and check its value with

[algogeeks]

2011-08-23 Thread Sanjay Rajpal
Hi frnds, I need Data Structures and Algorithm book by Andrew S Tanenbaum. Plz post a link or mail the book at srn...@gmail.com Thanx in Advance :) Sanju :) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email

Re: [algogeeks] C Trick

2011-08-23 Thread Sanjay Rajpal
@teja : use of comparison operator is not allowed. Sanju :) On Tue, Aug 23, 2011 at 6:42 AM, teja bala wrote: > int a,b,c; > c=(a print(c); > > On Tue, Aug 23, 2011 at 6:37 PM, Abhishek Yadav < > algowithabhis...@gmail.com> wrote: > >> Write a method which finds the maximum of two numbers You

Re: [algogeeks] Benefits of using Private or Protected Virtual Functions ?

2011-08-23 Thread Sanjay Rajpal
I think they can be useful in singlton classes. Sanju :) On Tue, Aug 23, 2011 at 3:32 AM, sachin sabbarwal wrote: > i can't come up with benefits... > but a potential use is here > class c1 > { > private: > c1() > { > } > > public: > static c1* makeobject(accept credentials)

Re: [algogeeks] Re: C dot

2011-08-23 Thread Sanjay Rajpal
7.7 LPA @ NIT Kurukshetra. Sanju :) On Mon, Aug 22, 2011 at 10:47 PM, siddharam suresh wrote: > how much they are offering ? > Thank you, > Siddharam > > > > On Tue, Aug 23, 2011 at 11:12 AM, ranjith kumar > wrote: > >> >> >> They shortlist candidates based on cgpa and select the highest cgp

Re: [algogeeks] Re: C-question

2011-08-23 Thread Sanjay Rajpal
to clear ur these concepts , i think u should refer to Programming in C , Schaum series, Byron S Gottfried, and then Ritchie book. They are clearly given there. Sanju :) On Mon, Aug 22, 2011 at 11:25 PM, Vijay Khandar wrote: > Thanks ...got it.. > > > On Tue, Aug 23, 2011 at 11:30 AM,

  1   2   3   >