Re: [algogeeks] Re: amazon,microsoft link list probs

2011-10-10 Thread rahul patil
On Thu, Oct 6, 2011 at 3:30 PM, 9ight coder 9ightco...@gmail.com wrote:

 hey ankit can u show me 1st question solution

 On Oct 5, 9:06 pm, Ankur Garg ankurga...@gmail.com wrote:
  Implement recursive merge sort for first question(Implement recursive
 merge sort for first question )
 
  For second just swap the values of node and node b
 
 
 
 
 
 
 
  On Wed, Oct 5, 2011 at 9:18 PM, 9ight coder 9ightco...@gmail.com
 wrote:
   1.perform inplace(we cant create new node)merge sort of two sorted
   linked list.(asked in amazon 1 mon before)
   2.a-b-c-d-e  convert to b-a-d-c-e  without creating new node.
   (asked in microsoft on 4rth oct at thapar).
 


Please elaborate the question. It must be condition that you should not swap
elements, you have to change the link pointer.




   sugeest solutions.
 
   --
   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
  http://groups.google.com/group/algogeeks?hl=en.

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards,
Rahul Patil

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Algo for Search in a 2D Matrix

2011-10-10 Thread shiva@Algo
id we see the pattern then we can easily find that the kth smallest element
lie on the upper half of the k*k submatrix(on the upperleft corner )
we can do search on  (k*k)/2 elements to find that

On Mon, Oct 10, 2011 at 10:36 AM, Dave dave_and_da...@juno.com wrote:

 @Shubham: So if the matrix is
 1 2
 3 4
 and you want the 2nd smallest, are you saying that it is 4?

 Dave

 On Oct 9, 7:40 pm, shubham goyal shubhamgoyal.n...@gmail.com wrote:
  im assuming it be a square matrix
  then kth smallest element will be in a first k*k sub matrix.
  jst look for smallest element in the diagonal of this matrix.
  it will give the kth smallest element .
 
 
 
  On Mon, Oct 10, 2011 at 4:45 AM, Ankur Garg ankurga...@gmail.com
 wrote:
   Given a 2D matrix which is both row wise and column wise sorted.
 Propose an
   algorithm for finding the kth smallest element in it in least time
   complexity
 
   A General Max Heap can be used with k space and n+klogk complexity
 
   Any other solution  or even a way by which we dont scan the whole
 matrix to
   find the solution ?
 
   I
 
   --
   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
  http://groups.google.com/group/algogeeks?hl=en.

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] How to Solve This

2011-10-10 Thread VIHARRI
For every number that has 3 in its units place has one multiple which
has all one's i.e. 111 is
such multiple and 13 has a multiple 11. Write a program to find
such multiple for any
number that has 3 at its units place.

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Posts on INTERVIEW QUERIES will be REMOVED

2011-10-10 Thread siva viknesh
If you want ask for any interview or company related queries , kindly
join new group.

http://groups.google.com/group/interview-street

..Only ALGORITHM RELATED interview questions from any company will
be posted ...Kindly notify your friends too

For more details visit this thread...

http://groups.google.com/group/algogeeks/browse_thread/thread/9d7c8ff9cacb6493

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Additive sequence

2011-10-10 Thread anand karthik
Hi,

I dont remember the question text exactly but the following should
convey it well

The question:

A number is said to be an additive number if it has the following format:

3268126844 : 32 6812 6844 :  32 + 6812 = 6844
123581321 : 1 2 3 5 8 13 21 : 1+2  = 3 , 2+3 = 5 , 3+5=8, 5+8 = 13, 8+13 -21
347  : 3 4 7 : 3+4=7
122331234346746 : 122 3312 3434 6746 : 122 + 3312 = 3434 , 3312+3434  = 6746


If the number is broken down into non zero ( 303 : 3+0 = 3 is not
additive ) segments,and when these segments are taken in groups of
consecutive 3 ,(so two digit or single digit inputs wont qualify), the
first two should add up to the third number, such a number is called
as an additive number.

Given a range of numbers, print all the numbers  which are additive in
the sequence.

Give an approach other than brute force.

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] How to Solve This

2011-10-10 Thread anshu mishra
string all1Multiple(int x)
{
string s;
setint mySet;
mySet.push(0);
int psize, r=1;
do
{
psize = mySet.size();
s += '1';
r = r % x;
mySet.push(r);
r = r * 10 + 1;
} while(mySet.size()  psize);

if (r != 1) return not Possible;
return s;
}

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Fwd: why we can not swap values using macro?

