Re: [algogeeks] Min Edges to be added to DAG to make it Strongly connected?

2012-10-10 Thread KK
...@gmail.comjavascript: wrote: find no. of cut vertex in the DAGthat will be the ans. On 6 Oct 2012 19:33, KK kunalka...@gmail.com javascript: wrote: Given a DAG(Directed Acyclic Graph). How to find out the minimum number of edges that needs to be added so that the given graph becomes Strongly

[algogeeks] Re: Help me find my Recursive algo complexity

2012-10-10 Thread KK
Hi Vicky.. Its O(n^K) as u are iterating over all the elements of array for each of the k element subset!! On Monday, 8 October 2012 23:53:15 UTC+5:30, ((** VICKY **)) wrote: Hi, I wrote code for generating all possible sets of length k in a array of length n. I did using recursion, but i'm

[algogeeks] Min Edges to be added to DAG to make it Strongly connected?

2012-10-06 Thread KK
Given a DAG(Directed Acyclic Graph). How to find out the minimum number of edges that needs to be added so that the given graph becomes Strongly Connected? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web

[algogeeks] Min Edges to be added to DAG to make it Strongly connected?

2012-10-06 Thread KK
Given a DAG(Directed Acyclic Graph). How to find out the minimum number of edges that needs to be added so that the given graph becomes Strongly Connected? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web

Re: [algogeeks] 4Sum

2012-06-18 Thread KK
@Hemesh : +1 @Jalaj : read Hemesh's solution again it is for 4sum. In short, make a new array having sum of each unique pair of given array. - O(n^2) sort it - O(n^2) for each number bi in new array, binary search (target - bi) in the same array - O(n^2) On Sunday, 17 June 2012 12:41:40

[algogeeks] Re: Permutations of a string

2012-06-12 Thread KK
Thanks Gene :D On Tuesday, 8 May 2012 07:24:01 UTC+5:30, Gene wrote: You just need to make sure that the same character is never swapped to the same position twice. Here is one way to do it. #include stdio.h #include string.h void swap(char *s, int i, int j) { char t = s[i];

[algogeeks] Re: problem

2012-06-10 Thread KK
This problem is of ACM-ICPC kanpur online round 2012. you can find the solution herehttp://www.codechef.com/ACMKAN11/problems/ARTHMNCY . On Sunday, 10 June 2012 16:37:33 UTC+5:30, payel roy wrote: Find the number of fractions a/b such that- 1. *gcd(a, b) = 1* 2. *0 a/b 1* 3. *a * b =

Re: [algogeeks] Matrix Minimum Path Sum

2012-06-07 Thread KK
The problem u are referencing is different one.. here u can move in all 4 directions! On Wednesday, 6 June 2012 18:43:15 UTC+5:30, Dheeraj wrote: http://www.geeksforgeeks.org/archives/14943 On Mon, Jun 4, 2012 at 7:57 PM, Decipher ankurseth...@gmail.com wrote: @Victor - Someone had asked

[algogeeks] Re: SPOJ TLE

2011-12-20 Thread KK
Try wid BFS.. thats the only alternative i can think off!! I got acc wid that!! On Dec 6, 12:29 pm, varma C.S.P verma@gmail.com wrote: I am getting a lot of tle's for this problem. https://www.spoj.pl/problems/BUGLIFE/ Here is my code #includeiostream #includecstdio #includecstring

[algogeeks] Re: Can Any1 provide a proper implementation of a Hashtable(Seperation Chaining) in C,C++

2011-10-08 Thread KK
#includeiostream #includevector #includelist #define TR(a,it)for(typeof((a).begin()) it = (a).begin(); it != (a).end(); ++it) using namespace std; void Insert(int key, int m, vector listint v); listint::iterator Search(int key, int m, vector listint v); void Delete(int key, int m,

[algogeeks] SPOJ PIE

