[algogeeks] Second shortest path

2011-12-07 Thread Aniket
1. How to find second shortest path from a source to a target? (Modification of dijkstras algo to store second best in the node when the node is the target would suffice I think, But any other way?) 2. How to find the second best MST for a graph? -- You received this message because you are subs

[algogeeks] Permutation Problem with repeating characters

2011-12-07 Thread Aniket
Write a programme to produce all permutations of a given string where characters are not unique. That means you are not allowed to print the duplicate strings. Ex: If input is aaa The output should be only aaa -- You received this message because you are subscribed to the Google Groups "Algori

[algogeeks] Query: Function returning void pointer

2011-11-21 Thread Aniket
Can a function return a void pointer ? -- 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

Re: [algogeeks] Amazon Onsite Chennai SDE

2011-11-14 Thread aniket chatterjee
. (Interviewer told. The same answer was given). On Mon, Nov 14, 2011 at 4:59 AM, rajeev bharshetty wrote: > Levensteins algorithm > > On 14 Nov 2011 18:19, "aniket chatterjee" wrote: > > > > yeah, that is normal bryteforce. Any better idea? > > > > On 11/14/11,

Re: [algogeeks] Amazon Onsite Chennai SDE

2011-11-14 Thread aniket chatterjee
an make it a valid word > . If not delete the next character and repeat the process again . > > This is what I can think of here. Any other solutions/guesses ? > > > > On Mon, Nov 14, 2011 at 12:43 PM, Aniket wrote: > >> You are given a word and a dictionary. Now pro

[algogeeks] Amazon Onsite Chennai SDE

2011-11-14 Thread Aniket
You are given a word and a dictionary. Now propose an algorithm edit the word (insert / delete characters) minimally to get a word that also exists in the dictionary. Cost of insertion and deletion is same. Write pseudocode for it. Seems like minimum edit distance problem but some modification is

Re: [algogeeks] BST question

2011-11-11 Thread aniket chatterjee
And also your solution prints the root to leaf path that sums up to X. But the path may not contain root as well as leaf also. May be some intermediate 4 nodes (from root to leaf path)sums up to X. Your code doesnt provide the solution for that scenario. On Fri, Nov 11, 2011 at 2:53 PM, aniket

Re: [algogeeks] BST question

2011-11-11 Thread aniket chatterjee
t->left = getnode(7); > root->left->right = getnode(8); > root->right->left = getnode(3); > root->right->right = getnode(7); > value = 14; > sum(value,root,ar,0); > return 0; > > } > > On Fri, Nov 11, 2011 at 12:38 PM, anike

Re: [algogeeks] BST question

2011-11-10 Thread aniket chatterjee
Write a recursive function that will store each root to leaf path in an array. Now for each root to leaf path find the subarray which sums up to X. On Thu, Nov 10, 2011 at 11:53 PM, AMAN AGARWAL wrote: > Hi All, > > Please give me the solution of this problem. > > A binary tree and a number X is

Re: [algogeeks] coding round question

2011-10-30 Thread aniket chatterjee
+1 On Sun, Oct 30, 2011 at 6:53 AM, Siddhartha Banerjee < thefourrup...@gmail.com> wrote: > could you please explain the question in a bit more detail? > especially the part"There are some particular > numbers which are made using 4 or 7 : any combination of 4 and 7 are > accepted." > > from what

[algogeeks] Amazon Onsite

2011-10-24 Thread Aniket
Suppose there is a circle. You have five points on that circle. Each point corresponds to a petrol pump. You are given two sets of data. 1. The amount of petrol that petrol pump will give. 2. Distance from that petrol pump tp the next petrol pump. (Assume for 1 lit Petrol the truck will go 1 km)

[algogeeks] Aniket Dutta wants to chat

2011-07-14 Thread Aniket Dutta
I've been using Google Talk and thought you might like to try it out. We can use it to call each other for free over the internet. Here's an invitation to download Google Talk. Give it a try! ------- Aniket Dutta wants

Re: [algogeeks] Output ( File Handling)