2011-10-10 Thread rahul sharma
macros i thnik cant swap pointers..i have doubt for same it is test ur c
skil question

On Sun, Oct 9, 2011 at 10:08 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 because you have not made any call to swap values of x and y

 I Don't know what you are trying to do here
 if you want to swap values why are you not calling macro swap(x,y,int)
 you are making a macro call to swap pointers and you can check that pointer
 will get swapped.


 On Sun, Oct 9, 2011 at 9:20 PM, Rajesh Kumar testalgori...@gmail.comwrote:



 -- Forwarded message --
 From: Rajesh Kumar testalgori...@gmail.com
 Date: Sun, Oct 9, 2011 at 2:58 PM
 Subject: why we can not swap values using macro?
 To: algogeeks@googlegroups.com


 why this code doesn't swap values of x and y?

 #includestdio.h
 #define swap(a,b,c) c t;t=a,a=b,b=t;
 main()
 {
 float x=10,y=20;
 float *p,*q;
 p=x,q=y;
 swap(p,q,float *);
 printf(%d %d\n,x,y);
 }


 --
 Regards
 Rajesh Kumar





 --
 Regards
 Rajesh Kumar


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Sunny Aggrawal
 B.Tech. V year,CSI
 Indian Institute Of Technology,Roorkee


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Memorization

2011-10-10 Thread arvind kumar
Can anyone tell me how to go about with the memorization technique to
retrieve values from already stored values,in case of eveluating
sequences(fibonacci series,etc).?

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.




Re: [algogeeks] Fwd: why we can not swap values using macro?

2011-10-10 Thread sunny agrawal
Macros can Swap Pointers. and That is what the above code is doing.



On Mon, Oct 10, 2011 at 5:52 PM, rahul sharma rahul23111...@gmail.comwrote:

 macros i thnik cant swap pointers..i have doubt for same it is test ur c
 skil question


 On Sun, Oct 9, 2011 at 10:08 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 because you have not made any call to swap values of x and y

 I Don't know what you are trying to do here
 if you want to swap values why are you not calling macro swap(x,y,int)
 you are making a macro call to swap pointers and you can check that
 pointer will get swapped.


 On Sun, Oct 9, 2011 at 9:20 PM, Rajesh Kumar testalgori...@gmail.comwrote:



 -- Forwarded message --
 From: Rajesh Kumar testalgori...@gmail.com
 Date: Sun, Oct 9, 2011 at 2:58 PM
 Subject: why we can not swap values using macro?
 To: algogeeks@googlegroups.com


 why this code doesn't swap values of x and y?

 #includestdio.h
 #define swap(a,b,c) c t;t=a,a=b,b=t;
 main()
 {
 float x=10,y=20;
 float *p,*q;
 p=x,q=y;
 swap(p,q,float *);
 printf(%d %d\n,x,y);
 }


 --
 Regards
 Rajesh Kumar





 --
 Regards
 Rajesh Kumar


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Sunny Aggrawal
 B.Tech. V year,CSI
 Indian Institute Of Technology,Roorkee


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Sunny Aggrawal
B.Tech. V year,CSI
Indian Institute Of Technology,Roorkee

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread sandeep nagamalli
@Shiva: How can min heap be uesd, can you eloborate a bit.

As far as i see, the best possible is O(nlogn) i.e by sorting and scanning
over the complete array once.



On Mon, Oct 10, 2011 at 9:49 AM, shiva@Algo shiv.jays...@gmail.com wrote:

 I think Min heap will do that..


 On Mon, Oct 10, 2011 at 12:37 AM, Ankur Garg ankurga...@gmail.com wrote:

 Given an unsorted array of Integers

 Find 2 nos whose diff is minimum

 Say Array is  4 2 18 19 11 8 5

 Nos are 18 and 19

 Algo shud be of O(n)

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




-- 
ThanksRegards:
-sandeep

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread Deoki Nandan
just find minimum and secon minimum by taking two variables in O(n)

