Re: [algogeeks] trie implementation

2013-03-14 Thread Hassan Monfared
Check codingways.blogspot.com I posted a t9 implementation On Mar 14, 2013 12:44 PM, rahul sharma rahul23111...@gmail.com wrote: Can anybody provide me to understand t9 implementation? I dnt need code..I need how to implement t9 with trie with explanation..thnx in advance -- You received

Re: [algogeeks] Finding Minimum of the maximum values

2012-08-12 Thread Hassan Monfared
do we sum all cell values when we step over them ? On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Hi there, There is a integer Matrix with dimensions n*2, If you want to go from (1,1) to (n,2) and you are allowed just to go down or right, what's the maximum

Re: [algogeeks] Finding Minimum of the maximum values

2012-08-12 Thread Hassan Monfared
these maximum paths. On 8/12/12, MeHdi KaZemI mehdi.kaze...@gmail.com wrote: On 8/12/12, Hassan Monfared hmonfa...@gmail.com wrote: do we sum all cell values when we step over them ? On Sun, Aug 12, 2012 at 12:42 PM, MeHdi KaZemI mehdi.kaze...@gmail.comwrote: Hi

Re: [algogeeks] Finding Minimum of the maximum values

2012-08-12 Thread Hassan Monfared
. P.S. I have not written boundary condition. For this if M[i - 1, j] goes beyond matrix boundary then take M[i, j-1] value and vice versa. Initialize M[0, 0] = A[0, 0] On Sun, Aug 12, 2012 at 3:16 PM, Hassan Monfared hmonfa...@gmail.comwrote: DP can help us to find max path, I couldn't find

Re: [algogeeks] Hanoi problem

2012-08-12 Thread Hassan Monfared
at http://groups.google.com/group/algogeeks?hl=en. -- Hassan H. Monfared http://www.linkedin.com/pub/hassan-monfared/55/1b6/33 *I*men *R*ayaneh *S*hargh,+9821-88104832 CEO and technical manager -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] program