2011-09-15 Thread KK
http://www.spoj.pl/problems/PIE/ I solved this using Binary Search its similar to shake shake shaky of spoj... but still get WA :( Plzz help... #includeiostream #includealgorithm using namespace std; bool solve(int *pie, int n, int mid,int f) { int sum = 0; for (int i=0; in; i++)

[algogeeks] Re: MS test cases type Questions

2011-09-14 Thread KK
U must mention all the boundary cases, very large input cases, -ve nos and must throw appropriate exception while coding during interviews... Questions are not too hard in MS... just they dont want buggy code... even if u allocate memory.. u should take an if condition i.e. if (p ! = NULL)...and

[algogeeks] Re: MICROSOFT in VJTI mumbai

2011-09-14 Thread KK
@Bharatkumar bagana : that is a standard Qs which uses line sweep algo and has O(n lgn) soln other than the trivial O(n^2) soln... google that Qs... @tej bala: out of 10.. 5-6 were output type obj Q... then 1 was what's full form of GCC... its gnu compiler collection.. i made mistake in this Q..

[algogeeks] Re: Implementing a grep

2011-09-10 Thread KK
grep is actually implemented using a suffix tree -- 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: MICROSOFT in VJTI mumbai

2011-09-10 Thread KK
MS visited out col with 2 profiles... written test: 3 different papers: 1 one all objectives 2nd 2 subjective problems... 1 ws to find the closest pair of points... and other was to find the bugs and provide the test cases for the already provided string copying code... then it was followed by 4

[algogeeks] Euler Phi Function

2011-08-30 Thread KK
This is the code for the Euler phi function: int phi (int n) { int result = n; for (int i=2; i*i=n; ++i) if (n % i == 0) { while (n % i == 0) n /= i; result -= result / i; // M NOT

[algogeeks] Re: C code scanf problem

2011-08-24 Thread KK
Using getchar() after the first scanf ll be much better...!! -- 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: logic???????????

2011-08-12 Thread KK
Check this out //But this and fails for input such as: 101 ie all nos must be unique.. int search_element_in_rotated_array(int *a, int low, int high, int key) { while(low = high) { int mid = low + (high - low)/2; if(a[mid] == key) return

[algogeeks] Re: Plz tell wat questions are asked by MICROSOFT IDC and IT both...Plz Reply fast.....anyone...!!

2011-08-10 Thread KK
Go through the last 50-100 posts... a lot of Qs have already been posted!! -- 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: amazon test question!!!

2011-08-08 Thread KK
3 -- 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

[algogeeks] Re: Directi question-centre of the tree

2011-08-07 Thread KK
Codechef Ques(Initiative of Directi) use DFS, BFS or Floyd Warshall... :) -- 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: Microsoft :)

2011-08-07 Thread KK
@Harshal: Thanx -- 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

[algogeeks] Re: Microsoft :)

2011-08-06 Thread KK
Hey Congrats!! :) I got intern dere :) -- 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

[algogeeks] Facebook Intern F2F Interview

2011-07-28 Thread KK
bool foo(int x) // Implement this function where 0 = x = 100 It should return true x% of times n false otherwise first i told him to have a static int s then increment it each time the func is called... and if s % (100 - x ) == 0 then true else false. then he told me to have some

[algogeeks] Re: Facebook Intern F2F Interview

2011-07-28 Thread KK
@Nikhil: ya true but i dont know wht else was he expecting. @sunny and Muthu: like suppose u pass 20 then func should return true with 20% probabily and false otherwise... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Re: Facebook Intern F2F Interview

2011-07-28 Thread KK
No i was not able to come up with a soln dere.. my bad :( This was my 1st interview hope the upcoming interviews would be nice!! -- 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.

[algogeeks] Re: SPOJ

2011-07-25 Thread KK
@shady: if ur not interested dont post ur comment, but let others do it.. @viswamath: WA -- 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

[algogeeks] Re: SPOJ

2011-07-25 Thread KK
@piyush: even if r = di and c = dj then whats the prob?? -- 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] SPOJ