On 10 October 2011 17:57, sandeep nagamalli nsandee...@gmail.com wrote:

 @Shiva: How can min heap be uesd, can you eloborate a bit.

 As far as i see, the best possible is O(nlogn) i.e by sorting and scanning
 over the complete array once.




 On Mon, Oct 10, 2011 at 9:49 AM, shiva@Algo shiv.jays...@gmail.comwrote:

 I think Min heap will do that..


 On Mon, Oct 10, 2011 at 12:37 AM, Ankur Garg ankurga...@gmail.comwrote:

 Given an unsorted array of Integers

 Find 2 nos whose diff is minimum

 Say Array is  4 2 18 19 11 8 5

 Nos are 18 and 19

 Algo shud be of O(n)

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




 --
 ThanksRegards:
 -sandeep


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




-- 
**With Regards
Deoki Nandan Vishwakarma
IIT ROORKEE
9760340784
for Computer Science Interview Material see my home page
https://sites.google.com/site/deokinandanmaterials/

*
*

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] subset of an array

2011-10-10 Thread Rashmi Jain
algo to find subsets of an array whose sum is equal to a given number..?

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Give Algo to do this in O(n)

2011-10-10 Thread sravanreddy001
Without sorting the elements we have around n^2 elements to look from, to 
find the smalled element.

But, after sort, we will have only n-1 elements to look from. So, O(nlogn) 
is what I see, the best case.

Is there really a O(n) solution, as finding the diff between elements should 
be done comparing will every other. (unsorted)
or selected ones (after sort)

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/-ac6LuuRRQkJ.
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread snehi jain
@ ankur:
 if space is not the consideration
first sort them using count sort and then look for the pair with the min.
difference ..
i think it should work .


Snehi



On Mon, Oct 10, 2011 at 7:21 PM, anubhav gupta anubhav.7...@gmail.comwrote:

  @deoki try for 1001,999,998,1


 On Mon, Oct 10, 2011 at 6:57 PM, Deoki Nandan deok...@gmail.com wrote:

 just find minimum and secon minimum by taking two variables in O(n)

 On 10 October 2011 17:57, sandeep nagamalli nsandee...@gmail.com wrote:

 @Shiva: How can min heap be uesd, can you eloborate a bit.

 As far as i see, the best possible is O(nlogn) i.e by sorting and
 scanning over the complete array once.




 On Mon, Oct 10, 2011 at 9:49 AM, shiva@Algo shiv.jays...@gmail.comwrote:

 I think Min heap will do that..


 On Mon, Oct 10, 2011 at 12:37 AM, Ankur Garg ankurga...@gmail.comwrote:

 Given an unsorted array of Integers

 Find 2 nos whose diff is minimum

 Say Array is  4 2 18 19 11 8 5

 Nos are 18 and 19

 Algo shud be of O(n)

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




 --
 ThanksRegards:
 -sandeep


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




 --
 **With Regards
 Deoki Nandan Vishwakarma
 IIT ROORKEE
 9760340784
 for Computer Science Interview Material see my home page
 https://sites.google.com/site/deokinandanmaterials/

 *
 *

  --
 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] subset of an array

2011-10-10 Thread Hatta
is it a contiguous set, any sparse subset or what?

if it's a subset of a set then it can be sparse, but when you say
array you make it quite tricky to figure out.

with all due respect sir,
please mind that when you make a question you're taking peoples time
to answer it
therefore if the answer is useless to you  you'd have wasted someone
else's time with no reason. so please, I gently ask you to make a
clear question next time.




On Mon, Oct 10, 2011 at 11:47 AM, Rashmi Jain rashmi.jain...@gmail.com wrote:
 algo to find subsets of an array whose sum is equal to a given number..?

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Hatta

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread sravanreddy001
Just went throught what a count sort is at 
http://en.wikipedia.org/wiki/Counting_sort

If all the elements are distinct which is possible, will this count sort 
have any use?

Also, the sorting takes O(nlogn) time right?

Did I miss anything?

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/08bcRsmFYJgJ.
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: why we can not swap values using macro?

2011-10-10 Thread sravanreddy001
The swap is happenning between the p  q pointers,

https://ideone.com/4MdX4

p points to y, q points to x after swap.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/XvbyN8ajVEUJ.
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] subset of an array

2011-10-10 Thread Rashmi Jain
not necessary contiguous..
eg:
we are given with an array-1,4,2,26,8,3 and we need to find the subsets of
this having sum of its members as 11.
ans should be  1,2,8 and 8,3
i hope i am clear this time..

