Re: [algogeeks] Add 2 long integers with digits represented by linked lists

2010-02-01 Thread Algoose Chase
@saurabh : so you scanned to find out that both lists are same : O(n) (agreed) prepare list 3 in time O(n) (agreed) process list 3 in time O(n) (*HOW ??*) can you run through your method and show how you process list 3 in O(n) using the below lists as input: 5->5->5->5->5->5->5->5->5->5 and 4->4->

Re: [algogeeks] recursive algorithm

2010-02-01 Thread Sieu Truc
initial assignmnet: g()={n1,..,nd) inter(i) { if(i<0) return; for(int j=0;j wrote: > Can you please help me with this one. > > write two algorithms that iterate over every index from (0,0,..,0) > to (n1,n2,..,nd).Make one algorithm recursive and the other > iterative. > > Th

Re: [algogeeks] string ques

2010-02-01 Thread Algoose Chase
Hope you meant a pattern is sub-array containing 2 or more UNIQUE chars. hope based on dfn, "abcd" is also a pattern in the input you have given. On Tue, Feb 2, 2010 at 1:11 AM, ankit mahendru wrote: > Q. Find all the patterns once which are present in the character array > given. A pattern is a

Re: [algogeeks] Add 2 long integers with digits represented by linked lists

2010-02-01 Thread saurabh gupta
nope, if both lists are of same length list 4 is not required and you save time to deal with list 4 so, you have list 3 only time reqd is O(3n) 3 passes approximately On Mon, Feb 1, 2010 at 11:24 AM, Algoose Chase wrote: > Thats true ! , The purpose is to add very long integers such that we c

[algogeeks] string ques

2010-02-01 Thread ankit mahendru
Q. Find all the patterns once which are present in the character array given. A pattern is a sub-array containing 2 or more chars. Example: i/p: aabcdadabc o/p: ab, abc, bc, da -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to thi

Re: [algogeeks] Add 2 long integers with digits represented by linked lists

2010-02-01 Thread saurabh gupta
the key observation is that your requirement for no space is nullified by using the space in the resultant list. so you scanned to find out that both lists are same : O(n) prepare list 3 in time O(n) process list 3 in time O(n) current list 3 is the answer as list 4 is empty total time O(n) as k

[algogeeks] recursive algorithm

2010-02-01 Thread DMX
Can you please help me with this one. write two algorithms that iterate over every index from (0,0,..,0) to (n1,n2,..,nd).Make one algorithm recursive and the other iterative. Thanks -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. T

Re: [algogeeks] Add 2 long integers with digits represented by linked lists

2010-02-01 Thread Algoose Chase
Thats true ! , The purpose is to add very long integers such that we cant use premative data types to represent them. The point I was trying to prove is : you would need to go through multiple passes through the list(essentially to propagate carry) when you have conditions like No Reversing the

Re: [algogeeks] missing integers in an unsorted array

2010-02-01 Thread Anil Kishore
This is clearly explained in the previous mail isn't it ? .. Anyway, sum of 1..n is S = n*(n+1)/2 . So, find the sum of all elements in the given input array, say the sum is T, this sum is almost same as S, its just less than S by the missing number. so, ( S - T ) will give the answer. Are you look

[algogeeks] Re: missing integers in an unsorted array

2010-02-01 Thread sachin
A way to solve this problem would be using xor(exclusive OR) xor all the elements from 1 to n.Call it A xor all the elements of the array into a variable B Now missing element = A xor B It works this way xor-ing an element with itself gives 0(p xor p=0) xor-ing an element with 0 gives the element i