2011-07-23 Thread KK
www.spoj.pl/problems/SHOP Its a pretty easy Q... But m not able to figure out any silly mistake in my prog.. plzz help #includeiostream #includevector #includemap #includequeue using namespace std; char a[26][26]; int si, sj, di, dj, rows, cols; void BFS(vector vectorint v, int si, int sj,

[algogeeks] Re: DP or DFS

2011-07-07 Thread KK
Can u elaborate something on implementation.?? -- 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: Help!!

2011-07-06 Thread KK
Hey anyone Pl help... its clearly written code and algo u know vry well so it wont take much time :) On Jul 5, 8:43 pm, KK kunalkapadi...@gmail.com wrote: This is the solution to the MST problem m getting WA again n again... cant figure out where's the mistake... so plzzz help!!!https

[algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread KK
for Q5 change the expr into postfix and then build expression tree... but is expression tree same as parse tree?? correct me if i m wrong!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] DP or DFS

2011-07-06 Thread KK
https://www.spoj.pl/problems/SHOP/ Anybody plzz post a solution to the above problem... i tried with dp but it failed... How to implement with DFS or if possible with DP??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] Help!!

2011-07-05 Thread KK
This is the solution to the MST problem m getting WA again n again... cant figure out where's the mistake... so plzzz help!!! https://www.spoj.pl/problems/BLINNET/ #includeiostream #includestring #includevector #includelist #includequeue #define MAXINT (int)9e9 #define TR(a,it)

[algogeeks] GATE 2011 C Ques

2011-07-02 Thread KK
10. What does the following fragment of C-program print? char c[] = GATE2011; char *p =c; printf(%s, p + p[3] - p[1]); (A) GATE2011 (B) E2011 (C) 2011 (D) 011 Answer: - (C) why is p[3] - p[1] returning 4 -- You received this message because you are subscribed to the Google Groups

[algogeeks] Re: GATE 2011 C Ques

2011-07-02 Thread KK
got it dont bother!!! anyway thanx abhijith!!! -- 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] Recurrence Relation

2011-07-02 Thread KK
3. Consider the following recurrence: T(n) = 2T(n ^ (1/2)) + 1 Which one of the following is true? (A) T(n) = (loglogn) (B) T(n) = (logn) (C) T(n) = (sqrt(n)) (D) T(n) = (n) Can we solve this using master theorem??? any other way??? -- You received this message because you are subscribed to

[algogeeks] Re: Recurrence Relation

2011-07-02 Thread KK
Answer (B) Let n = 2^m, T(n) = T(2^m) Let T(2^m) = S(m) From the above two, T(n) = S(m) S(m) = 2S(m/2) + C1 Above expression is a binary tree traversal recursion whose time complexity is (m). You can also prove using Master theorem. S(m) = (m) = (logn) /* Since n = 2^m */ Now, let

[algogeeks] Re: STL MAP HELP

2011-06-18 Thread KK
but in a set elements are not in any order...and also set cannot be indexed... if u want to sort in the basis of key use vector with pair... Correct me if m wrong -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Re: Tic Tac Toe

2011-06-17 Thread KK
@sunny: This test: if(! ( (countx == counto + 1) || (countx == counto) ) ) cout no endl; prints no if countx counto and this one if(o x) cout no endl; else cout yes endl; prints no if both have won or else

[algogeeks] Re: Tic Tac Toe

2011-06-17 Thread KK
@sunny: why the answer for the case u mentioned is no.. those are possible set of moves according to me and hence my program outputs yes -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Fiddling with Bits

2011-06-17 Thread KK
To remove all digits left of the rightmost digit one in the binary representation of some integer what we need to do is this: ans = no -no and this is what is exactly asked in this problem of SPOJ: www.spoj.pl/problems/MZVRK/ #includeiostream using namespace std; int main() { unsigned long

[algogeeks] Re: Tic Tac Toe

2011-06-17 Thread KK
oops !! :) i'll look into that.. thx -- 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

[algogeeks] Minimum Rotations