On Mon, Oct 10, 2011 at 9:38 PM, Hatta tmd...@gmail.com wrote:

 is it a contiguous set, any sparse subset or what?

 if it's a subset of a set then it can be sparse, but when you say
 array you make it quite tricky to figure out.

 with all due respect sir,
 please mind that when you make a question you're taking peoples time
 to answer it
 therefore if the answer is useless to you  you'd have wasted someone
 else's time with no reason. so please, I gently ask you to make a
 clear question next time.




 On Mon, Oct 10, 2011 at 11:47 AM, Rashmi Jain rashmi.jain...@gmail.com
 wrote:
  algo to find subsets of an array whose sum is equal to a given number..?
 
  --
  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
  http://groups.google.com/group/algogeeks?hl=en.
 



 --
 Hatta

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread Ankur Garg
@Sravan ..Counting Sort takes O(n) time but it needs range of nos to be
known
@Snehi jain..there is no range given so am not sure if count sort will work
,Can you please elaborate a bit on ur method

Ankur

On Mon, Oct 10, 2011 at 10:09 PM, sravanreddy001
sravanreddy...@gmail.comwrote:

 Just went throught what a count sort is at
 http://en.wikipedia.org/wiki/Counting_sort

 If all the elements are distinct which is possible, will this count sort
 have any use?

 Also, the sorting takes O(nlogn) time right?

 Did I miss anything?

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/08bcRsmFYJgJ.

 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
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Memorization

2011-10-10 Thread Ankur Garg
Memoization ?

On Mon, Oct 10, 2011 at 6:34 PM, arvind kumar arvindk...@gmail.com wrote:

 Can anyone tell me how to go about with the memorization technique to
 retrieve values from already stored values,in case of eveluating
 sequences(fibonacci series,etc).?

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] remove duplicate words from a string

2011-10-10 Thread sachin goyal
remove duplicate words from a string with min. complexityy.

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] subset of an array

2011-10-10 Thread anshu mishra
the simplest code could be for this question is

void printAllSubsetSum(int ar[], int n, int x)
{
for (i = 0; i  (1n); i++)
{
int sum = 0;
 for (j = 0; j  n; j++)
 {
if ( (1  j)  i) sum += ar[j];
 }
 if (sum == x)
 {
for (j = 0; j  n; j++)
   {
   if ( (1  j)  i) printf(%d , ar[j]);
   }
  printf(\n);
 }
}
}

Time complexity O(2^n)

this can be solved using DP in O(n * given number);

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread snehi jain
ankur : i wont say its the best way, but it can be used
   in one traversal the range can be determined and then count sort
can be applied.



On Mon, Oct 10, 2011 at 10:56 PM, Ankur Garg ankurga...@gmail.com wrote:

 @Sravan ..Counting Sort takes O(n) time but it needs range of nos to be
 known
 @Snehi jain..there is no range given so am not sure if count sort will work
 ,Can you please elaborate a bit on ur method

 Ankur


 On Mon, Oct 10, 2011 at 10:09 PM, sravanreddy001 sravanreddy...@gmail.com
  wrote:

 Just went throught what a count sort is at
 http://en.wikipedia.org/wiki/Counting_sort

 If all the elements are distinct which is possible, will this count sort
 have any use?

 Also, the sorting takes O(nlogn) time right?

 Did I miss anything?

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/08bcRsmFYJgJ.

 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread sunny agrawal
Counting Sort is really a Bad option for this Problem as range is not given
yes range can be find in single traversal but think if largest element is
10^9 and size of the array is just about 10^3
Counting Sort = O(10^9)
Simple Sorting = O(10^4)

Counting sort will perform bad in this case both in terms of Space
Requirements and Time

On Mon, Oct 10, 2011 at 11:25 PM, snehi jain snehijai...@gmail.com wrote:

 ankur : i wont say its the best way, but it can be used
in one traversal the range can be determined and then count sort
 can be applied.



 On Mon, Oct 10, 2011 at 10:56 PM, Ankur Garg ankurga...@gmail.com wrote:

 @Sravan ..Counting Sort takes O(n) time but it needs range of nos to be
 known
 @Snehi jain..there is no range given so am not sure if count sort will
 work ,Can you please elaborate a bit on ur method

 Ankur


 On Mon, Oct 10, 2011 at 10:09 PM, sravanreddy001 
 sravanreddy...@gmail.com wrote:

 Just went throught what a count sort is at
 http://en.wikipedia.org/wiki/Counting_sort

 If all the elements are distinct which is possible, will this count sort
 have any use?

 Also, the sorting takes O(nlogn) time right?

 Did I miss anything?

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/08bcRsmFYJgJ.

 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Sunny Aggrawal