2011-07-14 Thread Aniket Dutta
1. in ur program it will always output 1 because precedence of != is greater than = (assignment) On Thu, Jul 14, 2011 at 2:57 PM, Aniket Dutta wrote: > yeah i just figured it out > > > On Thu, Jul 14, 2011 at 2:47 PM, rajeev bharshetty > wrote: > >> @Aniket Its getc its

Re: [algogeeks] Output ( File Handling)

2011-07-14 Thread Aniket Dutta
addtion to previous post while((ch=getc(fp))!=EOF) then 2 case will occur On Thu, Jul 14, 2011 at 3:16 PM, Aniket Dutta wrote: > 2. the value of EOF is an integer which equals -1 (0x) >and not 0xff becoz this is a valid Ascii character >for this reason of tructation

Re: [algogeeks] Output ( File Handling)

2011-07-14 Thread Aniket Dutta
2. the value of EOF is an integer which equals -1 (0x) and not 0xff becoz this is a valid Ascii character for this reason of tructation the while loop will always be true. On Thu, Jul 14, 2011 at 3:13 PM, Aniket Dutta wrote: > 1. in ur program it will always output 1 beca

Re: [algogeeks] Output ( File Handling)

2011-07-14 Thread Aniket Dutta
yeah i just figured it out On Thu, Jul 14, 2011 at 2:47 PM, rajeev bharshetty wrote: > @Aniket Its getc itself !! > > On Thu, Jul 14, 2011 at 2:45 PM, Aniket Dutta wrote: > >> i think i should be like this >> while((c=fgetc(fp))!=EOF) and not getc >> >>

Re: [algogeeks] Output ( File Handling)

2011-07-14 Thread Aniket Dutta
i think i should be like this while((c=fgetc(fp))!=EOF) and not getc On Thu, Jul 14, 2011 at 2:41 PM, rShetty wrote: > // File Handling > #include > #include > int main() > { > unsigned char ch; // I think there is problem somewhere in this > line ! Help !! > FILE *fp; > fp = fopen("abc","r")

Re: [algogeeks] microsoft ques

2011-07-12 Thread Aniket Dutta
@sunny: right thanks for correcting On Wed, Jul 13, 2011 at 11:33 AM, sunny agrawal wrote: > @Aniket Dutta > Solution for your case will be 96 > > Algorithm Posted by Oppilas will do and is O(n). > > > On Wed, Jul 13, 2011 at 11:28 AM, Aniket Dutta wrote: > >> @vaib

Re: [algogeeks] microsoft ques

2011-07-12 Thread Aniket Dutta
@vaibhav: Sir ur algo fails in this array {2,-8,-3,1,2} it should give answer as 24 but ur algo gives 2 On Wed, Jul 13, 2011 at 11:02 AM, varun pahwa wrote: > please ignore my previous post that solution is wrong. > > > On Wed, Jul 13, 2011 at 11:01 AM, sameer.mut...@gmail.com < > sameer.mut...@g

Re: [algogeeks] Re: questions related to C

2011-07-12 Thread Aniket Dutta
what about a generic swap function which works for structures also? On Wed, Jul 13, 2011 at 2:23 AM, Don wrote: > To check for overflow, use condition: > > if (b > (maxuint-a)) > return error; > > Where maxuint is the largest value which can be stored in an unsigned > integer. > > Don > > On Ju

Re: [algogeeks] MS Interview

2011-07-12 Thread Aniket Dutta
you can sort it using external merge sort. if ur file is greater than memory refer henry F. korth Database System Concept On Wed, Jul 13, 2011 at 10:26 AM, rShetty wrote: > Given a very big file of words, a word in each line, sort the words . > Please provide the algorithm and explanation . > >

Re: [algogeeks] questions related to C