2011-06-17 Thread KK
http://www.spoj.pl/problems/MINMOVE/ This code is showing TLE after some 20th test case what else can be optimized??? try: import psyco psyco.full() except ImportError: pass string = input() minlen = string length = len(string) string += string[:] #print(string) index = 0 for i in

[algogeeks] MST (BLINNET) problem on SPOJ

2011-06-16 Thread KK
www.spoj.pl/problems/BLINNET/ Here is the code for the same... Its not getting AC in SPOJ m not able to figure out wheres the hole in this... plzz help #includeiostream #includestring #includevector #includelist #includequeue #define MAXINT (int)9e9 #define TR(a,it)

[algogeeks] Re: Finding total number of inversions in an array in O(nlogn) complexity .

2011-06-15 Thread KK
This code is not getting AC on spoj.. m not able to point out the error plzzz help. Here is the link to this problem at spoj : http://www.spoj.pl/problems/INVCNT/ #includeiostream #includevector #includestring #includealgorithm using namespace std; void MergeSort(vectorint v, int p, int r);

[algogeeks] Re: HASHIT

2011-06-15 Thread KK
Thanks 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 options, visit this

[algogeeks] Re: Finding total number of inversions in an array in O(nlogn) complexity .

2011-06-15 Thread KK
Thanks Harshal!! Actually changing juzz count from int to long long suffices -- 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: spoj NKTM

2011-06-15 Thread KK
This q increased my score by directly 3 points... and thats a huge one.. :D @ kartik - Do it by priorty queue for better efficiency.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: Swapping two variables without using a temporary variable

2011-06-12 Thread KK
@kunal Actually its not same value its the same variable and it arises only if u code the given way(and some people do it this way) void swap(int a, int b) { a ^= b ^= a ^= b; } now we have int a = 10; swap(a, a) This will set a's value to 0...and this happens while sorting arrays

[algogeeks] Re: Swapping two variables without using a temporary variable

2011-06-11 Thread KK
It wont give correct answer when u pass same values of a and b and such conditions arises in sorting -- *** Kunal Kapadia Computer Science and Engineering B.Tech 2nd yr NIT Trichy *** -- You received this

[algogeeks] Re: FOR ALL INDIANS PLZ READ IT

2011-06-11 Thread KK
It works!! Shame on u Umer Farooq u cant even give a call a no for ur nation whereas other are on hunger strike... even if this is algo group so whats the problem???... m sorry to say this... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] HASHIT

2011-06-10 Thread KK
This is the link to the SPOJ problem HASHIT : http://www.spoj.pl/problems/HASHIT/ i donno whts the mistake... i keep getting wrong answer even though the Q is Straightforward :( #includeiostream #includestring using namespace std; int hash(string str) { int sum = 0; int len =

[algogeeks] Re: SPOJ THRBL

2011-06-10 Thread KK
Search Topcoder Tutorial Range Minimum Query @ Google... By few intuitive changes u can implement Range Maximum Query as well... -- 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.

[algogeeks] Python

2011-05-07 Thread KK
I have juz started python and finished A Byte of Python Now to which book should i switch too??? Also recommend Python books to master it!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: Need help on fenwick trees

2011-05-02 Thread KK
Search Topcoder Tutorial on Google.. On Apr 17, 9:06 pm, naga vinod kumar vinodkumark...@gmail.com wrote: Hi Guys ,                    Can any one give link for  tutorial or videos about segment trees. I am unable to understand the basic idea  behind it . Regards, vinod -- You received

[algogeeks] Re: Link for sartaj sahni video lectures

2011-04-25 Thread KK
Hey it seems to be a fake link... It directs to some site which shorten URLs -- 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: Cracking the IT interview: jump start your career with confidence

2011-04-25 Thread KK
But i think here's no one to forward :p Kunal Kapadia Computer Science and Enggneering 2nd yr NIT Trichy -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

[algogeeks] Re: Sartaj Sahni ebook

2011-04-24 Thread KK
@ Carl Barton: I also know that site... i want a shared link u stupid... -- 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: Flipping Coins