B.Tech. V year,CSI
Indian Institute Of Technology,Roorkee

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] remove duplicate words from a string

2011-10-10 Thread Ankur Garg
I think this can be done through tries

Any better solution ?

On Mon, Oct 10, 2011 at 10:59 PM, sachin goyal monugoya...@gmail.comwrote:

 remove duplicate words from a string with min. complexityy.

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] remove duplicate words from a string

2011-10-10 Thread sunny agrawal
Trie will take too much space..
Balanced Binary tree can be Better ...??

On Tue, Oct 11, 2011 at 12:16 AM, Ankur Garg ankurga...@gmail.com wrote:

 I think this can be done through tries

 Any better solution ?

 On Mon, Oct 10, 2011 at 10:59 PM, sachin goyal monugoya...@gmail.comwrote:

 remove duplicate words from a string with min. complexityy.

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Sunny Aggrawal
B.Tech. V year,CSI
Indian Institute Of Technology,Roorkee

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Give Algo to do this in O(n)

2011-10-10 Thread Dave
A radix sort would provide an O(n) solution for any fixed-size integer
data type.

Dave

On Oct 10, 10:19 am, sravanreddy001 sravanreddy...@gmail.com wrote:
 Without sorting the elements we have around n^2 elements to look from, to
 find the smalled element.

 But, after sort, we will have only n-1 elements to look from. So, O(nlogn)
 is what I see, the best case.

 Is there really a O(n) solution, as finding the diff between elements should
 be done comparing will every other. (unsorted)
 or selected ones (after sort)

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] i cannot solve this written test question

2011-10-10 Thread icy`
one possible ruby solution/pic  attached

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.

attachment: digsum_output.png

[algogeeks] i cannot solve this written test question

2011-10-10 Thread icy`
one possible solution in ruby  (sry if this is double-posted -- i did not
see it come up the first time)

[image: digsum_output.png]

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.

digsum_output.png

[algogeeks] Re: remove duplicate words from a string

2011-10-10 Thread icy`
a)
1. could split the string using a regexp (into an array) in which you
define a word  --  is  hi.  the same as hi,  and hi  ?
2. then perform a unique operation on the array (some languages have
this built in) to remove duplicates
3. recombine array elements into string by joining with a space, for
example, depending on how you split it in the first step

b) Perhaps another way, in-place, could be to check the string, one
word (again define this) at a time, storing each word in a hash.  If
the hash already contains the word, replace this occurrence with
spaces or null bytes.  Finally compact the string (remove all null
bytes, or turn all extra spaces into one space, etc).

icy`

On Oct 10, 3:08 pm, sunny agrawal sunny816.i...@gmail.com wrote:
 Trie will take too much space..
 Balanced Binary tree can be Better ...??









 On Tue, Oct 11, 2011 at 12:16 AM, Ankur Garg ankurga...@gmail.com wrote:
  I think this can be done through tries

  Any better solution ?

  On Mon, Oct 10, 2011 at 10:59 PM, sachin goyal monugoya...@gmail.comwrote:

  remove duplicate words from a string with min. complexityy.

  --
  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
 http://groups.google.com/group/algogeeks?hl=en.

   --
  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
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Sunny Aggrawal
 B.Tech. V year,CSI
 Indian Institute Of Technology,Roorkee

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Find the later version

2011-10-10 Thread bagaria.ka...@gmail.com
Given two strings describing the version of a particular software need to
find the later version.

For eg.
1st string = 1.2.4.5
2nd string=1.2.3.5

1st string is the later one.

Can be done using traversing the string and comparing each character one
after the another. Looking for a better solution with lesser complexity.

-- 
Thanks and Regards

*Karan Bagaria*
*MCA Final Year*
Training and Placement Representative
*NIT Durgapur*

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] remove duplicate words from a string

2011-10-10 Thread Ankur Garg
@Sunny..How do u intend to store them in a Tree ? Can you explain ?

In a trie u first insert the first word ..take the second word..If its not
present in the trie u insert it else remove it from original string
.Alternatively u store the elements in a trie in the initial string and
terminate it with '\0' and return it . In the worst case trie will take O(n)
space where n is the no of letters in the string . and Traversal  and
creation and search too will take O(n).