2011-07-12 Thread Aniket Dutta
c=a+b then find b=c-a; if this b equals previous one then ok else overflow On 7/9/11, John Hayes wrote: > regarding question related to overflow > > int ovr_sum(int *sum,int a,int b) > { > *sum=a+b > if(*sum<0) > return -1; //overflow > else > return 0; //no problem with the

Re: [algogeeks] output

2011-07-12 Thread Aniket Dutta
@sandeep sir: thanx sir for clearing doubt On 7/12/11, Sandeep Jain wrote: > *const* in C++ is not exactly same as *final* in java. SO unlike java adding > the keyword const to a function does not affect overriding. > Infact, adding in C++ const functions ==> that they will not modify any > m

Re: [algogeeks] output

2011-07-12 Thread Aniket Dutta
@dheeraj: but the prototypes are same. how u are calling it overloading plz explain On 7/12/11, dheeraj tyagi wrote: > const means that it cannot be overloaded..i think due to that this is > happening. > > On Tue, Jul 12, 2011 at 9:26 PM, segfault wrote: > >> #include >> using namespace std;

Re: [algogeeks] Re: linked list doubt

2011-07-12 Thread Aniket Dutta
@anika: according to satistics we need both n/2 and n/2+1 to find the median from an even set ((n/2)+(n/2+1))/2. but here you cannot do this. so i guess n/2+1 or n/2 both are correct because both contribute equally to calculate median. On 7/12/11, bittu wrote: > now try how u will remove the loop

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
sorry @ankit On Tue, Jul 12, 2011 at 8:10 PM, Aniket Dutta wrote: > @bittu > > > On Tue, Jul 12, 2011 at 8:09 PM, Aniket Dutta wrote: > >> @yeah right >> >> >> On Tue, Jul 12, 2011 at 7:36 PM, ankit sambyal wrote: >> >>> @Aniket: Just ad

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
@bittu On Tue, Jul 12, 2011 at 8:09 PM, Aniket Dutta wrote: > @yeah right > > > On Tue, Jul 12, 2011 at 7:36 PM, ankit sambyal wrote: > >> @Aniket: Just add a condition at the begining: >> >> if(root == NULL) >> return 0; >> >> -- >>

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
@yeah right On Tue, Jul 12, 2011 at 7:36 PM, ankit sambyal wrote: > @Aniket: Just add a condition at the begining: > > if(root == NULL) > return 0; > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" gr

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
what will happen if node is not found?. you are not checking it On 7/12/11, bittu wrote: > whats the problem with this > > bool search(root,node) > { > if(root==node) > return 1; > else > return search(root->left,node)||search(root->right,node); > > } > > TC O(N) >

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
@bittu On 7/12/11, Aniket Dutta wrote: > what will happen if node is not found?. > you are not checking it > > On 7/12/11, bittu wrote: >> whats the problem with this >> >> bool search(root,node) >> { >> if(root==node) >> retu

Re: [algogeeks] microsoft ques

2011-07-12 Thread Aniket Dutta
for example /* { { } }*/ On Tue, Jul 12, 2011 at 6:36 PM, Aniket Dutta wrote: > what happens when to the '{' in comments i guess your program is also > counting that.. > > > On Tue, Jul 12, 2011 at 6:22 PM, nicks wrote: > >> igonre the previou

Re: [algogeeks] microsoft ques

2011-07-12 Thread Aniket Dutta
what happens when to the '{' in comments i guess your program is also counting that.. On Tue, Jul 12, 2011 at 6:22 PM, nicks wrote: > igonre the previous code, here is fully working code..previous one > doesn't include check for having { within quotes which should not be counted > for sc

[algogeeks] PHP E-Book

2011-05-06 Thread Aniket
Please suggest me a standard PHP book.I know there are lots in the internet.But as I am a beginner I want suggestions.Also if possible send the book or give me the link.Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To pos

[algogeeks] Problem regarding MySql server Installation

2011-04-28 Thread Aniket
I was trying to install mysql 5.5. in Windows XP.After installation during configuration phase when there was to apply security settings I m always getting an error Error No 1045 Access Denied for user 'root'@localhost(using password: NO). I have tried all possibilities in Firewall but it dint wo

Re: [algogeeks] c programming question

2011-02-04 Thread aniket chatterjee
The answer will be compiler dependent.Google "Sequence Point in C". -- 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+unsu

Re: [algogeeks] can i know the best way to learn programming??

2011-02-02 Thread aniket chatterjee
@Rahul: Awesome link dude!! -- 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 opti

Re: [algogeeks] Google Question

2011-01-21 Thread aniket chatterjee
It will be like a circularly sorted array.There exists a binary search type divide and conquer mechanism to find a specific number in such type of arrays. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to al

Re: [algogeeks] Re: MICROSOFT IDC

2011-01-12 Thread aniket chatterjee
Hi all Its about set intersection. @Davin predicted the problem wrongly. So,sorting gives the best performance. -- 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 fr

Re: [algogeeks] Re: MICROSOFT IDC

2011-01-12 Thread aniket chatterjee
Hi all Its about set intersection. @Davin predicted the problem wrongly. So,sorting gives the best performance. -- 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 fr

Re: [algogeeks] MICROSOFT IDC

2011-01-12 Thread aniket chatterjee
Is there any way to do it using recursion? Interviewer asked to do it using recursion. -- 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

[algogeeks] MICROSOFT IDC

2011-01-11 Thread Aniket
Find the intersection of two unsorted singly linked list in O(1) space and less than O(n^2) complexity. -- 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

[algogeeks] Please Explain

2011-01-03 Thread Aniket
#include using namespace std; const int a[]={1,2,3,4,5}; int b[a[2]]; int main(){return 0;} If the code is like above it is giving error in line 4; But if it is something like below it gives no error after compilation: #include using namespace std; const int a=3; int b[a]; int main(){return 0;}

Re: [algogeeks] Re: Longest Palindrome

2011-01-02 Thread aniket chatterjee
@Anand:I went through the link posted in your blog.But I found the method little bit hard to understand. @Aviral:Please elaborate the approach or give some link as in your blog I didn't find the solution. It will be very helpful.Thanks in advance. -- You received this message because you are subs

Re: [algogeeks] Re: Float Comparison

2011-01-02 Thread aniket chatterjee
This link may be helpful: http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htm -- 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 un

Re: [algogeeks] Plz Explain The Output.

2011-01-01 Thread aniket chatterjee
2. #include using namespace std; int main(){ int n = 255, i; char *p = (char *)&n; for(i = 0; i < sizeof(int); i++) cout<<(unsigned int)p[i]<<"\n"; cin.get(); return 0; } Output: 4294967295 0 0 0 I think p[0] is .So why it is giving 4294967295 in the first line. -- You received this m

[algogeeks] Plz Explain The Output.

2011-01-01 Thread Aniket
# include #include #define concatinate(a,b) a##b #define same1(a) #a #define same2(a) same1(a) int main(){ printf("%s\n",same2(concatinate(1,2))); printf("%s\n",same1(concatinate(1,2))); getch(); return 0; } Output is: 12 concatinate(1,2) -- You received this message because you are subscribe

[algogeeks] Longest Palindrome

2010-12-30 Thread Aniket
How do you find the longest palindrome in a given string in O(n) time? -- 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 algogeeks+u

Re: [algogeeks] Re: Strings search problem

2010-12-29 Thread aniket chatterjee
Take three pointers. p for bat q for cat r for mat Then first find the first ocurrences of bat, cat, mat in the text. Find min(abs(p-q),abs(q-r),abs(r-p)); Now among p,q,r which is minimum find next ocurrence of that particular string in the text.Update the corresponding pointer value. Again find

[algogeeks] DIVIDE TWO VARYING LENGTH NUMBERS.

2010-12-26 Thread Aniket
DIVIDE TWO VARYING LENGTH NUMBERS EX: ONE CAN BE UPTO 60 DIGIT AND OTHER 40 DIGIT Well,I thought of an approach.Store each digit of each number in two separate integer arrays(From right to left).Then apply the subtraction method.Will it be feasible? -- You received this message because you are

Re: [algogeeks] 10 Most Frequent Search Text

2010-12-26 Thread aniket chatterjee
@Chi: Would you please explain the process in a little bit more details? It will be helpful. Is Trie and Radix-Trie same? -- 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 unsu

[algogeeks] 10 Most Frequent Search Text

2010-12-26 Thread Aniket
When we type in google for search it will generate search text. For a stream of searchtext how you will find most 10 frequent search text. Give an efficient data structure for this. and also solve it with possible minimum complexity. -- You received this message because you are subscribed to the