Re: [algogeeks] Hash Table ( A hashtable class in c++)

2011-09-02 Thread Aj G
#include #include #include #include using namespace std; // It is not advisable to list all elements in this hash table. #define HASH_SIZE 51439 class HashTable { public: vector< map > table; HashTable() { table = vector< map >(HASH_SIZE); } int hashF(long long key) { if( ke

[algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread aj
you can write a python program to do that easily. program starts here : c=str.split(raw_input()) d=[] for x in c: d[x]=0 print list(d) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@

[algogeeks] Re: Finding the distance between two permutations of a string of length N

2006-05-15 Thread aj
correctness is by induction on number of cycles. thx aj --~--~-~--~~~---~--~~ 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] Re: Median of 2 combined array X[1...n] and Y[1...n] sorted in 0(lgn)

2006-05-12 Thread aj
well the set (X + Y) will have O(n^2) elements, where X and Y have n elements. As an example X = {1, 2} Y = {3, 5} X + Y = {1 + 3, 1 + 5, 2 + 3, 2 + 5} = {4, 5, 6, 7} Now the problem is to find the median of X + Y in subquadratic time. thx aj

[algogeeks] Re: Median of 2 combined array X[1...n] and Y[1...n] sorted in 0(lgn)

2006-05-12 Thread aj
How about finding the median of (X + Y) in subquadratic time. X + Y = {z | z = xi + yj for some i and j}. I could only reduce the space complexity from O(n^2) to O(n) but time complexity still remains O(n^2). thx Aj --~--~-~--~~~---~--~~ You received this

[algogeeks] Re: A problem related to palindromes

2006-05-03 Thread aj
that's right, it has worst case quadratic time complexity. W Karas wrote: > aj wrote: > > linear worst case time. > > The best I can do is: > > bool is_palin(const char x[], unsigned len) > { > if (len < 2) > return(true); > for (u

[algogeeks] Re: A problem related to palindromes

2006-05-02 Thread aj
linear worst case time. --~--~-~--~~~---~--~~ 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 [EMAIL P

[algogeeks] Re: A problem related to palindromes

2006-05-02 Thread aj
hi daizi, I was expecting a solution that does not use suffix trees. Using suffix trees the problem can be solved easily, but I was just wondering if it is mandatory to use complex data structures like suffix trees to solve this problem. thx aj

[algogeeks] A problem related to palindromes

2006-05-01 Thread aj
Given a binary string x of length n, find the longest prefix of x in linear time which is a palindrome. thx aj --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this g

[algogeeks] Re: How to find, efficiently, the maximum sum of atleast L consecutive integers from a sequence of N integers.

2006-03-21 Thread aj
gth of the subsequence) then your solution is excellent with O(n) time and O(1) space complexity. thx Aj --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, sen

[algogeeks] Re: How to find, efficiently, the maximum sum of atleast L consecutive integers from a sequence of N integers.

2006-03-21 Thread aj
hey syed, where are you right now? me at EPFL, switzerland. By the way your solution is same as mine (dynamic programming one). Aj B.Tech (CSE), IIT Kanpur '03 --~--~-~--~~~---~--~~ You received this message because you are subscribed t

[algogeeks] Re: How to find, efficiently, the maximum sum of atleast L consecutive integers from a sequence of N integers.

2006-03-21 Thread aj
with at least L elements. I hope I didnt misunderstood what you wanted to say Aj ps: in your code there is no guarntee that the the subsequence has at least L elements. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

[algogeeks] Re: How to find, efficiently, the maximum sum of atleast L consecutive integers from a sequence of N integers.

2006-03-20 Thread aj
pe it helps Aj --~--~-~--~~~---~--~~ 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 [EMAIL PROT

[algogeeks] Re: determine whether a matrix is rearrangeable

2006-03-19 Thread aj
the matrix 1 1 1 1 1 1 1 1 1 has rank 1, but is still rearrangable, so it seems linear dependence has not much to do with the problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To po

[algogeeks] Re: determine whether a matrix is rearrangeable

2006-03-19 Thread aj
SPX2 wrote: > what complexity aj ? O(ne) where e is the n is the number of rows and e is the number of 1's in the matrix. worst case O(n^3). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm

[algogeeks] Re: determine whether a matrix is rearrangeable

2006-03-18 Thread aj
olumn entries 1 (r < k), and in that case even permuting columns will not help as these k rows can cover at most r diagonals, i.e., A is not rearrangable. hope it helps Aj --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

[algogeeks] scheduling problem

2006-03-17 Thread aj
scheduling, or this small modification moves the problem from the class P to the class of NP-complete. thanks in advance Aj --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post