How abt Balanced Binary Tree ?

On Tue, Oct 11, 2011 at 12:38 AM, sunny agrawal sunny816.i...@gmail.comwrote:

 Trie will take too much space..
 Balanced Binary tree can be Better ...??


 On Tue, Oct 11, 2011 at 12:16 AM, Ankur Garg ankurga...@gmail.com wrote:

 I think this can be done through tries

 Any better solution ?

 On Mon, Oct 10, 2011 at 10:59 PM, sachin goyal monugoya...@gmail.comwrote:

 remove duplicate words from a string with min. complexityy.

 --
 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
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Sunny Aggrawal
 B.Tech. V year,CSI
 Indian Institute Of Technology,Roorkee


  --
 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
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Find the later version

2011-10-10 Thread sheetal naidu
divide the string in middle and first compare the left sub-string(as they
are MSB)...if they match then compare the right sub-string (iteratively)
if the left substring doesn't match then compare iteratively by dividing
again.
i think this would give complexity in lgn.

Hope this helps!!

On 11 October 2011 08:22, bagaria.ka...@gmail.com
bagaria.ka...@gmail.comwrote:

 Given two strings describing the version of a particular software need to
 find the later version.

 For eg.
 1st string = 1.2.4.5
 2nd string=1.2.3.5

 1st string is the later one.

 Can be done using traversing the string and comparing each character one
 after the another. Looking for a better solution with lesser complexity.

 --
 Thanks and Regards

 *Karan Bagaria*
 *MCA Final Year*
 Training and Placement Representative
 *NIT Durgapur*

  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




-- 
- A.Sheetal
  B.tech, Final yr,
  Department Of Information Technology,
  NIT, Durgapur

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] remove duplicate words from a string

2011-10-10 Thread sunny agrawal
@Ankur
in Trie at each Node there will be 26 Pointers Stored, and Most of them
would be NULL, thats why i think it will waste space,

in Balanced Binary Tree i was thinking of storing the Complete Words at a
Node.

But now i think this is Better - Ternary Search
Trieshttp://en.wikipedia.org/wiki/Ternary_search_tries




-- 
Sunny Aggrawal
B.Tech. V year,CSI
Indian Institute Of Technology,Roorkee

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Find the later version

2011-10-10 Thread Dave
@Karen: It is more complicated than scanning character by character.
E.g., 1.10.3 is older than 1.9.7. I think you need to parse the
numbers between the dots and compare them one by one. Thus, in the
above example, 1 compares equal to 1, so you keep scanning. Then 10
compares greater than 9 so the first string is number of the newer
version. I did this many years ago in a csh install script for a unix
product.

Dave

On Oct 10, 9:52 pm, bagaria.ka...@gmail.com
bagaria.ka...@gmail.com wrote:
 Given two strings describing the version of a particular software need to
 find the later version.

 For eg.
 1st string = 1.2.4.5
 2nd string=1.2.3.5

 1st string is the later one.

 Can be done using traversing the string and comparing each character one
 after the another. Looking for a better solution with lesser complexity.

 --
 Thanks and Regards

 *Karan Bagaria*
 *MCA Final Year*
 Training and Placement Representative
 *NIT Durgapur*

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] subset of an array

2011-10-10 Thread abhishek sharma
yea DP will be O(given no * n) if all array entries are positive and the
given no is non negative.

On Mon, Oct 10, 2011 at 11:09 PM, anshu mishra anshumishra6...@gmail.comwrote:

 the simplest code could be for this question is

 void printAllSubsetSum(int ar[], int n, int x)
 {
 for (i = 0; i  (1n); i++)
 {
 int sum = 0;
  for (j = 0; j  n; j++)
  {
 if ( (1  j)  i) sum += ar[j];
  }
  if (sum == x)
  {
 for (j = 0; j  n; j++)
{
if ( (1  j)  i) printf(%d , ar[j]);
}
   printf(\n);
  }
 }
 }

 Time complexity O(2^n)

 this can be solved using DP in O(n * given number);

  --
 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
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Given a String with unnecessary spaces, compact it in place

2011-10-10 Thread abhishek sharma
Can in place compaction be done without left shifts?



-- 
Nice Day

Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)

-- 
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 
http://groups.google.com/group/algogeeks?hl=en.