2011-04-23 Thread KK
Hey guys n gals WAKE UP No reply on this topic??? Do any knows here about segment tree?? -- 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

[algogeeks] Sartaj Sahni ebook

2011-04-23 Thread KK
Please give link to: Data Structures,Algorithms and Applications by Sartaj Sahni... or directly mail to me. -- 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

[algogeeks] Ebooks Sites

2011-04-21 Thread KK
Hello people please share sites from where good programming ebooks can be downloaded... i use library.nu and 4shared.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

[algogeeks] Flipping Coins

2011-04-21 Thread KK
Pls have a look at this Question on codechef http://www.codechef.com/problems/FLIPCOIN/ i tried this using Segment tree... i implemented segment updating properly but dont know how to do segment Querying in this particular Question although point Querying is easy.. and please suggest links and

[algogeeks] Re: [brain teaser] Sequence Puzzle 13april

2011-04-17 Thread KK
@vaibhav shukla: 3 1 2 2 1 1 is ok but how 1 3 1 1 2 2 2 1 came Thanks On Apr 13, 2:57 pm, vaibhav shukla vaibhav200...@gmail.com wrote: On Wed, Apr 13, 2011 at 1:02 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: * Sequence Puzzle * * * *The below is a number puzzle. It should be

[algogeeks] Re: [brain teaser] Sequence Puzzle 13april

2011-04-17 Thread KK
Dont worry got it!!! On Apr 13, 2:57 pm, vaibhav shukla vaibhav200...@gmail.com wrote: On Wed, Apr 13, 2011 at 1:02 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: * Sequence Puzzle * * * *The below is a number puzzle. It should be read left to right, top to bottom. Question 1 What is

[algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2011-04-17 Thread KK
Hey can u mail it to me plzzz?? On Mar 23, 7:55 am, Anand anandut2...@gmail.com wrote: Thanks!! On Tue, Mar 22, 2011 at 7:11 PM, D.N.Vishwakarma@IITR deok...@gmail.comwrote: thanx... On 3/22/11, Himanshu Neema potential.himansh...@gmail.com wrote: -- Forwarded

[algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2011-04-17 Thread KK
Hey plzz mail me too.. On Apr 14, 9:29 am, Rajeev Kumar rajeevprasa...@gmail.com wrote: check this link:https://docs.google.com/viewer?a=vpid=explorerchrome=truesrcid=1B5... If you have any problem in access,please inform me On Thu, Apr 14, 2011 at 1:04 AM, Abhishek Goswami

[algogeeks] Re: Spoj Problem

2011-03-17 Thread KK
i m getting TLE for this soln and m not getting the concept used in the above soln can anyone help?? #includeiostream using namespace std; int main() { int t,n,k,no,flag; scanf(%d,t); while(t--) { scanf(%d,n); k = n; int a[100] = {0};

[algogeeks] Re: What would be the output of the following program..?

2010-12-14 Thread KK
the rule governs that in exprns on both the side gets evaluated only if first exprns gives TRUE if 1st one gives FALSE then whatever be 2nd exprn answer be FALSE and in || 2nd side is not evaluated if 1st side replies with TRUE.. On Dec 13, 9:10 pm, siva viknesh sivavikne...@gmail.com wrote:

[algogeeks] Re: What would be the output of the following program..?

2010-12-14 Thread KK
ya all the exprn is evaluated and left expr is assigned .. On Dec 13, 9:21 pm, siva viknesh sivavikne...@gmail.com wrote: #includestdio.h int main() {  int a=1,b=2,c=3;  c=--a,b++ - c;  printf(%d %d %d,a,b,c);  return 0;  } the above code is perfectly valid and prints 0 3 0 ... but

[algogeeks] Re: How to solve this problem efficiently?

2007-09-21 Thread KK
On Sep 5, 11:07 am, jliang [EMAIL PROTECTED] wrote: how about a doubled linked list where you can remove item at any index. the removing is O(1). you can also keep track of the current removing from a doubled linked list is O(1)? How? size S so if you are borrowing book at index greater