2012-07-26 Thread Hassan Monfared
+ Manish Patidar On Thu, Jul 26, 2012 at 10:14 PM, Manish Patidar manishpatidar...@gmail.com wrote: 20 Thank you, Have a great day !! * With Regards, * * Manish Patidar.* On Thu, Jul 26, 2012 at 11:11 PM, payal gupta gpt.pa...@gmail.com wrote:

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-07-02 Thread Hassan Monfared
this problem in linear time? On Fri, Jun 29, 2012 at 9:10 PM, Hassan Monfared hmonfa...@gmail.comwrote: Hi, this can be done by simple modification in bubble sort : void inplace_pos_neg(int pdata[],int sz) { bool changed=false; do { changed=false; for(int i=1;isz;i++) if(pdata[i-1]0 pdata

Re: [algogeeks] MS Question: Segregrate positive and negative nos in array without changing order

2012-06-29 Thread Hassan Monfared
Hi, this can be done by simple modification in bubble sort : void inplace_pos_neg(int pdata[],int sz) { bool changed=false; do { changed=false; for(int i=1;isz;i++) if(pdata[i-1]0 pdata[i]0) { swap(pdata[i-1], pdata[i]); changed=true; } }while(changed); } void test_inplace_pos_neg() { int

Re: [algogeeks] Find peak element in log(n)

2012-06-24 Thread Hassan Monfared
difficulty/error, let me know. On Sun, Jun 24, 2012 at 1:27 AM, Hassan Monfared hmonfa...@gmail.com wrote: Given an array of integers find a peak element of array in log(n) time. for example if A={3,4,6,5,10} then peak element is 6 ( 65 64 ). Regards. -- You received

Re: [algogeeks] spoj problem EASYMATH

2012-06-24 Thread Hassan Monfared
use return (a/gcd(a,b)*b instead On Sun, Jun 24, 2012 at 7:10 PM, Sourabh Singh singhsourab...@gmail.comwrote: please suggest something : Problem : http://www.spoj.pl/problems/EASYMATH/ C++ code : http://ideone.com/r2OSb was getting wrong ans due to over flow i think in LCM() for big

[algogeeks] Find peak element in log(n)

2012-06-23 Thread Hassan Monfared
Given an array of integers find a peak element of array in log(n) time. for example if A={3,4,6,5,10} then peak element is 6 ( 65 64 ). Regards. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Find peak element in log(n)

2012-06-23 Thread Hassan Monfared
than its immediate right one. Just implement binary search with these additional constraints, thereby giving O(log n). In case of any difficulty/error, let me know. On Sun, Jun 24, 2012 at 1:27 AM, Hassan Monfared hmonfa...@gmail.comwrote: Given an array of integers find a peak element of array

Re: [algogeeks] Find peak element in log(n)

2012-06-23 Thread Hassan Monfared
at 1:27 AM, Hassan Monfared hmonfa...@gmail.com wrote: Given an array of integers find a peak element of array in log(n) time. for example if A={3,4,6,5,10} then peak element is 6 ( 65 64 ). Regards. -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Find peak element in log(n)

2012-06-23 Thread Hassan Monfared
Singh singhsourab...@gmail.comwrote: @Hassan Monfared was reading that link only. it's strange how he assume's we can leave half of element's ?? – If A[n/2-1]A[n/2] then search for a peak among A[1]… A[n/2-1] ?? why ?? eg. 12 12 12 11 1 2 5 3 m i missing something ?? On Sat, Jun 23, 2012

Re: [algogeeks] Re: Reverse Queue

2012-06-20 Thread Hassan Monfared
void Reverse(std::queueint pQ) { if(pQ.empty()) return; int item=pQ.front(); pQ.pop(); Reverse(pQ); pQ.push(item); } Regards On Wed, Jun 20, 2012 at 9:41 PM, enchantress elaenjoy...@gmail.com wrote: Queues are basically linked lists with head and tail pointers. It is possible to reverse the

Re: [algogeeks] Re: Reverse Queue

2012-06-20 Thread Hassan Monfared
reach middle point. Wont this use O(1) space and O(n/2) time. On Wed, Jun 20, 2012 at 1:56 PM, Hassan Monfared hmonfa...@gmail.comwrote: void Reverse(std::queueint pQ) { if(pQ.empty()) return; int item=pQ.front(); pQ.pop(); Reverse(pQ); pQ.push(item); } Regards On Wed, Jun 20

Re: [algogeeks] Analysis of Partial Sorting.

2012-06-17 Thread Hassan Monfared
O(N*logM) On Sat, Jun 16, 2012 at 5:15 PM, Amitesh Singh singh.amit...@gmail.comwrote: Hi Guys, *Problem: *Rearrange a given array with n elements, so that m places contain the m smallest elements in ascending order. *Solution 2:* using QuickSort method approach. [image: n = r -p + 1]

Re: [algogeeks] water trap

2012-06-15 Thread Hassan Monfared
Hi, I solved it with a recursive solution and published in my blog : http://codingways.blogspot.com/2012/06/rain-water-trap-problem-2d-version.html please let me know if you have any idea. Regards, Hassan On Fri, Jun 15, 2012 at 2:15 PM, utsav sharma utsav.sharm...@gmail.comwrote: pls explain

Re: [algogeeks] LEFT MOST set bit in an unsigned integer.

2012-06-14 Thread Hassan Monfared
It is equal to counting leading zeros. previous codes run in O(32). this code ( http://codingways.blogspot.com/2012/06/count-leading-zero-bits-in-integer.html ) runs in O(4) Regards, Hassan On Thu, Jun 14, 2012 at 2:34 PM, utsav sharma utsav.sharm...@gmail.comwrote: there are two approaches we

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Hassan Monfared
how can you pop from empty stack ? temp=pop(S); Regards, Hassan On Thu, Jun 14, 2012 at 8:25 PM, Ashish Goel ashg...@gmail.com wrote: Navin: copy pastes not encouraged till the logic is also clarified ;) Best Regards Ashish Goel Think positive and find fuel in failure +919985813081

Re: [algogeeks] c++ webservice in linux machine

2012-06-11 Thread Hassan Monfared
use gSOAP On Tue, Jun 12, 2012 at 5:24 AM, rgap rgap...@gmail.com wrote: Hi i want to write a c++ webservice which should work in linux machine with apache being the web server. Are there any libraries which allow you to write server-side applications that handle the HTTP requests with

[algogeeks] search in O(logn)

2012-06-08 Thread Hassan Monfared
A sorted array of integers is rotated unknown times. find an item in O(logn) time and O(1) space complexity. for example : 1,2,3,7,10,14 ---rotated 3 times-- 7,10,14,1,2,3 find 2 in O(logn) time in O(1) space complexity Regards Hassan H. Monfared -- You received this message because you

Re: [algogeeks] Re: search in O(logn)

2012-06-08 Thread Hassan Monfared
, 2012 8:41:47 AM UTC-5, Hassan Monfared wrote: A sorted array of integers is rotated unknown times. find an item in O(logn) time and O(1) space complexity. for example : 1,2,3,7,10,14 ---rotated 3 times-- 7,10,14,1,2,3 find 2 in O(logn) time in O(1) space complexity Regards Hassan H

Re: [algogeeks] Re: amazon interview questions

2012-06-06 Thread Hassan Monfared
+919985813081 +919966006652 On Tue, Jun 5, 2012 at 11:32 PM, Hassan Monfared hmonfa...@gmail.comwrote: yes It's valid, cuz it doesn't have any repeated substring next together On Tue, Jun 5, 2012 at 7:08 PM, Lomash Goyal lomesh.go...@gmail.comwrote: is geke is a invalid strng? On Tue

Re: [algogeeks] Re: amazon interview questions

2012-06-05 Thread Hassan Monfared
in failure +919985813081 +919966006652 On Mon, Jun 4, 2012 at 11:20 AM, Hassan Monfared hmonfa...@gmail.comwrote: for -- 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

Re: [algogeeks] Re: amazon interview questions

2012-06-05 Thread Hassan Monfared
yes It's valid, cuz it doesn't have any repeated substring next together On Tue, Jun 5, 2012 at 7:08 PM, Lomash Goyal lomesh.go...@gmail.com wrote: is geke is a invalid strng? On Tue, Jun 5, 2012 at 12:17 PM, Hassan Monfared hmonfa...@gmail.comwrote: Ashish: the algorithm passes over

Re: [algogeeks] Matrix Minimum Path Sum

2012-06-04 Thread Hassan Monfared
for non-negative values Dijkstra will solve the problem in ( O(N^2) ) and Floyd-Warshal is the solution for negative cells. ( O(N^3) ) On Mon, Jun 4, 2012 at 11:20 AM, atul anand atul.87fri...@gmail.com wrote: this recurrence wont work..ignore On Mon, Jun 4, 2012 at 8:55 AM, atul anand

Re: [algogeeks] Matrix Minimum Path Sum

2012-06-04 Thread Hassan Monfared
moving must be done in A* style On Mon, Jun 4, 2012 at 1:17 PM, atul anand atul.87fri...@gmail.com wrote: i dont think so dijistra will worh here..bcozz we cannot move diagonally ...but according to matrix this path can be considered. On Mon, Jun 4, 2012 at 1:39 PM, Hassan Monfared hmonfa

Re: [algogeeks] interview HARD problem

2012-06-04 Thread Hassan Monfared
Give a sample please On Mon, Jun 4, 2012 at 5:34 PM, Ashish Goel ashg...@gmail.com wrote: Given a dictionary of millions of words, give an algorithm to find the largest possible rectangle of letter that every row forms a word(reading left to right) and every column forms a word(reading from

Re: [algogeeks] Re: amazon interview questions

2012-06-03 Thread Hassan Monfared
yes it's not valid On Sun, Jun 3, 2012 at 5:36 PM, anugrah anugrah.agra...@gmail.com wrote: So any string with two same characters is not valid?? for example : GEEK has E followed by E. So GEEK is also invalid? On Jun 3, 1:49 pm, Hassan Monfared hmonfa...@gmail.com wrote: bool IsValid

Re: [algogeeks] Simple Question ,Find Error

2012-06-03 Thread Hassan Monfared
you can't assign value into names[i]! On Mon, Jun 4, 2012 at 3:12 AM, mahendra sengar sengar.m...@gmail.comwrote: main() { static char names[5][20]={pascal,ada,cobol,fortran,perl}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i=4;i++) printf(%s,names[i]); }

Re: [algogeeks] Re: amazon interview questions

2012-06-03 Thread Hassan Monfared
PM, Hassan Monfared hmonfa...@gmail.comwrote: yes it's not valid On Sun, Jun 3, 2012 at 5:36 PM, anugrah anugrah.agra...@gmail.comwrote: So any string with two same characters is not valid?? for example : GEEK has E followed by E. So GEEK is also invalid? On Jun 3, 1:49 pm, Hassan

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-06-01 Thread Hassan Monfared
1- read all elements of list into stack 2- max = stak.pop() 3- if stack.empty() goto 7 4- next=stack.pop() 5- if next max then max=next else delete next from list 6- repeat from 3 7- end! Regards, On Thu, May 31, 2012 at 9:45 PM, atul anand atul.87fri...@gmail.com wrote: @navin : +1 On

Re: [algogeeks] Linked list using void pointer

2012-05-31 Thread Hassan Monfared
Why don't you use templates ? template class T class LNode { public: LNode(T pData,LNode *pNext):data(pData),next(pNext){} T data; LNode *next; }; template class T class LList { protected: LNodeT *head; LNodeT *tail; public: LList() { head=tail=NULL; } void push_back(T pData) {

Re: [algogeeks] Tree/Graph implementation

2012-05-29 Thread Hassan Monfared
you can use adjacency matrices for spare graphs and two dimensional array for non-spare graphs On Tue, May 29, 2012 at 2:47 PM, prakash y yprakash@gmail.com wrote: How to implement complex data structures like trees (with unknown no.of subtrees) and graphs efficiently in C/Java? I have

Re: [algogeeks] problem with increment operator

2012-05-29 Thread Hassan Monfared
I implemented ++ for a simple class and got 17. class A { public : int val; A(int v):val(v){} int operator++() { cout empty arg called\n; return ++val; } int operator++(int x) { cout x:arged arg called\n; return val++; } }; -- A b(4); cout ++a + ++a +a++endl; 17 but

Re: [algogeeks] whats a CALL BACK in C?

2012-05-28 Thread Hassan Monfared
You can pass a function pointer to a function to be called after that function finished its job. On Tue, May 29, 2012 at 12:52 AM, rahul r. srivastava rahul.ranjan...@gmail.com wrote: whats a CALL BACK in C? -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: MS question : string compression

2012-05-26 Thread Hassan Monfared
u forgot to do inplace and you have wrong conversion of count On Sat, May 26, 2012 at 11:31 AM, Anchal Gupta anchal92gu...@gmail.comwrote: hey, here is the function that do the compression and store the output in an array op. void str_comp(char *str) { int count=0,j=0,i; char

Re: [algogeeks] Re: MS question : string compression

2012-05-26 Thread Hassan Monfared
, Hassan Monfared hmonfa...@gmail.com wrote: u forgot to do inplace and you have wrong conversion of count On Sat, May 26, 2012 at 11:31 AM, Anchal Gupta anchal92gu...@gmail.com wrote: hey, here is the function that do the compression and store the output in an array op