Re: [algogeeks] Openings in Flipkart BLR

2015-09-05 Thread Amit Tiwari
Hi,
What are the minimum qualifications for APM position?

Amit Tiwari
On Sep 1, 2015 9:38 PM, "Sachin Chitale"  wrote:

> Hi folks,
>
> There are following open position in  flipkart if someone is interested do
> send your resume.
>
> 1. SDE2/SDET 2/UI2 (2+ yrs)
> 2. APM/PM/EM
> 3. Engineering Directors
> 4. Architect
> 5. Data Scientist
>
> Regards,
> Sachin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


[algogeeks] Need help on SPOJ(HASHIT)

2013-05-27 Thread Amit
Hello,
I have been trying to solve this <http://www.spoj.com/problems/HASHIT/>problem 
on SPOJ. I am getting Wrong Answer on submission, but my solution work fine 
on the sample.
Please tell me where I am wrong. Here <http://ideone.com/lMSw94> is my code.

Thanks in advance.

Amit Tiwari
BIT Mesra

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.




Re: [algogeeks] sortin 2D array

2013-01-08 Thread Amit Basak
Take a one dimensional array as the multiplication of both the dimensions
of the two dimensional array and copy the two dimensional array elements in
the one dimensional array.
After that use an efficient sorting (e.g. quick sort) on this one
dimensional array

Regards,
- Amit
---
Sent from Nexus 4
On Jan 8, 2013 11:30 PM, "Ravi Ranjan"  wrote:

> You have a two dimensional array of size m*n. The
> elements in the rows are sorted and every row has
> unique elements means( in a row no two elements are same) but
> the elements can repeat across the rows.
> For example:
> you have following 2-D array:
> 2 5 7 9 14 16
> 3 6 8 10 15 21
> 4 7 9 15 22 35
> 7 8 9 22 40 58
> You are supposed to write an efficient function which
> will take upper 2-D array as input and will return a
> one-dimensional array with following properties:
> a) the 1-D array must contain all the elements of above
> 2-D array.
> b) the 1-D array should not have any repeated elements.
> c) all the elements should be in sorted order.
> For example:
> for the above 2-D array, the output should be:
> A [ ] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16, 21, 22, 35,
> 40, 58 }
>
> --
>
>
>

-- 




Re: [algogeeks] Resources for understanding Dynamic programming

2012-11-17 Thread Amit Tiwari
Try to read 'Introduction to Algorithms' by CLRS. Also there are videos
available for that course in the MIT's Open Course-ware. The concepts are
explained very nicely. There are also some good tutorials of dynamic
programming on the topcoder. Hope it helps.

On Thu, Nov 15, 2012 at 4:01 PM, Sarath  wrote:

> Are there any good resources to understand Dynamic programming and also
> looking for some good problem and step by step solution for better
> understanding.
>
> --
> 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/-/RtXi9Nlvqa0J.
> 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: INTERFACES VS ABSTRACT

2012-08-23 Thread Amit Tiwari
With an abstract class, the subclass of that inheritance tree only can and
should provide the definitions of the methods. With an interface,
subclasses of different inheritance tree can also implement the same
methods. Interface provides a way to separate out and group common behavior
of different inheritance trees. It is kind of a substitute for the multiple
inheritance that some other languages provide.

On Thu, Aug 23, 2012 at 4:59 PM, kings  wrote:

> Dear sulekha,
>
> when u want a default property to get embedded ie u want to force any
> feature use abstract.
> when u want an additional feature need to be added used interface.
>
> ex:
> For a car the default things are steering, engine, etc... if u want the
> car to compulsory to have A/c then add it in the abstract
> for a car having ABS is optional include it as an interface where ever u
> think its necessary.
>
>
> On Tuesday, 21 August 2012 21:20:45 UTC+5:30, sulekha .m wrote:
>
>>
>> hi all,
>>   why do we separately need interfaces in java?? we can declare all
>> the methods in abstract class as abstract this serves the purpose,then why
>> do we have interfaces???
>> --
>> sulekha metta
>> B.E computer science
>> osmania university
>>
>>  --
> 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/-/qI3YhsGoh7wJ.
>
> 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] Microsoft first round interview question.

2012-08-02 Thread Amit Basak
Does each node in the list have three pointers?
What do you mean by straight doubly link list?


Thanks,
Amit





On Wed, Aug 1, 2012 at 7:25 PM, sahil gupta  wrote:

> There is doubly link list and each node is having another pointer which is
> points to another doubly link list or points to null.
> You need make it straight doubly link list.
> Provide the efficient code.
>
> Sahil Gupta
>
> --
> 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] directi paper pattern

2012-07-31 Thread amit singh
 hi shaukat Ali ,it will be really kind if you can forward me that paper of 
directi 
my ID:amitsingh...@gmail.com

On Tuesday, 31 July 2012 21:42:43 UTC+5:30, md shaukat ali wrote:
>
>
>
> On Tue, Jul 31, 2012 at 7:37 PM, deepikaanand wrote:
>
>> can anyone tell me the pattern (selection procedure )followed by directi 
>> this year  
>>
>> -- 
>> 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/-/uaKshpROlGoJ.
>> 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.
>>
> i have mailed u recently asked question by direct i in nit allahabad..make 
> a view on it
>
>

-- 
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/-/e2nPukFWEpQJ.
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] adobe aptitude test

2012-07-26 Thread Amit Jain
I assumed, You were called for Interview off-campus.

It depends upon the profile You have been called for. BTW it was too easy
for White box testing.


On Wed, Jul 25, 2012 at 8:13 PM, deepikaanand wrote:

> can anybody tell me which topics are asked in adobe apti test...and what
> is the usual level of qs asked in aptitude test...
>
> --
> 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/-/hdqti4gC8igJ.
> 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] Re: Question asked in Amazon online test

2012-07-24 Thread Amit
Let's define a term "RANDOMNESS" of array as...
summation of position of each 1's
for eg
RANDOMNESS for 
(0,0,1,0,1,0,1,1)
will be
23
now calculate max possible RANDOMNESS for the given array (each 1 on max 
possible right position)
here it will be 26

so ans will be-->
MAX RANDOMNESS of given array - RANDOMNESS of given array

On Saturday, June 23, 2012 11:34:55 AM UTC+5:30, zerocool142 wrote:
>
> Given an array containing sequence of bits (0 or 1), you have to sort 
> this array in the ascending order i.e. all 0' in first part of array 
> followed by all 1's.   The constraints is that you can swap only the 
> adjacent elements in the array. Find the minimum number of swaps 
> required to sort the given input array. 
>
> Example:   Given the array (0,0,1,0,1,0,1,1) the minimum number of swaps 
> is 3. 
>

-- 
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/-/rugRBg0Q0-kJ.
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: How to get First D digits of a pow(N,N)

2012-07-20 Thread Amit Jain
Any thought?

On Tue, May 15, 2012 at 11:46 AM, Amit Jain  wrote:

> Hi All
>
> How can we get first D digits of N to the power N ?
>
> P.S. N is of order 10^18 (^ : Power) and D <= N
>
> Thanks
> Amit Jain
>
>
>

-- 
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] Crawler/perl/php/database help

2012-07-20 Thread Amit Jain
Hi

Is your crawler script in python or shell script?


Thanks
Amit Jain

On Fri, Jul 20, 2012 at 6:02 AM, Nandita Raman wrote:

> Hello,
>
> I am working on a unix machine. and i have the crawler script with me. The
> task i need to do is, update my database (by creating a new field) with the
> files that my crawler finds from a directory.
>
> I am working on PHP , but any help ASAP to make this work/happen, would be
> appreciated!
>
> Thanks!
>
> --
>
> Regard
> Nandita
>
>  --
> 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] Re: Directi Interview Ques

2012-07-17 Thread Amit Jain
Please see *stable merge *in question.

On Sun, Jul 15, 2012 at 2:04 AM, sengar.mahi  wrote:

> @naveen : 3*7+2*9+1*3 =42 is not maximum..
> sum of the product would me maximum wen, i guess, most weighted elements
> are adjacent
> like in this case
> if c={1,2,3,3,7,9}
> 1*2 + 3*3 + 7*9=74 (maximum )
>
> thus this question is just merging both strings such resultant (here C) is
> in sorted order which can be easily done in nlogn .
>
>
> On Sat, Jul 14, 2012 at 2:15 PM, Navin Gupta wrote:
>
>> As the final array contains element in stable-order, at any time we have
>> 3 options for choosing the elements from A & B.
>> 1- A[i] & A[i+1]
>> 2- A[i] & B[I]
>> 3- B[i] & B[i+1]
>> we will choose that pair whose product is maximum.
>> For ex:-
>> A-2,1,3
>> B-3,7,9
>> C- 3,7,2,9,1,3
>> Its a linear time solution with constant time complexity.
>> Algo :-
>> 1 - Keep two indexes i=0 and j=0 pointing to arrays A & B respectively
>> and k=0 for array C.
>> 2 - Now , check the maximum of (a[i]*a[i+1], a[i]*b[j], b[j]*b[j+1] ).
>> 3 - If  a[i]*a[i+1] is maximum,  add a[i],a[i+1] to C, i+=2.
>> 4 - If  a[i]*b[j] is maximum,  add a[i],b[j] to C, i++,j++.
>> 5 - If  b[j]*b[j+1] is maximum,  add b[j],b[j+1] to C, j+=2.
>> 6 - k+=2.
>> 7 - If i,j reached end, then break else Goto step 2.
>> Time Complexity :- O(n)
>> Space Complexity :- O(1)
>>
>>  --
>> 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/-/6-JIwC7l-hYJ.
>>
>> 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*
> Mahendra Pratap Singh Sengar
> B-tech 4/4
> NIT Warangal.
>
> Facebook ID 
>
>  --
> 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] Re: Directi Interview Ques

2012-07-17 Thread Amit Jain
Awesomely done :) +1

On Mon, Jul 16, 2012 at 2:15 AM, Anshu Mishra wrote:

> two arrays are suppose x[n], y[n];
>
> take a function
> f( x(i, n), y(j, n) , 0) --> taking x[i] as a first element of merged
> array then max sum;
> f( x(i, n), y(j, n), 1)  --> taking y[j] as a first element of
> merged array then max sum;
>
>
> f( x(i, n), y(j, n) ,0) = max(  { x[i] * x[i+1] +  f( x(i+1, n), y(j, n),
> 0)  }, { x[i] * y[j] +  f( x(i+1, n), y(j, n), 1 ) } );
> f( x(i, n), y(j, n) ,1) = max(  { x[i] * y[j] +  f( x(i, n), y(j+1, n), 0)
>  }, { y[j] * y[j+1] +  f( x(i, n), y(j+1, n), 1 ) } );
>
> final sol = max (  f( x(0, n), y(0, n) ,0), f( x(0, n), y(0, n) ,1) );
>
> Now it's looking a very simple *dp *problem with O(n^2) time and space
> complexity. :)
>
> --
> Anshuman Mishra | Software Development Engineer | Amazon
>
>
>  --
> 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] Re: microsoft

2012-07-16 Thread Amit Jain
No It will not.

For negative number, it will fail.

On Sun, Jul 15, 2012 at 11:45 PM, Tanuj Makkar
wrote:

> double round(double num)
> { return (int)(num+0.5)
> }
> will it work all the time?
> ..
> didnt get itcan anyone explain it.thnx in advance.
>
> On Friday, 26 August 2011 21:58:05 UTC+5:30, rahul sharma wrote:
>>
>> hi guys...microsoft is coming to our campus..plz nyone tell their
>> recruitment procedure..n give me their previous xams question if nyone
>> has...but please tell me their selection procedure n
>> roundscuming after 2 days.plz reply soon.n tell me the
>> subjects to crack microsoft.nyon having info reply fast
>> plz..
>
>  --
> 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/-/mWeduVanassJ.
> 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] A Coding Problem

2012-07-16 Thread Amit Jain
+1

On Sat, Jul 14, 2012 at 8:14 PM, saurabh singh  wrote:

> its from a running contest i believe.This is against the group policy as
> well as against the ethics of programmers. The author of this post is
> banned permanently from algogeeks. Kindly no more posts on this thread till
> 16th July (the date mentioned as end of contest in the given link).
> Saurabh Singh
> B.Tech (Computer Science)
> MNNIT
> blog:geekinessthecoolway.blogspot.com
>
>
>
> On Sat, Jul 14, 2012 at 2:36 PM, Gobind Kumar Hembram <
> gobind@gmail.com> wrote:
>
>>
>> Please visit this 
>> link.And
>> help me in  solving this.
>> --
>> Thanks & Regards
>> Gobind Kumar Hembram
>> Contact no.-+91867450
>>
>>
>>  --
>> 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] Finding intersection of 2 linked lists

2012-07-04 Thread Amit Chauhan
If both the linked list are ordered one then you can solve this problem in
linear time and with constant space.



On Wed, Jul 4, 2012 at 10:41 PM, Abhi  wrote:

> Any efficient algorithm to find intersection of two linked lists.Example:
> Linked List 1)  1 -> 2 -> 3 -> 4 -> 5 -> 6
> Linked List 2)  3 -> 4 -> 5
>
> Intersection 4 -> 5 -> 6
>
> --
> 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/-/-8_lnGA-ZhgJ.
> 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] Abridged summary of algogeeks@googlegroups.com - 10 Messages in 8 Topics

2012-06-25 Thread amit singh
sourabh singh, i think problem in your code may arise due to term (m/a
-n/a) ,instead it should be m/a -(n-1)/a .
there may be some other problem  also .but this can be one of them

On Mon, Jun 25, 2012 at 5:10 PM,   wrote:
>   Today's Topic Summary
>
> Group: http://groups.google.com/group/algogeeks/topics
>
> Is max distance between two leaves(diameter) in a tree is equal to max
> distance between any two node in that tree?? [1 Update]
> Adobe interview question [1 Update]
> 4Sum [1 Update]
> spoj problem EASYMATH [3 Updates]
> Find the Max from each sub-array of size k [1 Update]
> Lucky Draw - longest increasing sub sequence in a circular arrangement [1
> Update]
> Reverse Queue [1 Update]
> Find peak element in log(n) [1 Update]
>
>  Is max distance between two leaves(diameter) in a tree is equal to max
> distance between any two node in that tree??
>
> atul anand  Jun 25 12:48PM +0530
>
> consider a case where tree is right skewed or left skewed , in dat case max
> distance b/w two node found are root and leftmost or rightmost node(left
> or right skewed) . so its not alwayzz true
>
> ...more
>
>  Adobe interview question
>
> himanshu kansal  Jun 25 09:12AM +0530
>
> @rahul: the ques itself says that we have to implement abstract
> class*without
> * using pure virtual function...
>
>
> --
>
> Regards
> Himanshu Kansal
> Msc Comp. sc.
> (University of Delhi)
> ...more
>
>  4Sum
>
> shady  Jun 25 12:42AM +0530
>
> @hemesh, amol = correct solutions
>
> ABCDEF another problem on SPOJ, incase people want to try.
>
> ...more
>
>  spoj problem EASYMATH
>
> Sourabh Singh  Jun 24 07:40AM -0700
>
> 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 prime's i
> guess. ...more
>
> Hassan Monfared  Jun 24 07:29PM +0430
>
> use " return (a/gcd(a,b)*b instead "
>
> ...more
>
> shady  Jun 25 12:35AM +0530
>
> dont post codes, ask whether your algorithm is correct or not.
>
> ...more
>
>  Find the Max from each sub-array of size k
>
> rajesh pandey  Jun 24 05:10PM +0530
>
> can find one more solution in my blog
> http://pandey123.wordpress.com/
>
> check it... and tell me if you have any doubt...
>
> ...more
>
>  Lucky Draw - longest increasing sub sequence in a circular arrangement
>
> sachin goyal  Jun 24 05:42AM -0700
>
> http://www.codechef.com/problems/D2/
>
> Please suggest some good algorithm for this problem
> ...more
>
>  Reverse Queue
>
> deepikaanand  Jun 24 08:53AM -0700
>
> code:-
> http://ideone.com/yMQSK
> ...more
>
>  Find peak element in log(n)
>
> Anshul Agarwal  Jun 24 07:11PM +0530
>
> can any one expain for 2-D??
>
>
> ...more
>
> You received this message because you are subscribed to the Google Group
> algogeeks.
> You can post via email.
> To unsubscribe from this group, send an empty message.
> For more options, visit this group.
>
> --
> 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] Need Valuable suggestions

2012-06-11 Thread amit kumar
Sandeep, I guess its easy in your case. As you said, one of the profile is
for testing and the other profile is for development. So, the decision to
be taken here is that you want to do testing or development. This decision
is going to affect you career path more than joining Juniper or Tally.

Regards,
Amit.
On Jun 11, 2012 2:11 PM, "SANDEEP CHUGH"  wrote:

> Guys please tell ur suggestions.. I really need that !!
>
> Thnks in advance !!
>
> On Mon, Jun 11, 2012 at 11:58 AM, SANDEEP CHUGH 
> wrote:
>
>> @Manjay   Tally came to Our campus for recruitment...
>>
>>
>> On Mon, Jun 11, 2012 at 11:55 AM, Manjay kumar 
>> wrote:
>>
>>> can you please tell me how to apply in Telly??
>>>
>>>
>>> On Mon, Jun 11, 2012 at 11:45 AM, SANDEEP CHUGH >> > wrote:
>>>
>>>> actually i am a fresher..
>>>>
>>>> In juniper , its in testing ..
>>>>
>>>> In tally designation is sw developer at R&D..
>>>>
>>>> so thats y i am confused
>>>>
>>>> On Mon, Jun 11, 2012 at 11:43 AM, rajesh singarapu <
>>>> rajesh0...@gmail.com> wrote:
>>>>
>>>>> depends on how experienced you are,
>>>>> if you are somewhere < 5yrs exp,
>>>>> you can go to small company and excel,
>>>>> but if you are too less experienced, then it is
>>>>> wise to go for brand, it is good for future jumps/opportunities.
>>>>>
>>>>>
>>>>> Congrats && thanks
>>>>> Rajesh
>>>>>
>>>>>
>>>>> On Mon, Jun 11, 2012 at 11:39 AM, SANDEEP CHUGH <
>>>>> sandeep.aa...@gmail.com> wrote:
>>>>> > Heys guys which is better option for growth??
>>>>> >
>>>>> > Juniper networks  or Tally Solutions Pvt Ltd ?
>>>>> >
>>>>> > Please do tell ur opinion..Both paying almost same
>>>>> >
>>>>> >
>>>>> >
>>>>> > --
>>>>> > 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.
>>>>
>>>
>>>
>>>
>>> --
>>> Manjay Kumar Dasaundhi
>>> Birla Institute of technology, Mesra
>>> B.E. (Information Technology)
>>>
>>>  --
>>> 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] adarsh kumar wants to chat

2012-05-23 Thread Amit Tiwari
I have added you on gtalk.

On 5/22/12, adarsh kumar  wrote:
> ---
>
> adarsh kumar wants to stay in better touch using some of Google's coolest
> new
> products.
>
> If you already have Gmail or Google Talk, visit:
> http://mail.google.com/mail/b-838f0088c8-7ce2f0cfbf-whddt6Y3xfr109-a6qqOkRZmhu0
> You'll need to click this link to be able to chat with adarsh kumar.
>
> To get Gmail - a free email account from Google with over 7,500 megabytes of
> storage - and chat with adarsh kumar, visit:
> http://mail.google.com/mail/a-838f0088c8-7ce2f0cfbf-whddt6Y3xfr109-a6qqOkRZmhu0
>
> Gmail offers:
> - Instant messaging right inside Gmail
> - Powerful spam protection
> - Built-in search for finding your messages and a helpful way of organizing
>   emails into "conversations"
> - No pop-up ads or untargeted banners - just text ads and related
> information
>   that are relevant to the content of your messages
>
> All this, and it's yours for free. But wait, there's more! By opening a
> Gmail
> account, you also get access to Google Talk, Google's instant messaging
> service:
>
> http://www.google.com/talk/
>
> Google Talk offers:
> - Web-based chat that you can use anywhere, without a download
> - A contact list that's synchronized with your Gmail account
> - Free, high quality PC-to-PC voice calls when you download the Google Talk
>   client
>
> We're working hard to add new features and make improvements, so we might
> also
> ask for your comments and suggestions periodically. We appreciate your help
> in
> making our products even better!
>
> Thanks,
> The Google Team
>
> To learn more about Gmail and Google Talk, visit:
> http://mail.google.com/mail/help/about.html
> http://www.google.com/talk/about.html
>
> (If clicking the URLs in this message does not work, copy and paste them
> into
> the address bar of your browser).
>
> --
> 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] Re: storing URL's

2012-05-15 Thread Amit Mittal
Why hashing won;t work for millions of URL.
If you hash each URL in to a distinct 32 bit integer, you can map 2^32 URL
which is around 4 billion. it should work.

On Wed, May 16, 2012 at 10:42 AM, atul anand wrote:

> i was thinking about using TRIE or patricia tree. hashing is another but
> it wont work if URLs are in millions
> is there any better data structure ?
>
>
> On Tue, May 15, 2012 at 11:37 PM, Varun  wrote:
>
>> should be a tree based on domain in url and directory mentioned in url.
>>
>>
>> On Tuesday, 15 May 2012 21:20:55 UTC+5:30, atul007 wrote:
>>>
>>> Given a file which contain millions of URL's. which data structure would
>>> you use for storing these URL's . data structure used should store and
>>> fetch data in efficient manner.
>>
>>
>> On Tuesday, 15 May 2012 21:20:55 UTC+5:30, atul007 wrote:
>>>
>>> Given a file which contain millions of URL's. which data structure would
>>> you use for storing these URL's . data structure used should store and
>>> fetch data in efficient manner.
>>
>>  --
>> 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/-/idbhSUZ6TNIJ.
>> 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
Amit Mittal

-- 
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 get First D digits of a pow(N,N)

2012-05-15 Thread Amit Jain
Hi All

How can we get first D digits of N to the power N ?

P.S. N is of order 10^18 (^ : Power) and D <= N

Thanks
Amit Jain

-- 
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] algorithm that returns number of internal nodes in the tree

2012-05-09 Thread Amit Jain
Here is my version

Algorithm count(x)

1: if (x==nil || (left[x]== nil and right[x]==nil))
2:  return 0
3: return count(left[x]) + count(right[x]) +1

Time Complexity: O(n) where is n is total number of node in tree.

Thanks

On Wed, May 9, 2012 at 11:17 AM, Akshay Rastogi  wrote:

> you are not checking whether the current node is an internal node or not !!
>
> On Thu, May 3, 2012 at 12:47 AM, Rose  wrote:
>
>> Is this algorithm right or how shall I write it?
>>
>> *
>> *
>>
>> *
>> *
>>
>> *Construct an algorithm **Intern(**x**)**, which returns the number of
>> internal nodes in the tree. *
>>
>> * *
>>
>> Algorithm Intern(x)
>>
>>
>>
>> 1: if (x = nil) then
>>
>> 2:  return 0
>>
>> 3: else
>>
>> 4:  return 1 + Intern(left[x]) + Intern(right[x])
>>
>> 5: end if
>>
>>
>>
>>  *a   -**Give the time complexity/Running time of your solution in **
>> O**-notation. *
>>
>> --
>> Med Venlig Hilsen/Kind regards
>>
>> Rose
>>
>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> AKSHAY RASTOGI
> BE(Hons) CS
> BITS PILANI , Pilani
>
>  --
> 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] Explain the code

2012-03-20 Thread Amit Kumar
@sajal
I mean the same.



Warm Regards
Amit Kumar
Master Of Computer Applications
University Of Delhi

-- 
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] Share your comments

2012-02-10 Thread Amit Garg
I was studying the algorithm behind gold and currency that is running
for ages on Earth.
So I though I would share it with algo geeks:

http://lunaticzombie.blogspot.in/2011/12/barter-to-gold-to-currency-to-barter.html
do share your comments

-- 
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: virtual destructor problem

2011-12-08 Thread Amit Basak
@ atul anand:
Because Prem Krishna Chettri's question was for main function that was as
below:

int main() {

baseClass *aPtr = new derivedClass1();

baseClass *bPtr = new derivedClass2();
delete aPtr;
delete bPtr;
}

Here, there are two derived objects aPtr and bPtr, so the base class
destructor is called twice here.

On Thu, Dec 8, 2011 at 4:57 PM, ashok dhakar  wrote:

> class baseClass { public :   ~baseClass() { cout<< "baseClass Des
> called"<< endl; } };
> 
> int main()
> {
> baseClass *bPtr = new derivedClass2();
> delete bPtr;
> }
> This will print :"baseClass Des called"
> Reason:
> The baseClass is a simple class there is no virtual destructor for
> it,so whenever we create the object of classes derived from baseClass
> there will be memory leak for the Derived Object.
> There is no way for the compiler to interpret differently the
> destructor function..so it calls baseClass destructor functions only.
> If we make it virtual Destructor then this will be determined at run
> time through the v-table based on its object type and derived
> destructor will be executed 1st then base destructor.
>
>
> In the below case:
> /*Derived class*/
> class derivedClass1 : public baseClass {
> public:
>virtual ~derivedClass1() {cout <<"derivedClass1 Des called"<<
> endl;}
>
> };
> class derivedClassOf1 : public derivedClass1{
> public:
>virtual ~derivedClassOf1() {cout <<"derivedClassOf1 Des called"<<
> endl;}
> };
>
> Now derivedClass1  has virtual destructor so all the derived objects
> of this class will not have any memory leak provided if
> derivedClass1 *pdC1=new derivedClassOf1 ();
> delete pdC1;
> This will 1st call derivedClassOf1,then derivedClass1 and also the
> base class(remember deletion via derived pointer will make sure the
> base destructor will be called,virtual was added to solve the problem
> of memory leak while deletion from base pointers)
>
>
> baseClass *p=new derivedClassOf1 ();
> This will have memory leak as it will call only the base class
> destructor.
>
> --
> 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.
>
>


-- 
Thanks,
Amit Kumar Basak

-- 
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] virtual destructor problem

2011-12-07 Thread Amit Basak
For the main question, the base class destructor will be called and the
output of the program will be: "baseClass Des called".

This is because, when  delete bPtr; is called, the base class destructor
will be called as bPtr is of type baseClass.
And since baseClass destructor is not decalred as virtual, so the type of
the object that bPtr points to does not come into picture.
In other words, the base part of memory held by  derivedClass2 object will
only be destructed here.

@Prem Krishna Chettri's question: In this case also only the baseClass's
destructor will be called and hence we will have two lines output as
"baseClass Des called"
"baseClass Des called"

This is why it is always advisable to make the destructor as virtual.


Amit

On Wed, Dec 7, 2011 at 3:27 PM, Prem Krishna Chettri wrote:

> The Output would be only  the base class object destructor would be called
> so output :-
>
> derivedClass2 Des called
>
> Now why ..
>
>   It is no more than just a base parent concept here, so base pointer
> capable if holding its derived object address get's derived object as new
> derivedClass2() creates only derived object. However,  by deleting that
> pointer would results in destructing of this object which is the object of
> the derived class type "derivedClass2".
>
>
> Well,  I Guess what would be more interesting if you have a main something
> like this :-
>
> int main() {
>
> baseClass *aPtr = new derivedClass1();
>
> baseClass *bPtr = new derivedClass2();
>  delete aPtr;
> delete bPtr;
> }
>
>
> On Wed, Dec 7, 2011 at 2:51 PM, deepak kumar wrote:
>
>> Hi All,
>> I am sharing  with you all a problem . The problem is as follow
>>
>>
>> class baseClass {
>> public :
>>   ~baseClass() { cout<< "baseClass Des called"<< endl; }
>> };
>>
>> /*Derived class*/
>>
>> class derivedClass1 : public baseClass {
>> public:
>> *virtual *~derivedClass1() {cout <<"derivedClass1 Des called"<<
>> endl;}
>> };
>>
>> /*Derived class*/
>>
>> class derivedClass2 : public baseClass {
>> public:
>> ~derivedClass2() {cout <<"derivedClass2 Des called"<< endl;}
>> };
>>
>>
>> int main() {
>>
>> baseClass *bPtr = new derivedClass2();
>> delete bPtr;
>> }
>>
>>
>> Can anyone tell me what will be the output and why ?
>> Note: the virtual destructor in derivedClass1.
>>
>>
>> --
>> Thanks and Regards
>> Deepak 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.
>>
>
>  --
> 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] Link list Q

2011-12-01 Thread Amit Chauhan
Option (c) is correct. detects the loop in singly linked list

**


On Thu, Dec 1, 2011 at 1:42 PM, Vijay Khandar wrote:

> What does the following program do on the singly linked list?
>
> p=head;
> q=head->next;
> while(p!=null && q!null)
> {
> if(p==q)
> {
> exit(0)
> }
> p=p->next;
> q=(q->next)?(q->next->next):q->next;
> }
>
> a)traverse the entire singly linked list
> b)detects the duplicate nodes
> c)detects the loop in singly linked list
> d)detects the duplicate nodes at alternate places
>
> plz explain anyone with correct option..
>
> --
> 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] Dbms

2011-10-06 Thread amit kannaujiya
Any one having good material on functional dependency and normalization ,
which contain examples and easily explain these concepts ...
Plz post here ...

-- 
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: oracle finance questions

2011-10-03 Thread amit kannaujiya
pkg 6.6, NIT Kurukshetra

On Tue, Oct 4, 2011 at 12:54 AM, Rahul Tiwari wrote:

> colg ?  pkg ???
>
> On Oct 3, 7:36 pm, amit kannaujiya 
> wrote:
> > if any one know  regarding oracle finance online test, plz post type of
> > questions asked in online test .
>
> --
> 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] oracle finance questions

2011-10-03 Thread amit kannaujiya
if any one know  regarding oracle finance online test, plz post type of
questions asked in online test .

-- 
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] request of ebook..(Data Structures and algorithms made easy:)

2011-09-26 Thread Amit Mittal
plz send me that book too

On Mon, Sep 26, 2011 at 3:28 PM, Ishan Aggarwal <
ishan.aggarwal.1...@gmail.com> wrote:

> plz send me that book to
> I also need that book...
>
>
> On Sun, Sep 25, 2011 at 9:37 PM, sarath prasath 
> wrote:
>
>> hi every one..
>> pls do give me the link if u find or have, about this book..
>> title name:"Data Structures and Algorithms Made Easy: 700 Data
>> Structure and Algorithmic Puzzles"
>> author:"Narasimha Karumanchi"
>> ISBN-10: 145654988X
>> ISBN-13: 978-1456549886
>> publisher:careermonk..
>> pls do send to this email id..."prasathsar...@gmail.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 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.
>>
>>
>
>
> --
> Kind Regards
> Ishan Aggarwal
> [image: Aricent Group]
> Presidency Tower-A, M.G.Road,Sector-14
> Gurgaon,Haryana.122015 INDIA
> Phone : +91-9654602663
> ishan2.aggar...@aricent.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 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] Re: sqrt function...

2011-09-25 Thread Amit Mittal
double sqrt(double c)
{
if (c < 0) return error;
double err = 1e-15;
double t = c;
while (fabs(t*t - c) > err)
t = (c/t + t) / 2.0;
return t;
}

On Sun, Sep 25, 2011 at 2:57 PM, teja bala wrote:

> @vikram
>
> the one which i posted(link) it was newton raphson method which is used to
> derive the square root of a number , there are many other methods if u r
> interested visit wikipedia ,
> and coming to this method write the code and xplain to him with an
> xample...
>
> --
> 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] Re: microsoft interview

2011-09-08 Thread Amit Gupta
Guys, why don't we do something like this :

1. If (arrayHasBeenTraversed, Goto 4).
Else, Traverse the 2-D array [row,column] wise. Inspect element
array[row][column]. Goto 2.
2. If you encounter a '1' (array[row][column]),
change all the 0's in the corresponding [row,column] to '-1'
Also, don't do anything if you encounter a '1'.
3. Goto 1.
4. Scan the array, change all '-1s' to 1s. Finish.

Send your comment.

Cheers,
Amit

-- 
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: Adobe written test

2011-09-07 Thread Amit Gupta
Written test of adobe had 3 sections -
Quant and Analytical section - 45 questions(30 + 15) 45 mins
2 coding papers - 1 hr each , 10 ques each
1st coding paper had general MCQ  (test ur c skills type )
2nd coding paper had ques for writing algos, codes and few OS
questions.

-- 
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] puzzle

2011-09-04 Thread amit kannaujiya
1)  on one switch for some time .
then  , off that switch.
2) Now on a switch , and open the door.
the bulb which is on  , that is for that switch .
earlier on switch  will be for that bulb ,which is hot .
and the third switch will be for that bulb which coolest

On Sun, Sep 4, 2011 at 12:30 PM, 9ight coder <9ightco...@gmail.com> wrote:

> There is a room with a door (closed) and three light bulbs. Outside
> the room there
> are three switches, connected to the bulbs. You may manipulate the
> switches as
> you wish, but once you open the door you can't change them. Identify
> each switch
> with its bulb.
>
> --
> 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] Book Request <>

2011-09-03 Thread Amit Mittal
Rahul,
This is not the complete book, it has just two chapters. Can you provide a
link for the entire book ?


On Sat, Sep 3, 2011 at 6:28 PM, Rahul Verma wrote:

> download the book from:
> http://www.scribd.com/doc/50658450/Data-Structures-and-Algorithms-Made-Easy-For-Interviews-Programming-Interview-Questions
>
> --
> 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/-/_ps7Ei5Tf74J.
>
> 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] Book Request <>

2011-09-03 Thread Amit Mittal
Please upload this book, if anyone of you have it.



On Fri, Aug 19, 2011 at 7:59 AM, Swati Sarraf  wrote:

> Hey Navneet , which book are you talking abt- Data structure and algo made
> easy OR Data structure Puzzles ?
>
>
> 
> On Thu, Aug 18, 2011 at 10:16 PM, Navneet  wrote:
>
>> My two cents on this book -
>>
>> Too lengthy and written more like an exhaustive tutorial rather than
>> "idea" book. I purchased hard copy but sold it for didn't like it
>> much.
>>
>> On Aug 19, 2:56 am, Swati Sarraf  wrote:
>> > Hi guys,
>> >
>> > Does any one of u has the book - Data Structures and Algorithms made
>> Easy -
>> > by Narasimha Karumanchi
>> > <
>> http://www.slideshare.net/nakarumaka/data-structures-and-algorithms-m...>
>> >
>> > On Thu, Aug 18, 2011 at 4:15 PM, Sanjay Rajpal <
>> sanjayrajpal108...@gmail.com
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > wrote:
>> > > Hi friends,
>> >
>> > > Does any one of u has the book
>> > > Data Structure Puzzles: Puzzle your mind for Data Structures
>> > > <
>> http://www.amazon.com/Data-Structure-Puzzles-Puzzle-Structures/dp/146..
>> .>by
>> > > Narasimha Karumanchi ?
>> >
>> > > Plz mail this book to me or post the link as soon as possible..
>> >
>> > >  --
>> > > 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,
>> > Swati Sarraf
>>
>> --
>> 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,
> Swati Sarraf
>
> --
> 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] Re: Find the Max from each sub-array of size k

2011-09-02 Thread amit chandel
we can do it using max heap

-- 
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: reverse

2011-08-25 Thread amit kannaujiya
On Thu, Aug 25, 2011 at 7:58 PM, amit kannaujiya <
amitkannaujiyan...@gmail.com> wrote:

> int reverse(int n)
> {
>int i=9*( abs(n/10 - n%10) );
>i=i+n;
>return i;
> }
>
> On Wed, Aug 24, 2011 at 9:56 PM, Dave  wrote:
>
>> @Anika: So you want to reverse the digits of the decimal
>> representation of a number. Extracting decimal digits requires
>> division and modulus by 10. Normally this is done by division, but as
>> a different recent thread has shown, division can be accomplished by
>> bit operations, comparisons, and subtraction.
>>
>> This is the kind of computation you should go through to reverse the
>> decimal digits of a number...
>>
>> int reverse( int n );
>> {
>>int i = 0;
>>while( n )
>>{
>>i = i * 10 + n % 10;
>>n /= 10;
>>}
>>return i;
>> }
>>
>> Now, if you want, you can dig though the other postings for the
>> division algorithm. A simple modification of that algorithm can return
>> the modulus (remainder) instead of or in addition to the quotient.
>> Multiplication by 10 can be done with bit operations as i << 3 + i <<
>> 1.
>>
>> Dave
>>
>> On Aug 11, 12:57 pm, Anika Jain  wrote:
>> > reverse of a no. means.. reverse of 39 is 93..
>> > but i dont get it how can we reverse a no. by bitwise operator...
>> >
>> >
>> >
>> > On Thu, Aug 11, 2011 at 11:11 PM, manvir siyo 
>> wrote:
>> > > please tell me abt the pattern of de shaw company..
>> > > please
>> >
>> > > On Thu, Aug 11, 2011 at 11:06 PM, paul suganthan <
>> paul.sugant...@gmail.com
>> > > > wrote:
>> >
>> > >> You are trying to reverse the bits. not the number.
>> > >> This will not work for bits also!
>> >
>> > >> If given input is 1101 0011
>> > >> you will get
>> > >> 0010 1100
>> >
>> > >> On Thu, Aug 11, 2011 at 11:01 PM, Naren s 
>> wrote:
>> >
>> > >>> not 100% sure if this is what you are asking for but here it goes.
>> >
>> > >>> you have a number  (binary) and you want  (binary)?
>> >
>> > >>> you want to use the xor operator ^
>> >
>> > >>> value = 0xf0; // binary
>> > >>> printf("before %d\n");
>> > >>> value ^= 0xff; // binary
>> > >>> printf("after%d\n");
>> >
>> > >>> output:
>> > >>> before 240
>> > >>> after 15
>> >
>> > >>> 240 in binary is 
>> > >>> 15 in binary is 
>> >
>> > >>> <
>> http://wiki.answers.com/Q/How_do_you_reverse_a_number_using_bitwise_o...>
>> >
>> > >>> On Thu, Aug 11, 2011 at 10:43 PM, Rajeshwar Patra <
>> > >>> rajeshwarpa...@gmail.com> wrote:
>> >
>> > >>>> how can we reverse a number using bitwise operators?
>> >
>> > >>>> --
>> > >>>> *Rajeshwar Patra,*
>> > >>>> *MCA final year,*
>> > >>>> *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.
>> >
>> > >>> --
>> > >>> *Narayanan S,*
>> > >>> B.E., C.S.E., (final year),
>> > >>> College Of Engineering Guindy,
>> > >>> Anna University,
>> > >>> Chennai-25.
>> >
>> > >>>  --
>> > >>> 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.
>> 

Re: [algogeeks] Re: reverse

2011-08-25 Thread amit kannaujiya
int reverse(int n)
{
   int i=9*( abs(n/10 - n%10) );
   return i;
}

On Wed, Aug 24, 2011 at 9:56 PM, Dave  wrote:

> @Anika: So you want to reverse the digits of the decimal
> representation of a number. Extracting decimal digits requires
> division and modulus by 10. Normally this is done by division, but as
> a different recent thread has shown, division can be accomplished by
> bit operations, comparisons, and subtraction.
>
> This is the kind of computation you should go through to reverse the
> decimal digits of a number...
>
> int reverse( int n );
> {
>int i = 0;
>while( n )
>{
>i = i * 10 + n % 10;
>n /= 10;
>}
>return i;
> }
>
> Now, if you want, you can dig though the other postings for the
> division algorithm. A simple modification of that algorithm can return
> the modulus (remainder) instead of or in addition to the quotient.
> Multiplication by 10 can be done with bit operations as i << 3 + i <<
> 1.
>
> Dave
>
> On Aug 11, 12:57 pm, Anika Jain  wrote:
> > reverse of a no. means.. reverse of 39 is 93..
> > but i dont get it how can we reverse a no. by bitwise operator...
> >
> >
> >
> > On Thu, Aug 11, 2011 at 11:11 PM, manvir siyo 
> wrote:
> > > please tell me abt the pattern of de shaw company..
> > > please
> >
> > > On Thu, Aug 11, 2011 at 11:06 PM, paul suganthan <
> paul.sugant...@gmail.com
> > > > wrote:
> >
> > >> You are trying to reverse the bits. not the number.
> > >> This will not work for bits also!
> >
> > >> If given input is 1101 0011
> > >> you will get
> > >> 0010 1100
> >
> > >> On Thu, Aug 11, 2011 at 11:01 PM, Naren s 
> wrote:
> >
> > >>> not 100% sure if this is what you are asking for but here it goes.
> >
> > >>> you have a number  (binary) and you want  (binary)?
> >
> > >>> you want to use the xor operator ^
> >
> > >>> value = 0xf0; // binary
> > >>> printf("before %d\n");
> > >>> value ^= 0xff; // binary
> > >>> printf("after%d\n");
> >
> > >>> output:
> > >>> before 240
> > >>> after 15
> >
> > >>> 240 in binary is 
> > >>> 15 in binary is 
> >
> > >>> <
> http://wiki.answers.com/Q/How_do_you_reverse_a_number_using_bitwise_o...>
> >
> > >>> On Thu, Aug 11, 2011 at 10:43 PM, Rajeshwar Patra <
> > >>> rajeshwarpa...@gmail.com> wrote:
> >
> >  how can we reverse a number using bitwise operators?
> >
> >  --
> >  *Rajeshwar Patra,*
> >  *MCA final year,*
> >  *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.
> >
> > >>> --
> > >>> *Narayanan S,*
> > >>> B.E., C.S.E., (final year),
> > >>> College Of Engineering Guindy,
> > >>> Anna University,
> > >>> Chennai-25.
> >
> > >>>  --
> > >>> 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.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> 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] Accessing private members of Derived class ?

2011-08-22 Thread Amit Mittal
This might help

http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr130.htm
\



On Mon, Aug 22, 2011 at 11:40 AM, Sanjay Rajpal  wrote:

> Here concept of v-tables comes into picture. Refer to C++ Primer Plus by
> Stephen Prata.
>
>
> Sanju
> :)
>
>
>
> On Sun, Aug 21, 2011 at 11:05 PM, JAIDEV YADAV  wrote:
>
>> because Access control check is done at compile time while using virtual
>> make fun not available to the base class pointer till runtime ... so no
>> access check to derived class ... hope u understand and correct me to if
>> there is any mistake ...
>>
>>
>> On Mon, Aug 22, 2011 at 10:57 AM, Decipher wrote:
>>
>>> class Base
>>> {
>>> public :
>>>   virtual void show()
>>>   {
>>>   cout<<"\n Base ";
>>>   }
>>>
>>> };
>>> class Derived : public Base
>>> {
>>>   private :
>>> void show()
>>> {
>>>  cout<<"\n Derived ";
>>> }
>>> };
>>> int main()
>>> {
>>> Base *d = new Derived();
>>> d->show();
>>> getch();
>>> }
>>>
>>> Why Derived::show is called even though it is private ? (Ran this code on
>>> Dev - C++)
>>>
>>> --
>>> 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/-/MKvMpI_KOLUJ.
>>> 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.
>>>
>>
>>
>>
>> --
>> JaiDev Yadav
>> (National Yoga Champion)
>> Computer Engg. Dept.
>> National Institute of Technology
>> Kurukshetra,Haryana
>>
>> --
>> 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] Re: Trees

2011-08-11 Thread amit karmakar
* correction
(5*5(There are 5*5 nodes in level 2)-4(These became internal nodes..))

On Aug 11, 9:58 pm, amit karmakar  wrote:
> 5 is possible.
> Considering root of the tree to be at level 0,
> level 1 and level 2 are completely filled.
>
> There are 5 internal nodes in level 1, (since all level 2 nodes are
> present)
> Now only (10 - 5(from level 1)+1(the root)) nodes are required.
> So choose 4 nodes from level 2 and make them interior node.
> So you get 4*5(4 nodes have 5 children) + (5*5(There are 5*5 nodes in
> level 2)-4(These became leaves)) leaves.
>
> Unfortunately 5 is not in the option
>
> On Aug 11, 7:31 pm, rShetty  wrote:
>
>
>
> >  A complete n- array tree in which each node has n children or no
> > children, let i be the number of internal nodes and L be the number of
> > leaves in a complete n- array tree. If L=41 and i=10 what is the value
> > of n.
>
> > a. 3    b. 6   c. 4
>
> > How to solve such problems??

-- 
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: Trees

2011-08-11 Thread amit karmakar
I tried solving this problem and came to conclusion that none of the
options can be correct. Indeed for value 5, you can have a solution.
Then i googled for this question, and found out that, you have an
option missing. i.e 5 :|

On Aug 11, 9:01 pm, rajeev bharshetty  wrote:
> @all : Could anyone explain it using the tree diagram . @nithin : 4 may not
> be th answer i am not able to plot into a tree satisfying those constarints
>
> On Thu, Aug 11, 2011 at 9:16 PM, Nitin Nizhawan 
> wrote:
>
>
>
>
>
> > i guess answer is c. 4
>
> > n*i+1
>
> > On Thu, Aug 11, 2011 at 8:01 PM, rShetty  wrote:
>
> >>  A complete n- array tree in which each node has n children or no
> >> children, let i be the number of internal nodes and L be the number of
> >> leaves in a complete n- array tree. If L=41 and i=10 what is the value
> >> of n.
>
> >> a. 3    b. 6   c. 4
>
> >> How to solve such problems??
>
> >> --
> >> 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
> Rajeev N B 
>
> "*Winners Don't do Different things , they do things Differently"*

-- 
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: Trees

2011-08-11 Thread amit karmakar
5 is possible.
Considering root of the tree to be at level 0,
level 1 and level 2 are completely filled.

There are 5 internal nodes in level 1, (since all level 2 nodes are
present)
Now only (10 - 5(from level 1)+1(the root)) nodes are required.
So choose 4 nodes from level 2 and make them interior node.
So you get 4*5(4 nodes have 5 children) + (5*5(There are 5*5 nodes in
level 2)-4(These became leaves)) leaves.

Unfortunately 5 is not in the option

On Aug 11, 7:31 pm, rShetty  wrote:
>  A complete n- array tree in which each node has n children or no
> children, let i be the number of internal nodes and L be the number of
> leaves in a complete n- array tree. If L=41 and i=10 what is the value
> of n.
>
> a. 3    b. 6   c. 4
>
> How to solve such problems??

-- 
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: ~ operator

2011-08-10 Thread amit karmakar
calculate 0101+1001+1 as 
Now if the signed numbers are represented using 2's complement system
then  is the representation for -1


On Aug 10, 7:23 pm, Ayswarya Srinivasan  wrote:
> can someone explain how this works-
> *
> *
> *void* *main*(){
>     *int* a,b,d;
>     scanf("%d%d",&a,&b);
>     d=a+~b+1;
>     printf("%d",d);
>     getch();
>
> }
>
> say if a=5 b=6 then
> output is -1
>
> if ~ is one's complement operator
> then
> a=0101
> ~b=1001
>
> d= 0101+1001+1. which is not -1
>
> can someone explain how it works.
>
> --
>
> Regards,
> Ayswarya 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.



[algogeeks] Re: pre-post decrement

2011-08-08 Thread amit karmakar
>> z=(--i)--;
It works fine only with a c++ compiler not C.
preincrement operator -- doesn't yield a lvalue in case of C.

will have different
On Aug 8, 11:01 pm, raj kumar  wrote:
> @jagrati
> so why it works fine
> z=(--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.



[algogeeks] Re: nlogn, in-place, iterative mergesort?

2011-08-07 Thread amit karmakar
@DK
Hmm, i do understand what you said. Maybe, i should make it clear that
i just wanted to tell that implementing a non-recursive merge-sort
will not require explicit stacks and is actually easier to implement.
This was because someone mentioned using stacks to remove recursion. I
didn't mean to tell anything more than that. :)

On Aug 7, 3:07 pm, DK  wrote:
> @Amit and @Immanuel: You're not getting the point. Merge sort is not
> in-place because it requires an extra O(N) array during the merge step.
> The problem asks not to remove the recursive nature of the merge-sort but to
> remove the non-in-place nature of merge sort by removing the need for that
> extra array. This is a research problem that has been solved and there have
> been multiple papers on the topic. I've posted the earliest one that forms
> the basis of this field.
>
> --
> DK
>
> http://gplus.to/divyekapoorhttp://twitter.com/divyekapoorhttp://www.divye.in

-- 
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: nlogn, in-place, iterative mergesort?

2011-08-07 Thread amit karmakar
The best thing is that you don't need explicit stacks for removing
recursion. A couple of loops can do the job.

On Aug 6, 9:57 pm, immanuel kingston 
wrote:
> Yes. just remove the recursive part using 2 stacks.
>
> Thanks,
> Immanuel
>
> On Fri, Aug 5, 2011 at 6:51 PM, Nitin Nizhawan 
> wrote:
>
>
>
> >  does anyone know of any in-place, iterative mergesort algorithm with nlogN
> > worst case complexity? It would be good if it is stable also.
>
> > TIA
> > Nitin
>
> > --
> > 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] Re: Sum from array

2011-08-07 Thread amit karmakar
It can be reduced to subset sum problem. So I cannot see O(n) being
possible here. Even the dynamic programming approach(provided there
are some more constraints for this problem) is O(n*m) where m is
related to the range of values of sum.

On Aug 7, 2:10 pm, swetha rahul  wrote:
> Given an array find all the set which form the given sum  in O(n)
>
> i/p: a[]={1,2,3,5,7,6,8,10}
> sum=9
>
> o/p should be {1,3,5} {2,7} {3,6},{1,8}

-- 
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: SPOJ ABCD

2011-08-07 Thread amit karmakar
@amol
I got accepted using the similar approach. But i performed
backtracking. In each step of backtracking i chose the next option as
you done. So, there can be cases where this approach fails.

Runtime error may occur because,

>> while(count[k-'A'].second>=n||count[k-'A'].first==up[i]||count[k-'A'].first 
>> ==down[i-1])
>>   k++;
The above code segment assumes that you will get one of the ABCD to
fill the position. But in cases where none of these are possible you
will end up with out of bounds error.

On Aug 7, 1:23 am, Amol Sharma  wrote:
> i attempted a problem
>  http://www.spoj.pl/problems/ABCD/
>
> my logic is scan the input string and record the count of A, B, C, D in
> array of size 4
>
> now sort the count array
>
> in the output array at first position put an element from count array
> whose count is less than n and not equal to element above them...
>
> then for other positions put element from the count array whose count is
> less(minimum) than n and they are not equal to previous element and element
> above them...
>
> it is working fine for most of the cases but i was able to figure out the
> cases where it failed
>
> input -   BCDBCD
> output - ABACAH   which is wrong it should be ABADAC or ADACAB.
>
> i am getting a run time error on submission
>
> Please help me in correcting my logic to reach to the correct solution.
> My Code is as follows
>
> -
>
> #include
> #include
> #include
> #include
> #include
>
> using namespace std;
>
> //problem four colours ABCD
>
> bool myfunc(pair i,pair j)
> {
> return (i.second < j.second);
>
> }
>
> int main()
> {
>     int n;
>     scanf("%d",&n);
>     //now up and down array should have 2n colours and each colour should be
> present n times
>         vector< pair > count(4);
>
>         //count array will store the frequency of each colour
>         int i,j;
>         char k,down[10];
>         string up;
>         count[0].first='A';
>         count[1].first='B';
>         count[2].first='C';
>         count[3].first='D';
>         count[0].second=count[1].second=count[2].second=count[3].second=0;
>         cin >> up;
>         //string up is scanned
>         //get the count of each colour in up string
>         for(i=0;i<2*n;i++)
>         {
>             count[up[i]-'A'].second+=1;
>         }
>      /*   for(j=0;j<4;j++)
>                      printf("%c\t%d\t",count[j].first,count[j].second);
>         printf("\n");*/
>         //now scan the above string and construct the down string together
>         for(i=0;i<2*n;i++)
>         {
>             sort(count.begin(),count.end(),myfunc);
>             /*for(j=0;j<4;j++)
>                      printf("%c\t%d\t",count[j].first,count[j].second);
>             printf("\n");*/
>             if(i==0)
>             {
>                 //this is the case when we have first element to fill
>                 k='A';
>                 while(count[k-'A'].second>=n||count[k-'A'].first==up[i])
>                     k++;
>                 down[i]=count[k-'A'].first;
>                 count[k-'A'].second+=1;
>             }
>             else
>             {
>                 k='A';
>
> while(count[k-'A'].second>=n||count[k-'A'].first==up[i]||count[k-'A'].first 
> ==down[i-1])
>                     k++;
>                 down[i]=count[k-'A'].first;
>                 count[k-'A'].second+=1;
>             }
>             /*printf("Hi\n");
>             for(j=0;j<4;j++)
>                      printf("%c\t%d\t",count[j].first,count[j].second);
>             printf("\n");*/
>         }
>        down[2*n]='\0';
>         cout<     //system("pause");
> return 0;
>
> }
>
> --
>
> Amol Sharma
> Third Year Student
> Computer Science and Engineering
> MNNIT Allahabad

-- 
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: n-ary tree

2011-08-06 Thread Amit
u can do that
struct TreeNode
{
 list listOfchildNodes; or vector von or ur
own list
 int data;
};

Amit

On Aug 6, 5:18 pm, Aman Goyal  wrote:
> thanks, by no means we can add the child nodes dynamically to the father
> node??
>
>
>
>
>
>
>
> On Sat, Aug 6, 2011 at 5:33 PM, rohit  wrote:
> > use a linked list to store child nodes, a tree node will hold pointer
> > to next sibling and a pointer to its first child.
> > typedef struct TreeNode{
> > struct TreeNode * nextSibling;
> > struct TreeNode * fistChild;
> > //rest things
> > }
>
> > On Aug 6, 4:10 pm, Aman Goyal  wrote:
> > > Can anyone suggests a good data structure for n-ary tree.. where n is the
> > > input by the user...
>
> > --
> > 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] Re: Global Scholar

2011-08-06 Thread amit karmakar
I only know about the telephonic interview round which was of around
30 minutes.
They asked three algorithmic problems,
1. For a given binary tree where each node has a integer value
associated with it. Write a program that takes k as input and prints
the sum of all nodes after level k.
2. Algorithm/program for rotating a string k times.
3. Some problem related to Josephus problem

Then they asked some basic questions on C/C++

On Aug 6, 1:48 pm, vicky S  wrote:
> Any one know how the global scholar written round will be ? whether they
> concentrate on OOPs language lik C++ Java or c aptitudes itself enough ? how
> wil be the next techinical  rounds ?
> Thanks in adcance :)

-- 
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: Longest matching substring

2011-08-06 Thread amit karmakar
I think there is some error in this implementation,

On Aug 6, 1:54 pm, Mukul Gupta  wrote:
> Yes, vikash is right. This will work. Works in O(nm).
>
> http://ideone.com/G6RAK
>
>
>
>
>
>
>
> On Sat, Aug 6, 2011 at 1:30 PM, vikash  wrote:
> > apply longest common subsequqnce problem with a little modification.
> > that would solve your problem.
>
> > On Aug 6, 12:54 pm, swetha rahul  wrote:
> > > Hi,
> > >              How to find the longest matching substring in 2 arrays..
>
> > > Say we have 2 strings,
> > > str1="abcdefghi" and str2="iabcdefgk" the answer must be "abcdefg"
>
> > --
> > 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] Re: Longest matching substring

2011-08-06 Thread amit karmakar
For other algorithms have a look here,
http://en.wikipedia.org/wiki/Longest_common_substring_problem

On Aug 6, 1:55 pm, payel roy  wrote:
> Trie ..
>
> On 6 August 2011 14:24, Mukul Gupta  wrote:
>
>
>
>
>
>
>
> > Yes, vikash is right. This will work. Works in O(nm).
>
> >http://ideone.com/G6RAK
>
> > On Sat, Aug 6, 2011 at 1:30 PM, vikash  wrote:
>
> >> apply longest common subsequqnce problem with a little modification.
> >> that would solve your problem.
>
> >> On Aug 6, 12:54 pm, swetha rahul  wrote:
> >> > Hi,
> >> >              How to find the longest matching substring in 2 arrays..
>
> >> > Say we have 2 strings,
> >> > str1="abcdefghi" and str2="iabcdefgk" the answer must be "abcdefg"
>
> >> --
> >> 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] Samsung SISO Question

2011-08-05 Thread amit kumar
can u plz xplain d qstn a litl more
thanx

On Fri, Aug 5, 2011 at 8:33 PM, bagaria.ka...@gmail.com <
bagaria.ka...@gmail.com> wrote:

> Given a rope of 10m , numbered at 1m i.e like
> 0  1  2  3  4  5  6  7  8  9  10
> ||---|---|---|---|---|---|---|---|---|
> |---10m|
>
> One dry out it clothes of various length like 4m from 0-4 then of 2m from
> 6-8 then 6m from 2-8 and so on ,one on top of another , then u need to
> construct a data structure such that
> when seeing from the top u have to give the number of clothes drying , at
> one particular instance.
> --
> Thanks and Regards
>
> *Karan Bagaria*
> *MCA Final Year*
> Training and Placement Representative
>
>
>  --
> 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] Re: remove duplicate words in a string

2011-08-05 Thread amit karmakar
Using a trie data structure this can be solved in O(n).
read each character of the input string and build a trie. Maintain the
counts of all words.

Now traverse the trie again with the input string and making decisions
whether to print a string depending on the word count that you get
from the trie.

On Aug 5, 1:21 pm, vaibhav shukla  wrote:
> Given a string,remove all duplicates words:
>
> input: where there is a will there is a way
>
> o/p : where will way.
>
> --
>   best wishes!!
>     Vaibhav
>       MCA

-- 
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: Printf

2011-08-05 Thread amit karmakar
Some discussions here,
http://ubuntuforums.org/showthread.php?t=316081
and some here,
http://groups.google.com/group/comp.lang.c/msg/21250e8fe083e4f8

On Aug 5, 12:51 pm, Anurag Narain  wrote:
> i think logical address...physical address is never accessible to user
> program
>
> @amit-can u explain why??

-- 
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: Printf

2011-08-05 Thread amit karmakar
Invokes undefined behavior.!

On Aug 5, 12:47 pm, Aman Goyal  wrote:
> physical address i suppose...
>
>
>
> On Fri, Aug 5, 2011 at 1:09 PM, anurag  wrote:
> > What will be the output.
>
> > int i=5;
> > printf("%u",&i);
> > What it will print:
> > i. 5
> > ii. Base address of the memory
> > iii. Physical address
> > iv. Logical address
>
> > --
> > 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] Re: C++ doubt

2011-08-04 Thread Amit
static_cast<> does not do run time type checking. That's why base
class  pointer can be changed to drived class though it actually is a
base class pointer. Now its a drived class pointer, you can call
drived class functions. If you use dynamic_cast<> instead of
static_cast<>, it will throw a bad cast exception, because
dynamic_cast<> does runtime type checking.

 Regards,
 Amit

-- 
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: merging of two sorted arrays

2011-08-04 Thread Amit
Consider two array arr_a[] and arr_b[].
Suppose Number of elements  in  arr_a[] are n and number of elements
in arr_b[] are
m. size of arr_a[] is n and  size of arr_b[] is m.

 MergeInPlace(int arr_a[], int arr_b[],int n,int m)
 {
int a =0;b=0,k=0,key=0;
for(;b0){
 arr_b[k] = arr_b[k-1];
 k--;
}
arr_b[0] = arr_a[n-1];
k =n-1;
while(k>=a){
  arr_a[k] = arr_a[k-1];
  k--;
}
arr_a[a] = key;
break;
  }
}

-- 
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] Google Interview preparation

2011-08-04 Thread Amit Mittal
I have my google interview at the end of this month.
can any body provide me some tips/suggestions/questions ?
I am sure some of you guys here must have appeared in google interviews
before,
your help will be very valuable and much appreciated.


Thanks

-- 
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 an efficient search algo

2011-08-03 Thread amit karmakar
Can you show how to find k for an array containing n 2's using binary
search.

On Aug 4, 6:29 am, Dave  wrote:
> @Amit: If k is not known, you can find it with another binary search.
>
> Dave
>
> On Aug 3, 3:02 pm, amit karmakar  wrote:
>
>
>
> > I think for question 1, the value of k is not provided, right?
>
> > On Aug 4, 12:53 am, Ankur Garg  wrote:
>
> > > Dave's solution looks gud to me :)
>
> > > On Wed, Aug 3, 2011 at 3:52 PM, Ankur Garg  wrote:
> > > > Q1 can be looked as rotated sorted array...check whether the no is less 
> > > > or
> > > > greater than kth element ..if greater search using binary search with 
> > > > low =0
> > > > high k-1 and if less earch in right with low=k+1 high =n;
>
> > > > q2) Dont know :(
>
> > > > On Wed, Aug 3, 2011 at 3:44 PM, Dave  wrote:
>
> > > >> @Tushar: For problem 1, do a binary search on elements 1 to k, and if
> > > >> no hit is found, do a binary search on elements k+1 to n.
>
> > > >> For problem 2, suppose that you are searching the given array for the
> > > >> number 2. The idea is to take big steps when you are far from the
> > > >> target, and small steps when you are close. Start with i = 0. If a[i] !
> > > >> = 2, then add abs(a[i]-2) to i and try again. This is because it will
> > > >> take at least abs(a[i]-2) steps to get to 2.
>
> > > >>  In this case, i = 0 and a[0] = 6, so add 4 to i, getting 4. a[4] = 4,
> > > >> so add 2 to i, getting 6. a[6] = 3, so add 1. a[7] = 2.
>
> > > >> Dave
>
> > > >> On Aug 3, 2:09 pm, TUSHAR  wrote:
> > > >> > 1.   Given an array of n-elements ? the 1st k -elements are in
> > > >> > descending order and k+1 to n elements are in
> > > >> >       ascending order. give an  efficient algo for searching an
> > > >> > element ?
>
> > > >> > 2.  Given an array of n-elements ? each element in the array is 
> > > >> > either
> > > >> > same or less by 1 or larger by 1 from the
> > > >> >      previous element . give an  efficient algo for searching an
> > > >> > element ?
>
> > > >> >           e.g :   6 6 6 5 4 4 3 2 3 4 3 4 
>
> > > >> --
> > > >> 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.-Hide quoted text -
>
> > - Show quoted text -

-- 
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 an efficient search algo

2011-08-03 Thread amit karmakar
I think for question 1, the value of k is not provided, right?

On Aug 4, 12:53 am, Ankur Garg  wrote:
> Dave's solution looks gud to me :)
>
>
>
> On Wed, Aug 3, 2011 at 3:52 PM, Ankur Garg  wrote:
> > Q1 can be looked as rotated sorted array...check whether the no is less or
> > greater than kth element ..if greater search using binary search with low =0
> > high k-1 and if less earch in right with low=k+1 high =n;
>
> > q2) Dont know :(
>
> > On Wed, Aug 3, 2011 at 3:44 PM, Dave  wrote:
>
> >> @Tushar: For problem 1, do a binary search on elements 1 to k, and if
> >> no hit is found, do a binary search on elements k+1 to n.
>
> >> For problem 2, suppose that you are searching the given array for the
> >> number 2. The idea is to take big steps when you are far from the
> >> target, and small steps when you are close. Start with i = 0. If a[i] !
> >> = 2, then add abs(a[i]-2) to i and try again. This is because it will
> >> take at least abs(a[i]-2) steps to get to 2.
>
> >>  In this case, i = 0 and a[0] = 6, so add 4 to i, getting 4. a[4] = 4,
> >> so add 2 to i, getting 6. a[6] = 3, so add 1. a[7] = 2.
>
> >> Dave
>
> >> On Aug 3, 2:09 pm, TUSHAR  wrote:
> >> > 1.   Given an array of n-elements ? the 1st k -elements are in
> >> > descending order and k+1 to n elements are in
> >> >       ascending order. give an  efficient algo for searching an
> >> > element ?
>
> >> > 2.  Given an array of n-elements ? each element in the array is either
> >> > same or less by 1 or larger by 1 from the
> >> >      previous element . give an  efficient algo for searching an
> >> > element ?
>
> >> >           e.g :   6 6 6 5 4 4 3 2 3 4 3 4 
>
> >> --
> >> 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] Re: Minimum cuts required so that each sub string is a palindrome

2011-08-03 Thread amit karmakar
#include 
#include 
#include 
using namespace std;

#define REP(i, n) for(int i = 0, _n(n); i < _n; i++)

const int MX = 1;
char s[MX];

int pre[MX][MX];

int dp[MX];

int main() {
scanf("%s", s);

int n = strlen(s);

// preprocessing stage, mark pre[i][j] = 1 only if substring from
i to j is a palindrome
REP(i, n) memset(pre[i], 0, sizeof(pre[i]));
REP(i, n) {
// try i as center;
pre[i][i] = 1;
// try all odd length palindromes
int l = i-1, r = i+1;
while(l>=0 && r=0 && r wrote:
> @amit: can u supply the code for ur approach ??

-- 
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: C question.. increment decrement operator..

2011-08-03 Thread amit karmakar
You are wrong.
The above program invokes undefined behavior. Read the standard
language draft to know about sequence points, side effects and
undefined behavior.

Between a previous and next sequence point a variable's value cannot
be modified twice.
c-faq should be quite useful
http://c-faq.com/~scs/cgi-bin/faqcat.cgi?sec=expr
On Aug 3, 5:20 pm, Puneet Gautam  wrote:
> As we know:
>                      In an expression, if pre n post occur
> simultaneously, pre inc the value then n there only n post executes it
> after that expression...and expression evaluates right to left...
>
>  Also, the value of a variable in  an expression can be modified
> multifold times...there is no restriction on dat...
>
> Here in this code:
> Print statement No.:
>
> 1.  i++*i++ is equivalent to:
>          output i*i(7*7)
>        followed by
> i=i+1;
> i=i+1;
> prior to 2nd printf statement..that makes i=9
>
> 2. i++*++i
>     expn. evaluates right to left: i inc. by one due to pre..
> i is now 10 .
> output i*i(10*10)
> i=i+1 (due to post inc., it inc. the value after the output)
>  i is now 11
>
> 3. ++i*i++
>      right to left evaluation, but post inc. increases value only after 
> output..
> coming to ++i in the expn., i inc. to 12
> output: 12*12
> i=i+1(due to postinc.)
>  i is now 13
>
> 4. ++i*++i
> both pre inc operators, order of evaluation doesnt ,matter:
> i=i+1
> i=i+1
> output: 15*15
>
> i finishes at 15
>
> Hence the output:
> 49
> 100
> 144
> 225
>
> I think i made it clear..
> Feel free to point any loopholes..
>
> Thanks.
>
> On 8/3/11, ankit sambyal  wrote:
>
>
>
>
>
>
>
> > Its compiler dependent. Acc. to the C standard an object's stored value can
> > be modified only once in an expression.
>
> > --
> > 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] Re: Minimum cuts required so that each sub string is a palindrome

2011-08-03 Thread amit karmakar
Let the given string have a length N and contain characters indexed
from 1 on to N.

Let,
f(n) denote the minimum number of cuts that you need to make such that
each substring is a palindrome, considering only the prefix containing
n characters.

f(0) = -1
f(n) = min( f(x) + 1 ), take x such that 0 <= x < n and  p(x+1, n)=1.

where p(x, n) = { 1, if substring containing characters from position
x to n is a palindrome
 0, otherwise

You should calculate p(n, x) beforehand,
p(i, j) for all i, j such that 1 <= i <= j <= n can be calculated in
O(n^2),

Just try all characters as center and try growing the palindrome
towards right and left simultaneously. On the first mismatch before
right and left characters stop and try other
 characters as center. While you do this you may mark sol[i][j] as 1
if substring(i, j) is a palindrome.

I hope this is the optimal way of solving this problem.

This has a complexity of O(n^2).

If anyone has something better to add to this please comment.

On Aug 3, 9:07 am, ankit sambyal  wrote:
> You are given a large string. You need to cut the string into chunks such
> that each substring that you get is a palindrome. Remember that each 1
> length string is always a palindrome. You need to find the minimum number of
> cuts that you need to make such that each substring is a palindrome.

-- 
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: SEGMENT TREE: WA

2011-08-02 Thread amit karmakar
Do you understand the problem properly ?
>From your code it seems you don't understand the problem.
Can you explain the approach that you have implemented?

On Aug 2, 5:13 pm, Amol Sharma  wrote:
> anyone ??
> --
>
> Amol Sharma
> Third Year Student
> Computer Science and Engineering
> MNNIT Allahabad
>
>
>
>
>
>
>
> On Tue, Aug 2, 2011 at 1:57 PM, Amol Sharma  wrote:
> > hi,
>
> > i attempted the problem  http://www.spoj.pl/problems/GSS1/
>
> > i have the solved the problem using segment trees.i have the checked my
> > solution for the most of the cases it is working fine.but i am getting
> > WA...plz tell any case where my code fails !!.please point out the
> > bug if any in the code
>
> > #include
> > //                                SEGEMENT TREE
> > // this program will make a segment tree of a given array and then perform
> > the queries on it as asked in the question fo any range
>
> > //starting with the function to ionitialise the segement tree
>
> > //                        INTIALIZATION
> > void initialize(int node, int b, int e, int M[], int A[])
> > {
> >    if (b == e)
> >        M[node] = A[b];
> >    else
> >   {
> > //compute the values in the left and right subtrees
> >        initialize(2 * node, b, (b + e) / 2, M, A);
> >        initialize(2 * node + 1, (b + e) / 2 + 1, e, M, A);
> > //search for the minimum value in the first and
> > //second half of the interval
> >        if (M[2 * node] >= M[2 * node + 1])
> >             M[node] = M[2 * node];
> >        else
> >             M[node] = M[2 * node + 1];
> >    }
> > }
>
> > //function for doing query on the segement tree
> > //                            QUERY
>
> > int query(int node, int b, int e, int M[], int A[], int i, int j)
> > {
> >     int p1, p2;
>
> > //if the current interval doesn't intersect
> > //the query interval return -1
> >     if (i > e || j < b)
> >         return -1;
>
> > //if the current interval is included in
> > //the query interval return M[node]
> >     if (b >= i && e <= j)
> >         return M[node];
>
> > //compute the minimum position in the
> > //left and right part of the interval
> >     p1 = query(2 * node, b, (b + e) / 2, M, A, i, j);
> >     p2 = query(2 * node + 1, (b + e) / 2 + 1, e, M, A, i, j);
>
> > //return the position where the overall
> > //minimum is
> >     if (p1 == -1)
> >         return /*M[node] =*/ p2;
> >     if (p2 == -1)
> >         return /*M[node] =*/ p1;
> >     if (p1 >= p2)
> >         return /*M[node] =*/ p1;
> >     return /*M[node] =*/ p2;
> > }
>
> > int A[5]={0},M[10]={-1};
>
> > int main()
> > {
> >     int n,i,j,tc;
> >     scanf("%d",&n);//now number of elements in the array is known
> >     for(i=0;i >         scanf("%d",&A[i]);
>
> >     //initialize your segement tree now
>
> >    initialize(1,0,n-1,M,A);
>
> > /*    for(i=0;i<2*n;i++)
> >             printf("%d  ",M[i]);
> >        printf("\n");
> >     */
> >     //perform the queries here
> >    scanf("%d",&tc);
> >     while(tc--)
> >     {
> >         scanf("%d%d",&i,&j);
> >         //perform the query for each interval
> >        printf("%d\n",query(1,0,n-1,M,A,i-1,j-1));
>
> >         //print the maximun value here
> >     }
>
> > return 0;
> > }
>
> > Amol Sharma
> > Third Year Student
> > Computer Science and Engineering
> > MNNIT Allahabad

-- 
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: 100th Fibonacci number using LL

2011-07-31 Thread amit karmakar
Since long long cannot store the 100th Fibonacci number, you need to
implement or use an existing library for bignum.

You may use linked lists to solve this problem.
Read about bignum here 
http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic

Here is my implementation for solving this problem,
#include 
#include 
#include 

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FILL(c, v) memset(c, v, sizeof(c))

const int MX = 10;
int prv1[MX], prv2[MX], cur[MX], l1, l2, lcur;

int main() {
FILL(prv1, 0); FILL(prv2, 0); FILL(cur, 0);
int n;
scanf("%d", &n);

prv1[0] = 0; l1 = 1;
prv2[0] = 1; l2 = 1;
cur[0]  = 0; lcur = 1;
REP(i, n) {
int mx = max(l1, l2);
int carry = 0;
REP(j, mx) {
int imd = prv1[j]+prv2[j]+carry;
cur[j]  = imd%10;
carry   = imd/10;
}
if(carry) {
cur[mx++] = carry;
}
lcur = mx;

REP(j, l1)   prv2[j] = prv1[j]; l2=l1;
REP(j, lcur) prv1[j] = cur[j];  l1=lcur;
}
REP(i, lcur) printf("%d", cur[lcur-i-1]); printf("\n");
}

On Jul 31, 9:31 pm, bharath sriram  wrote:
> Since both the "normal" recursive (stack overflow) and non-recursive (data
> type overflow) versions fails, is there a  way one can use linked lists to
> solve this problem?
>
> Bharath.

-- 
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: interview questoin

2011-07-31 Thread Amit Jaspal
This is discussed before I think. It will be in O(n).

On Jul 31, 1:15 pm, siva viknesh  wrote:
> using map ?? key - string , value - count..print d string whose count
> is 1..
>
> On Jul 19, 8:49 pm, "pacific :-)"  wrote:
>
>
>
>
>
>
>
> > sorry.
>
> > On Tue, Jul 19, 2011 at 9:07 PM, Shubham Maheshwari <
>
> > shubham.veloc...@gmail.com> wrote:
> > > what is meant by unique string ...!!
>
> > > A string which occurs only once.
>
> > > On Tue, Jul 19, 2011 at 9:04 PM, SAMMM  wrote:
>
> > >> There is only one unique string  in the list of strings (words) ?
>
> > > There can be many.
>
> > >> On Jul 19, 8:31 pm, "pacific :-)"  wrote:
> > >> > Find unique string from a list of strings in one pass.
>
> > >> > --
> > >> > regards,
> > >> > chinna.
>
> > >> --
> > >> 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.
>
> > > --
> > > Shubham Maheshwari
> > > ShubZz
> > > O.o o.O
>
> > > enJoY ...!!!
>
> > >  --
> > > 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,
> > chinna.

-- 
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: Subsequence with Sum S

2011-07-30 Thread amit karmakar
This can be reduced to the standard subset sub problem. For algorithms
to solve it consider reading about it here,
http://en.wikipedia.org/wiki/Subset_sum_problem

This is my implementation for solving this problem provided the range
of values that the array can take is small(from 0 to MXSUM-1
inclusive).

#include 
#include 

using namespace std;

#define REP(i, n) for(int i = 0, _n(n); i <(_n); i++)

typedef long long LL;

const int MXCNT = 111, MXSUM = 11;
int a[MXCNT], mk[MXSUM], subsets[MXSUM];

int main() {
int n, k;
scanf("%d%d", &n, &k);

REP(i, n) scanf("%d", &a[i]);
memset(mk, 0, sizeof(mk));
memset(subsets, 0, sizeof(subsets));

int cnt = 0;
subsets[cnt++] = 0;

int ok = 0;
REP(i, n) {
REP(j, cnt) {
int tmp = subsets[j]+a[i];
if(!mk[tmp]) {
if(tmp==k) ok = 1;
subsets[cnt++] = tmp;
mk[tmp] = 1;
}
}
}
printf("%d\n", ok);
}



On Jul 30, 9:36 pm, Dumanshu  wrote:
> Given an array of length n of integer numbers. Output 1 or 0 depending
> on whether or not there exists a sub sequence in the array with sum S.
> Suggest a fastest algorithm plz.
>
> e.g. say given an array with numbers as 10 20 30 40 50 60 70
> Sum = 110
>
> Output is 1 because 20+30+50 is 110.

-- 
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: adobe written round que

2011-07-29 Thread Amit
well,well,well...
a=x>>1;
b=x>>2;
c=(a+b)>>1;
d=x>>3;
x=c+d;
 1/3 = 3/9 = ((1/2)+(1/4))/2 + 1/8   >

On Jul 30, 1:37 am, nivedita arora 
wrote:
> hmm ok got it . ..i can take gt sum of digits without having the
> number as string as well . i din exactly gt the whole point of using
> strings.
> they shud hv mentioned it explicitly i guess . .
> though thanks ankur
>
> On Jul 30, 1:15 am, Ankur Khurana  wrote:
>
>
>
>
>
>
>
> > you shouldn't be using itoa anyways. It is not a part of ANSI C. you might
> > like to use sprintf . you can search for reference on cplusplus.com
>
> > On Sat, Jul 30, 2011 at 1:36 AM, aditi garg 
> > wrote:
>
> > > @Ankur: I dont know how to use itoa function...can u please write a small
> > > code...for eg in dis ques only can u tell me how to use itoa to get sum...
>
> > > On Sat, Jul 30, 2011 at 1:13 AM, Ankur Khurana 
> > > wrote:
>
> > >> when you use itoa , what you get is a string. get the sum of all the
> > >> digits , using c-'0' and then use repeated subtraction . . .
>
> > >> On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
> > >> wrote:
>
> > >>> repeated subtraction !!
>
> > >>> On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora <
> > >>> vivaciousnived...@gmail.com> wrote:
>
> >  Without using /,% and * operators. write a function to divide a number
> >  by 3. itoa() function is available.
>
> >  all i cn thnk of is to use shift operator and addition ,  x/3=e^(logx-
> >  log3) or repetitive subtraction
>
> >  but none of them uses itoa() ..ne idea how its done?
> >  thnks !
>
> >  --
> >  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.
>
> > >> --
> > >> Ankur Khurana
> > >> Computer Science
> > >> Netaji Subhas Institute Of Technology
> > >> Delhi.
>
> > >>  --
> > >> 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.
>
> > > --
> > > Aditi Garg
> > > Undergraduate Student
> > > Electronics & Communication Divison
> > > NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> > > Sector 3, Dwarka
> > > New Delhi
>
> > >  --
> > > 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.
>
> > --
> > Ankur Khurana
> > Computer Science
> > Netaji Subhas Institute Of Technology
> > Delhi.

-- 
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: permutation of string with repeated characters...

2011-07-29 Thread amit karmakar
there was an typo,

if mk array is *not* there backtracking will try like

On Jul 29, 7:13 pm, amit karmakar  wrote:
> The seen array filters out the characters which are available for
> filling a particular position.
> The mk array makes sure that we choose only one of the repeated
> characters.
>
> for example,
> if the array is aba
>
> if mk array is there backtracking will try like
> String             :  a _ _   or  b _ _  or a _ _
> character position :  0 _ _       1 _ _     2 _ _
>
> with mk array ,
> String             :  a _ _
> character position :  2 _ _
> will not happen.
>
> I hope you can get my notations.
>
> On Jul 29, 10:17 am, Arun Vishwanathan  wrote:
>
>
>
> > @amit:i am not clear about the code.Maybe could you take your example string
> > aabc and explain a few steps that happen from your code??.The array mk is
> > locally created for each function call and so I do not get how it keeps
> > track of elements tried cos each time it is a new array.
>
> > On Fri, Jul 29, 2011 at 3:54 AM, amit karmakar 
> > wrote:
>
> > > What my recursive solution does is that,
> > > For all elements that can be used at position *k*, fix that element at
> > > position *k* and then permute the rest of the elements.
> > > So if are two same elements which can be used at position *k* we must
> > > choose only one of it to avoid repeated permutations.
>
> > > Array mk[256] keeps a track of the elements that have already been
> > > tried.
>
> > > >> Does there exist any better solution also, or this backtracking 
> > > >> solution
> > > is the best?
> > > You should have a look at this:
>
> > >http://en.wikipedia.org/wiki/Permutation#Algorithms_to_generate_permu...
>
> > > On Jul 29, 12:34 am, Nitish Garg  wrote:
> > > > Can you please explain what is the use of the array mk[256], how this
> > > array
> > > > solves the problem of repeated characters.
> > > > Does there exist any better solution also, or this backtracking solution
> > > is
> > > > the best?
>
> > > --
> > > 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] Re: permutation of string with repeated characters...

2011-07-29 Thread amit karmakar
The seen array filters out the characters which are available for
filling a particular position.
The mk array makes sure that we choose only one of the repeated
characters.

for example,
if the array is aba

if mk array is there backtracking will try like
String :  a _ _   or  b _ _  or a _ _
character position :  0 _ _   1 _ _ 2 _ _

with mk array ,
String :  a _ _
character position :  2 _ _
will not happen.

I hope you can get my notations.

On Jul 29, 10:17 am, Arun Vishwanathan  wrote:
> @amit:i am not clear about the code.Maybe could you take your example string
> aabc and explain a few steps that happen from your code??.The array mk is
> locally created for each function call and so I do not get how it keeps
> track of elements tried cos each time it is a new array.
>
> On Fri, Jul 29, 2011 at 3:54 AM, amit karmakar 
> wrote:
>
>
>
> > What my recursive solution does is that,
> > For all elements that can be used at position *k*, fix that element at
> > position *k* and then permute the rest of the elements.
> > So if are two same elements which can be used at position *k* we must
> > choose only one of it to avoid repeated permutations.
>
> > Array mk[256] keeps a track of the elements that have already been
> > tried.
>
> > >> Does there exist any better solution also, or this backtracking solution
> > is the best?
> > You should have a look at this:
>
> >http://en.wikipedia.org/wiki/Permutation#Algorithms_to_generate_permu...
>
> > On Jul 29, 12:34 am, Nitish Garg  wrote:
> > > Can you please explain what is the use of the array mk[256], how this
> > array
> > > solves the problem of repeated characters.
> > > Does there exist any better solution also, or this backtracking solution
> > is
> > > the best?
>
> > --
> > 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] Re: permutation of string with repeated characters...

2011-07-29 Thread amit karmakar
>> i more thing ... the code repeats same palindromes as in incase of ABA baa
>> is coming twice..
Put back mk array in place and baa won't be repeated.

The idea is that out of all available options for filling a particular
position in our partial solution at each round of backtracking we
choose for each group of repeated characters, only one of them.
In this way, we get only distinct permutations as output.

On Jul 29, 3:37 pm, snehi jain  wrote:
> i did a dry run on this code and didnt find the significance of mk array ...
> so i did remove it from the code ..
> and the code works fine ..
> i more thing ... the code repeats same palindromes as in incase of ABA baa
> is coming twice..
>
> correct me if i am wrong ...
>
> On Fri, Jul 29, 2011 at 10:47 AM, Arun Vishwanathan
> wrote:
>
>
>
> > @amit:i am not clear about the code.Maybe could you take your example
> > string aabc and explain a few steps that happen from your code??.The array
> > mk is locally created for each function call and so I do not get how it
> > keeps track of elements tried cos each time it is a new array.
>
> > On Fri, Jul 29, 2011 at 3:54 AM, amit karmakar 
> > wrote:
>
> >> What my recursive solution does is that,
> >> For all elements that can be used at position *k*, fix that element at
> >> position *k* and then permute the rest of the elements.
> >> So if are two same elements which can be used at position *k* we must
> >> choose only one of it to avoid repeated permutations.
>
> >> Array mk[256] keeps a track of the elements that have already been
> >> tried.
>
> >> >> Does there exist any better solution also, or this backtracking
> >> solution is the best?
> >> You should have a look at this:
>
> >>http://en.wikipedia.org/wiki/Permutation#Algorithms_to_generate_permu...
>
> >> On Jul 29, 12:34 am, Nitish Garg  wrote:
> >> > Can you please explain what is the use of the array mk[256], how this
> >> array
> >> > solves the problem of repeated characters.
> >> > Does there exist any better solution also, or this backtracking solution
> >> is
> >> > the best?
>
> >> --
> >> 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] Re: Facebook Intern F2F Interview

2011-07-28 Thread Amit Gupta
I'm wondering if we should be using the rand() library function or
the guy is expecting us to create a random function.

y = rand( )%100; if(yhttp://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: permutation of string with repeated characters...

2011-07-28 Thread amit karmakar
What my recursive solution does is that,
For all elements that can be used at position *k*, fix that element at
position *k* and then permute the rest of the elements.
So if are two same elements which can be used at position *k* we must
choose only one of it to avoid repeated permutations.

Array mk[256] keeps a track of the elements that have already been
tried.

>> Does there exist any better solution also, or this backtracking solution is 
>> the best?
You should have a look at this:
http://en.wikipedia.org/wiki/Permutation#Algorithms_to_generate_permutations

On Jul 29, 12:34 am, Nitish Garg  wrote:
> Can you please explain what is the use of the array mk[256], how this array
> solves the problem of repeated characters.
> Does there exist any better solution also, or this backtracking solution is
> the best?

-- 
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: Permutations in a string

2011-07-28 Thread amit karmakar
Yes, you are right. A slight modification is needed to handle repeated
characters. I have already posted that in this group.
https://groups.google.com/group/algogeeks/msg/afb18610819dbd90

On Jul 28, 10:56 pm, varun pahwa  wrote:
> @amit:: I think ur solution will give wrong answer if all the characters are
> not unique.
>
>
>
>
>
> On Thu, Jul 28, 2011 at 11:13 PM, SAMMM  wrote:
>
> >http://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotte...
>
> > U can try this too ..  Without any recursion ...
>
> > --
> > 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.
>
> --
> Varun Pahwa
> B.Tech (IT)
> 7th Sem.
> Indian Institute of Information Technology Allahabad.
> Ph : 09793899112
> Official Email :: rit2008...@iiita.ac.in
> Another Email :: varunpahwa.ii...@gmail.com
>
> People who fail to plan are those who plan to fail.

-- 
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: Facebook Interview question at NIT Warangal

2011-07-28 Thread amit karmakar
I am wrong about the complexity. Its O(n*2^n).

>> @amitno it wont work..check it..
My code generates all subsets of a set containing elements from 1 to
n(inclusive). I was answering for ankur.
Why won't it work ?

On Jul 28, 1:39 pm, Piyush Sinha  wrote:
> @amitno it wont work..check it..
>
>
>
>
>
> On Wed, Jul 27, 2011 at 10:07 PM, amit  wrote:
> > This should be O(2^n)
>
> > #include 
> > #include 
> > using namespace std;
>
> > int n;
> > int sol[1000];
> > void solve(int pos, int k) {
> >    for(int i = 0; i < k; i++) printf("%d, ", sol[i]);
> >    putchar('\n');
> >    for(int i = pos; i < n; i++) {
> >        sol[k] = i+1;
> >        solve(i+1, k+1);
> >    }
> > }
>
> > int main() {
> >    scanf("%d", &n);
> >    solve(0, 0);
> > }
>
> > On Jul 27, 8:33 pm, Ankur Garg  wrote:
> > > Hi
>
> > > The solution in the link is of complexity (n*2^n))
>
> > > Does anyone know any better solution ?
>
> > > Regards
> > > Ankur
> > > On Tue, Jul 26, 2011 at 11:10 PM, rajeev bharshetty <
> > rajeevr...@gmail.com>wrote:
>
> > > > @Ankur The link does has a very good explanation. Nice solution :)
>
> > > > On Tue, Jul 26, 2011 at 10:47 PM, Kunal Patil 
> > wrote:
>
> > > >> @Ankur Garg: Nice explanation at the link given by u...
>
> > > >> On Tue, Jul 26, 2011 at 10:35 PM, Ankur Garg  > >wrote:
>
> > > >>> Check this
>
> >http://codesam.blogspot.com/2011/03/find-all-subsets-of-given-set.html
>
> > > >>> On Tue, Jul 26, 2011 at 9:41 PM, Vishal Thanki <
> > vishaltha...@gmail.com>wrote:
>
> > > >>>> Here is the working code..
>
> > > >>>> #include 
> > > >>>> #include 
> > > >>>> int a[] = {1,2,3,4,5};
> > > >>>> #define ARRLEN(a) (sizeof(a)/sizeof(a[0]))
> > > >>>> void print_comb(int len)
> > > >>>> {
> > > >>>>        int tlen = len;
> > > >>>>        int i, j, k;
> > > >>>>         int al = ARRLEN(a);
> > > >>>>        for (i = 0; i < al; i++) {
> > > >>>>                for (j=i+len-1; j > > >>>>                for (k = i; k < i+len-1; k++) {
> > > >>>>                        printf("%d ", a[k]);
> > > >>>>                }
> > > >>>>                printf("%d\n", a[j]);
> > > >>>>                 }
> > > >>>>        }
> > > >>>> }
>
> > > >>>> int main(int argc, char *argv[])
> > > >>>> {
> > > >>>>        int len = atoi(argv[1]);
> > > >>>>         print_comb(len);
> > > >>>>        return 0;
> > > >>>> }
>
> > > >>>> On Tue, Jul 26, 2011 at 5:18 PM, praneethn 
> > > >>>> wrote:
>
> > > >>>> > check this link:
>
> > > >>>> > *http://www.stefan-pochmann.info/spots/tutorials/sets_subsets/*
>
> > > >>>> > On Tue, Jul 26, 2011 at 11:59 AM, sumit 
> > > >>>> wrote:
>
> > > >>>> >> Given an array of size n, print all the possible subset of array
> > of
> > > >>>> >> size k.
> > > >>>> >> eg:-
> > > >>>> >> input:
> > > >>>> >> a[]={1,2,3,4}, k = 2
> > > >>>> >> output:
> > > >>>> >> 1,2
> > > >>>> >> 1,3
> > > >>>> >> 1,4
> > > >>>> >> 2,3
> > > >>>> >> 2,4
> > > >>>> >> 3,4
>
> > > >>>> >> --
> > > >>>> >> 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, v

Re: [algogeeks] TIC TAC TOE

2011-07-28 Thread amit karmakar
Will the given game configuration always be a completed game i.e no more
moves can be done?

On Thu, Jul 28, 2011 at 7:10 PM, radha krishnan <
radhakrishnance...@gmail.com> wrote:

> Excuse me MR.balaji :P
> U got selected for Microsoft Redmond :P still preparing ? :P
>
> On Thu, Jul 28, 2011 at 6:01 AM, Balaji S  wrote:
> > Given a 3X3 matrix , with 1's 0's and -1's ( 1 is player one 0 is player
> two
> > -1 is none)
> >
> > how ll you find who is the winner / draw in a tic tac toe game in the
> most
> > effiecient manner...
> >
> > --
> > With Regards,
> > Balaji.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.
> >
>
> --
> 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] Re: rotate a matrix NVIDIA question

2011-07-28 Thread amit karmakar
I think you meant spiral traversal,

#include 
#include 
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)

const int MX = 1000;
int a[MX][MX], seen[MX][MX], n;

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main() {
scanf("%d", &n);
REP(i, n) REP(j, n) scanf("%d", &a[i][j]);

REP(i, n) memset(seen[i], 0, sizeof(seen[i]));

int x, y, dir;
x = y = dir = 0;
REP(i, n*n) {
printf("%d ", a[x][y]);
seen[x][y] = 1;

x += dx[dir]; y += dy[dir];
if((x<0) || (x>=n) || (y<0) || (y>=n) || seen[x][y]) {
x -= dx[dir]; y -= dy[dir];
dir = (dir+1)%4;
x += dx[dir]; y += dy[dir];
}

}
}


On Jul 28, 11:57 am, Deoki Nandan  wrote:
> there is no specification on complexity . if input matrix is
> 1 2 3
> 4 5 6
> 7 8 9
> then after 180 rotation output should be
> 1 2 3 6  9 8 7 4 5
>
> On Wed, Jul 27, 2011 at 11:34 PM, amit karmakar
> wrote:
>
>
>
>
>
> > If you meant "rotate a 2D matrix by angle 180" of order n x n
> > Then you cannot have a O(n) algo, Each of the n^2 elements must be
> > accessed so you cannot have anything less than n^2
>
> > On Jul 27, 10:59 pm, Puneet Gautam  wrote:
> > > Can anyone give an O(n) solution pls...??
> > > I think the above code is an O(n^2) solution..
> > > if i am not wrong...!!!
>
> > > On 7/27/11, amit  wrote:
>
> > > > #include 
> > > > #include 
> > > > using namespace std;
>
> > > > const int MX = 1000;
> > > > int n, m;
> > > > int a[MX][MX];
>
> > > > int main() {
> > > >     scanf("%d%d", &n, &m);
> > > >     for(int i = 0; i < n; i++)
> > > >         for(int j = 0; j < m; j++)
> > > >             scanf("%d", &a[i][j]);
>
> > > >     for(int i = 0; i < n/2; i++)
> > > >         for(int j = 0; j < m; j++)
> > > >             swap(a[i][j], a[n-i-1][m-j-1]);
> > > >     if(n&1)
> > > >         for(int j = 0; j < m/2; j++)
> > > >             swap(a[n/2][j], a[n/2][m-j-1]);
>
> > > >     for(int i = 0; i < n; i++) {
> > > >         for(int j = 0; j < m; j++)
> > > >             printf("%d ", a[i][j]);
> > > >         printf("\n");
> > > >     }
> > > > }
>
> > > > On Jul 27, 7:54 pm, Anika Jain  wrote:
> > > >> is it lyk for {1,2,3
> > > >>                    4,5,6,
> > > >>                    7,8,9}
> > > >> to be {3,2,1,
> > > >>          6,5,4,
> > > >>          9,8,7}    ??
>
> > > >> On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan 
> > wrote:
> > > >> > rotate a 2D matrix by angle 180
>
> > > >> > --
> > > >> > **With Regards
> > > >> > Deoki Nandan Vishwakarma
>
> > > >> > *
> > > >> > *
>
> > > >> >  --
> > > >> > 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.
>
> --
> **With Regards
> Deoki Nandan Vishwakarma
>
> *
> *

-- 
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: Facebook Interview question at NIT Warangal

2011-07-28 Thread amit
This should be O(2^n)

#include 
#include 
using namespace std;

int n;
int sol[1000];
void solve(int pos, int k) {
for(int i = 0; i < k; i++) printf("%d, ", sol[i]);
putchar('\n');
for(int i = pos; i < n; i++) {
sol[k] = i+1;
solve(i+1, k+1);
}
}

int main() {
scanf("%d", &n);
solve(0, 0);
}


On Jul 27, 8:33 pm, Ankur Garg  wrote:
> Hi
>
> The solution in the link is of complexity (n*2^n))
>
> Does anyone know any better solution ?
>
> Regards
> Ankur
> On Tue, Jul 26, 2011 at 11:10 PM, rajeev bharshetty 
> wrote:
>
>
>
> > @Ankur The link does has a very good explanation. Nice solution :)
>
> > On Tue, Jul 26, 2011 at 10:47 PM, Kunal Patil  wrote:
>
> >> @Ankur Garg: Nice explanation at the link given by u...
>
> >> On Tue, Jul 26, 2011 at 10:35 PM, Ankur Garg wrote:
>
> >>> Check this
>
> >>>http://codesam.blogspot.com/2011/03/find-all-subsets-of-given-set.html
>
> >>> On Tue, Jul 26, 2011 at 9:41 PM, Vishal Thanki 
> >>> wrote:
>
>  Here is the working code..
>
>  #include 
>  #include 
>  int a[] = {1,2,3,4,5};
>  #define ARRLEN(a) (sizeof(a)/sizeof(a[0]))
>  void print_comb(int len)
>  {
>         int tlen = len;
>         int i, j, k;
>          int al = ARRLEN(a);
>         for (i = 0; i < al; i++) {
>                 for (j=i+len-1; j                 for (k = i; k < i+len-1; k++) {
>                         printf("%d ", a[k]);
>                 }
>                 printf("%d\n", a[j]);
>                  }
>         }
>  }
>
>  int main(int argc, char *argv[])
>  {
>         int len = atoi(argv[1]);
>          print_comb(len);
>         return 0;
>  }
>
>  On Tue, Jul 26, 2011 at 5:18 PM, praneethn 
>  wrote:
>
>  > check this link:
>
>  > *http://www.stefan-pochmann.info/spots/tutorials/sets_subsets/*
>
>  > On Tue, Jul 26, 2011 at 11:59 AM, sumit 
>  wrote:
>
>  >> Given an array of size n, print all the possible subset of array of
>  >> size k.
>  >> eg:-
>  >> input:
>  >> a[]={1,2,3,4}, k = 2
>  >> output:
>  >> 1,2
>  >> 1,3
>  >> 1,4
>  >> 2,3
>  >> 2,4
>  >> 3,4
>
>  >> --
>  >> 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.
>
> >>>  --
> >>> 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
> > Rajeev N B 
>
> >  --
> > 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.googl

Re: [algogeeks] permutation of string with repeated characters...

2011-07-27 Thread amit karmakar
>> how to find all permutations of string with repeated characters.like
aabc.
idea is backtracking, complexity isn't very good

#include 
#include 
using namespace std;

const int MX = 1000;
char str[MX], sol[MX];

bool seen[MX] = {0};
void print(int n, int k=0) {
if(k==n) {
sol[n] = 0; printf("%s\n", sol);
return;
}
int mk[256] = {0};
for(int i = 0; i < n; i++) {
if(!seen[i]&& !mk[str[i]]) {
sol[k] = str[i];
mk[str[i]] = 1;
seen[i] = 1; print(n, k+1); seen[i] = 0;
}
}
}

int main() {
scanf("%s", &str);
print(strlen(str));
}


On Thu, Jul 28, 2011 at 1:31 AM, Kamakshii Aggarwal
wrote:

> how to find all permutations of string with repeated characters.like aabc.
>
> --
> Regards,
> Kamakshi
> kamakshi...@gmail.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 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] Re: Amazon Question

2011-07-27 Thread amit karmakar
#include 
#include 
using namespace std;

const int MX = 1000;
char str[MX], sol[MX];

bool seen[MX] = {0};
void print(int n, int k=0) {
if(k==n) {
sol[n] = 0; printf("%s\n", sol);
return;
}

for(int i = 0; i < n; i++) {
if(!seen[i]) {
sol[k] = str[i];
seen[i] = 1; print(n, k+1); seen[i] = 0;
}
}
}

int main() {
scanf("%s", &str);
print(strlen(str));
}


On Jul 28, 12:03 am, "*$*"  wrote:
> The following code can be used to generate permutations of the string.. but
> still some bugs are there like to avoid already printed char etc.. however
> logic will be similar..
>
> order will be less that n^2
>
> // stringPermutration.cpp : Defines the entry point for the console
> application.
> //
>
> #include "stdafx.h"
> #include
> #include
> #include
> #include
>
> using namespace std;
>
> using namespace std;
>
> void Permutate(int pos,char *prefix,char *str,char *src)
> {
>     char *prefix1,*str1,*src1;
>         prefix1 = new char[20];
>     memset(prefix1,0,20);
>     str1 = new char[20];
>     memset(str1,0,20);
>     src1 = new char[20];
>     memset(src1,0,20);
>     if(pos >= strlen(src))
>         return;
>     if(strlen(str)!=0)
>     {
>
>     strcpy(prefix1,prefix);
>     strcpy(str1,str);
>     strcpy(src1,src);
>     prefix1[strlen(prefix1)]=str1[0];
>     prefix1[strlen(prefix1)+1]='\0';
>     for(int i=0;i     {
>         str1[i]=str1[i+1];
>     }
>     }
>     else
>     {
>         int j;
>         int pos1=pos+1;
>         for(int i=pos1,j=0;j         {
>             str[j]=src[(i+j)%strlen(src)];
>             j++;
>             //i++;
>
>         }
>         strcpy(prefix1,"");
>         strcpy(str1,str);
>         pos++;
>     }
>     strcpy(prefix,prefix1);
>     strcpy(str,str1);
>     Permutate(pos,prefix,str,src);
>
>     for(int x=0;x     {
>         printf("\n %s",prefix1);
>         printf("%c",str1[x]);
>     }
>
> }
>
> int _tmain(int argc, _TCHAR* argv[])
> {
>
>     char *str = new char[20];
>     char *remaining = new char[20];
>     memset(str,0,20);
>     memset(remaining,0,20);
>     strcpy(str,"abcd");
>     strcpy(remaining,str);
>     char *prefix = new char[20];
>     memset(prefix,0,20);
>     Permutate(0,prefix,remaining,str);
>     return 0;
>
> }
>
> Thx,
> --Gopi
>
> On Thu, Jul 28, 2011 at 12:30 AM, Kamakshii Aggarwal
> wrote:
>
>
>
> > in the above example y ac is not included in the substring?
>
> > On Wed, Jul 27, 2011 at 3:45 PM, saurabh singh wrote:
>
> >> hmm o(nlogn) was for constructing the tree.Btw sorry for being unclear.
> >> The best solution is the obvious one in this case.
>
> >> On Wed, Jul 27, 2011 at 2:10 PM, surender sanke wrote:
>
> >>> @ sunny , ur right!!
>
> >>> surender
>
> >>> On Wed, Jul 27, 2011 at 1:58 PM, sunny agrawal 
> >>> wrote:
>
>  i don't find difference between your suffix tree approach and my simple
>  O(N^2) method
>  in both cases printf statement will be executed O(N^2) times
>  and in Suffix Tree approach will take some extra time of construction of
>  tree and extra space too !
>
>  On Wed, Jul 27, 2011 at 1:45 PM, surender sanke 
>  wrote:
>
> >         *
> >      /  \    \
> >    a     b    c
> >   /        \
> > b          c
> > /
> > c
>
> > prints *a*
> > comes to b, appends a with b    prints *ab*
> > comes to c ,appends ab with c   prints *abc*
> > starts with new child
> > prints *b*
> > prints *bc*
> > prints *c*
>
> > surender
>
> > On Wed, Jul 27, 2011 at 12:46 PM, sunny agrawal <
> > sunny816.i...@gmail.com> wrote:
>
> >> But still Printing O(N^2) substrings will take O(N^2) time isn't it ?
>
> >> On Wed, Jul 27, 2011 at 12:39 PM, surender sanke  >> > wrote:
>
> >>> @sunny
> >>> consider *uncompressed* suffix tree, even with distinct elements
> >>> maximum number of nodes with string length n formed will be 2n.
> >>>  once suffix tree is constructed, needs to traverse in dfs order
> >>> appending the node found on the way.
> >>> total complexity would be O(construction of suffix tree ) +
> >>> O(traverse time).
>
> >>> surender
>
> >>> On Wed, Jul 27, 2011 at 12:00 PM, sunny agrawal <
> >>> sunny816.i...@gmail.com> wrote:
>
>  @shiva viknesh
>  this is a different Question...
>
>  @saurabh
>  how is nlgn possible, total no of possible substrings are n^2
>
>  this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh
>  singh
>
>  for(int l = 0; l < len; l++){
>                  for(int i = 0; i < len-l; i++){
>                          int j = i+l;
>                          char temp = s[j+1];
>                          s[j+1] = 0;
>                          printf("%s\n", s+i);
>                          s[j+1] = temp;
>                  }
>          }

[algogeeks] Re: Amazon Question

2011-07-27 Thread amit karmakar
http://en.wikipedia.org/wiki/Substring
ac should be a subsequence and not substring.

On Jul 28, 12:00 am, Kamakshii Aggarwal  wrote:
> in the above example y ac is not included in the substring?
>
>
>
>
>
> On Wed, Jul 27, 2011 at 3:45 PM, saurabh singh  wrote:
> > hmm o(nlogn) was for constructing the tree.Btw sorry for being unclear.
> > The best solution is the obvious one in this case.
>
> > On Wed, Jul 27, 2011 at 2:10 PM, surender sanke wrote:
>
> >> @ sunny , ur right!!
>
> >> surender
>
> >> On Wed, Jul 27, 2011 at 1:58 PM, sunny agrawal 
> >> wrote:
>
> >>> i don't find difference between your suffix tree approach and my simple
> >>> O(N^2) method
> >>> in both cases printf statement will be executed O(N^2) times
> >>> and in Suffix Tree approach will take some extra time of construction of
> >>> tree and extra space too !
>
> >>> On Wed, Jul 27, 2011 at 1:45 PM, surender sanke 
> >>> wrote:
>
>          *
>       /  \    \
>     a     b    c
>    /        \
>  b          c
>  /
>  c
>
>  prints *a*
>  comes to b, appends a with b    prints *ab*
>  comes to c ,appends ab with c   prints *abc*
>  starts with new child
>  prints *b*
>  prints *bc*
>  prints *c*
>
>  surender
>
>  On Wed, Jul 27, 2011 at 12:46 PM, sunny agrawal <
>  sunny816.i...@gmail.com> wrote:
>
> > But still Printing O(N^2) substrings will take O(N^2) time isn't it ?
>
> > On Wed, Jul 27, 2011 at 12:39 PM, surender sanke 
> > wrote:
>
> >> @sunny
> >> consider *uncompressed* suffix tree, even with distinct elements
> >> maximum number of nodes with string length n formed will be 2n.
> >>  once suffix tree is constructed, needs to traverse in dfs order
> >> appending the node found on the way.
> >> total complexity would be O(construction of suffix tree ) + O(traverse
> >> time).
>
> >> surender
>
> >> On Wed, Jul 27, 2011 at 12:00 PM, sunny agrawal <
> >> sunny816.i...@gmail.com> wrote:
>
> >>> @shiva viknesh
> >>> this is a different Question...
>
> >>> @saurabh
> >>> how is nlgn possible, total no of possible substrings are n^2
>
> >>> this is the O(n^2) solutionOn Wed, Jul 27, 2011 at 8:09 AM, saurabh
> >>> singh
>
> >>> for(int l = 0; l < len; l++){
> >>>                 for(int i = 0; i < len-l; i++){
> >>>                         int j = i+l;
> >>>                         char temp = s[j+1];
> >>>                         s[j+1] = 0;
> >>>                         printf("%s\n", s+i);
> >>>                         s[j+1] = temp;
> >>>                 }
> >>>         }
>
> >>>  wrote:
>
> >>> > using suffix tree this can be done in o(nlogn) though will take
> >>> extra space.
>
> >>> > On Wed, Jul 27, 2011 at 12:47 AM, siva viknesh <
> >>> sivavikne...@gmail.com> wrote:
>
> >>> >>http://geeksforgeeks.org/?p=767
>
> >>> >> On Jul 26, 11:49 pm, Pratz mary  wrote:
> >>> >> > how?
>
> >>> >> > On 26 July 2011 23:18, ankit sambyal 
> >>> wrote:
>
> >>> >> > > @vivin : Suffix trees are memory intensive..
>
> >>> >> > > This problem can be solved just by running 2 nested loops in
> >>> O(1)
> >>> >> > > space and O(n^2) 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
> >>> >> > > algogeeks+unsubscr...@googlegroups.com.
> >>> >> > > For more options, visit this group at
> >>> >> > >http://groups.google.com/group/algogeeks?hl=en.
>
> >>> >> > --
> >>> >> > regards Pratima :)
>
> >>> >> --
> >>> >> 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.
>
> >>> > --
> >>> > Saurabh Singh
> >>> > B.Tech (Computer Science)
> >>> > MNNIT ALLAHABAD
>
> >>> > --
> >>> > 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 IV year,CSI
> >>> Indian Institute Of Technology,Roorkee
>
> >>> --
> >>> You received this message because

[algogeeks] Re: rotate a matrix NVIDIA question

2011-07-27 Thread amit karmakar
If you meant "rotate a 2D matrix by angle 180" of order n x n
Then you cannot have a O(n) algo, Each of the n^2 elements must be
accessed so you cannot have anything less than n^2

On Jul 27, 10:59 pm, Puneet Gautam  wrote:
> Can anyone give an O(n) solution pls...??
> I think the above code is an O(n^2) solution..
> if i am not wrong...!!!
>
> On 7/27/11, amit  wrote:
>
>
>
> > #include 
> > #include 
> > using namespace std;
>
> > const int MX = 1000;
> > int n, m;
> > int a[MX][MX];
>
> > int main() {
> >     scanf("%d%d", &n, &m);
> >     for(int i = 0; i < n; i++)
> >         for(int j = 0; j < m; j++)
> >             scanf("%d", &a[i][j]);
>
> >     for(int i = 0; i < n/2; i++)
> >         for(int j = 0; j < m; j++)
> >             swap(a[i][j], a[n-i-1][m-j-1]);
> >     if(n&1)
> >         for(int j = 0; j < m/2; j++)
> >             swap(a[n/2][j], a[n/2][m-j-1]);
>
> >     for(int i = 0; i < n; i++) {
> >         for(int j = 0; j < m; j++)
> >             printf("%d ", a[i][j]);
> >         printf("\n");
> >     }
> > }
>
> > On Jul 27, 7:54 pm, Anika Jain  wrote:
> >> is it lyk for {1,2,3
> >>                    4,5,6,
> >>                    7,8,9}
> >> to be {3,2,1,
> >>          6,5,4,
> >>          9,8,7}    ??
>
> >> On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan  wrote:
> >> > rotate a 2D matrix by angle 180
>
> >> > --
> >> > **With Regards
> >> > Deoki Nandan Vishwakarma
>
> >> > *
> >> > *
>
> >> >  --
> >> > 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] Re: Xplain the C code

2011-07-27 Thread amit
>> char a[3]="mnnitald";
"mnnitald" is string literal and causes allocation of static storage.
char a[3] leads to allocation of memory where first three characters
of mnnitald are copied
a[3] doesn't include the terminating character for a string.
which means strlen has to read beyond the bounds of array a and hence
you get random answers.

On Jul 27, 9:08 pm, Shantanu Sachdev  wrote:
> #include
> #include
> int main()
> {
>         char a[3]="mnnitald";
>         int x=strlen(a);
>         printf("%d",x);
>
> }
>
> Plz xplain the output of this program. x comes out to be 7. if  u take
> a[2],den it comes to be 6 nd so on.and if a[7] is taken, size comes out to
> be 10.
>  Compiler - GCC.
> --
> SHANTANU SACHDEV
> 20098080
> MNNIT ALLAHABAD

-- 
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: sizeof() question.

2011-07-27 Thread amit
>> if you write sizeof(main()) or sizeof(&main)...you will get 4 which will be
>> the size of a pointer

sizeof(main()) and sizeof(&main) are different.

sizeof(main()) is equivalent to sizeof( return type of main )
while sizeof(&main) is sizeof( function pointer )

On Jul 27, 9:02 pm, Abhinav Arora  wrote:
> The *sizeof* operator cannot be used with the following operands:
>
>    - Functions. (However, *sizeof* can be applied to pointers to functions.)
>    - Bit fields.
>    - Undefined classes.
>    - The type *void*.
>    - Dynamically allocated arrays.
>    - External arrays.
>    - Incomplete types.
>    - Parenthesized names of incomplete types
>
> so when you use mainits the name of a function and not pointerin
> this case we get an implementational dependent unsigned integer which can be
> 1 too...
> if you write sizeof(main()) or sizeof(&main)...you will get 4 which will be
> the size of a pointer
>
>    -

-- 
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: Re : [algogeeks] sizeof() question.

2011-07-27 Thread amit karmakar
>> sizeof(main()) == sizeof(int) because main return integer.
But main isn't invoked, sizeof does all thing at compile time.

On Wed, Jul 27, 2011 at 9:27 PM, Charlotte Swazki
wrote:

> No. it's wrong.
>
> sizeof(main()) == sizeof(int) because main return integer.
>
> i
>
>
>
> - Mail original -
> De : Vishal Thanki 
> À : algogeeks@googlegroups.com
> Cc :
> Envoyé le : Mercredi 27 Juillet 2011 15h45
> Objet : Re: [algogeeks] sizeof() question.
>
> I am not sure about the first question, but if you use sizeof(main()),
> it gives the ans 4.
> vishal@ubuntu:~/progs/c\ 09:12:57 PM >$ cat alg.c
> #include
> int main()
> {
> printf("%d\n",sizeof(main()));
> return 0;
> }
> vishal@ubuntu:~/progs/c\ 09:13:00 PM >$ gcc alg.c
> vishal@ubuntu:~/progs/c\ 09:13:02 PM >$ ./a.out
> 4
> vishal@ubuntu:~/progs/c\ 09:13:03 PM >$
>
>
> The reason why it doesn't overflow is because sizeof() operator
> calculates the size at compile time, and it doesn't really invoke
> main().
>
> Vishal
>
> On Wed, Jul 27, 2011 at 9:02 PM, Charlotte Swazki
>  wrote:
> > Hi there,
> >
> > I have two questions,
> >
> > Why sizeof(main) == 1 ? (sizeof(func) == 1).
> > Not 4 bytes ?.sizeof(void) == 1 too.
> >
> >
> > And this code doesn't stackoverflow ?
> > int main() {
> >
> >  sizeof(main());
> > }
> >
> >
> >
> > Thanks,
> >
> > --
> > 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.
>
>

-- 
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: OUTPUT

2011-07-27 Thread amit
Hmm, I don't get the question.
>> how to dynamically allocate memory for int *a[3]; ?
What do you mean by allocating memory for int *a[3];
Can you explain in some more details what exactly you want to do

On Jul 27, 8:39 pm, Kamakshii Aggarwal  wrote:
> i am not getting any of the ways..can u explain?
>
> On Wed, Jul 27, 2011 at 9:06 PM, Abhinav Arora 
> wrote:
>
>
>
>
>
> > I believe the method written is incorrect, it didnt work for me
> > i guess this is the right way...worked for me:
>
> > int **p;
> > p=malloc(3*sizeof(int *));
>
> > --
> > 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/-/ATGevOaqMbUJ.
>
> > 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,
> Kamakshi
> kamakshi...@gmail.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 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: rotate a matrix NVIDIA question

2011-07-27 Thread amit
#include 
#include 
using namespace std;

const int MX = 1000;
int n, m;
int a[MX][MX];

int main() {
scanf("%d%d", &n, &m);
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
scanf("%d", &a[i][j]);

for(int i = 0; i < n/2; i++)
for(int j = 0; j < m; j++)
swap(a[i][j], a[n-i-1][m-j-1]);
if(n&1)
for(int j = 0; j < m/2; j++)
swap(a[n/2][j], a[n/2][m-j-1]);

for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++)
printf("%d ", a[i][j]);
printf("\n");
}
}


On Jul 27, 7:54 pm, Anika Jain  wrote:
> is it lyk for {1,2,3
>                    4,5,6,
>                    7,8,9}
> to be {3,2,1,
>          6,5,4,
>          9,8,7}    ??
>
>
>
> On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan  wrote:
> > rotate a 2D matrix by angle 180
>
> > --
> > **With Regards
> > Deoki Nandan Vishwakarma
>
> > *
> > *
>
> >  --
> > 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] Re: Permutations in a string

2011-07-27 Thread amit
#include 
#include 
using namespace std;

const int MX = 1000;

int n, k;
char str[MX], partial[MX];

void solve(int pos, int aux) {
if(aux==k) {
partial[aux] = 0;
printf("%s\n", partial);
return;
}

for(int i = pos; i < n; i++) {
partial[aux] = str[i];
solve(i+1, aux+1);
}
}

int main() {
scanf("%s", str);
scanf("%d", &k);
n = strlen(str);
solve(0, 0);
}


On Jul 27, 7:49 pm, Rajeev Kumar  wrote:
> One more thread is running parallel on the same topic
> Please refer :http://comments.gmane.org/gmane.comp.programming.algogeeks/17279
>
> On Wed, Jul 27, 2011 at 7:39 AM, Nikhil Gupta 
> wrote:
>
>
>
>
>
> > Given a string of length 5 (example "abcde"), write a program to print all
> > the possible combinations OF LENGTH 3.
>
> > In this case : abc, abd, abe, acd, ace, ade, bcd, bce, bde, cde
>
> > Can someone provide a working code?
>
> > --
> > Nikhil Gupta
> > Senior Co-ordinator, Publicity
> > CSI, NSIT Students' Branch
> > NSIT, New Delhi, India
>
> >  --
> > 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.
>
> --
> Thank You
> Rajeev 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.



[algogeeks] Re: C output 2

2011-07-27 Thread amit
"hello" is a string literal and this is what the C standard says about
string literals:

>> The multibyte character sequence is then used to initialize an array of 
>> static storage duration and length just
>> sufficient to contain the sequence.

So memory will remain reserved for "hello" for the entire lifetime of
program.
Your program invokes undefined behavior because it causes a char
pointer to int conversion.

On Jul 27, 7:01 pm, Ankur Khurana  wrote:
> if i declare a string constant inside another function
> like let us say
> ,
> int how()
> {
>
> char *s="hello";
> return s;
>
> }
>
> so when how() get executed , the memory for hello will remain reserved or it
> can be allocated to others. Will it amount to memory leak ?
>
> --
> Ankur Khurana
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.

-- 
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: C Doubts

2011-07-17 Thread Amit
1. In C, you cannot assign to a variable which is const, but in C++,
there is a way to cast away constness of object/variable using
const_cast<>.

-- 
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: amazon

2011-07-14 Thread Amit Gupta
Just replace the 1's with { and 0's with }

-- 
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/-/H1GtxuX8Zq4J.
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: amazon

2011-07-14 Thread Amit Gupta
I think Nitish is right. The output shoud be as mentioned by Nitish. 
And the code for that 

#include
int n;
void f(int *,int,int,int);
int main()
{
scanf("%d",&n);
int arr[n];
f(arr,0,0,0);
getchar();
getchar();
return 0;
}

void f(int arr[], int open, int close, int index)
{
 if (close==n)
 {
 for (int i=0;ihttps://groups.google.com/d/msg/algogeeks/-/caAn1qhOpTUJ.
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: Adding w/o +

2011-07-13 Thread Amit Gupta
You can try this also

do
{
sum = a ^ b;
carry = a & b;
a = sum;
b = carry;
}while (carry!=0);

-- 
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/-/KoeFGWuM71IJ.
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] puzzle

2011-07-09 Thread amit the cool
6,24,60,120,_

-- 
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] puzzle

2011-07-09 Thread amit the cool
find d next:
91,110,134,_

-- 
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] Longest substring 0's & 1's

2011-07-06 Thread amit kumar
excellent solution sunny

On Tue, Jul 5, 2011 at 11:44 PM, amit kumar  wrote:

> #include
> #define n 11
> int main()
> {
> int ar[n]={1,0,1,1,1,0,0,0,0,0,1};
> int a[n][n];
> int l,i,k,maxlength=0,start,end;
> for(i=0;i {
> ar[i]==0?(a[i][i]=-1):(a[i][i]=1);
> }
> for(l=2;l<=n;l++)
> {
> for(i=0;i<=n-l;i++)
> {
> for(k=i;k {
> a[i][i+l-1]=a[i][k]+a[k+1][i+l-1];
> if(a[i][i+l-1]==0 && l>maxlength)
> {
> maxlength=l;
> start=i;
> end=i+l-1;
> }
> }
> }
> }
> printf("maxm length=%d\n",maxlength);
> for(i=start;i<=end;i++)
> printf("%d  ",ar[i]);
>
> }
>
> On Tue, Jul 5, 2011 at 11:49 AM, Kunal Patil  wrote:
>
>> @Sunny : Excellent !!! Keep posting such nice solutions !! :)
>>
>>
>> On Sat, Jul 2, 2011 at 1:47 AM, Anika Jain wrote:
>>
>>> ohh ok i got it.. thanx :)
>>>
>>>
>>> On Sat, Jul 2, 2011 at 12:48 AM, sunny agrawal 
>>> wrote:
>>>
>>>> it is (2,4] not [2,4].
>>>> open interval, close interval . consider (i,j] as [i+1,j]
>>>>
>>>> because a[i] = sum of values from 0 to i
>>>> and a[j] = sum of values from 0 to j
>>>> if a[i] = a[j] then it means sum does not changes between a[i] to a[j]
>>>>
>>>> so from i+1 to j there are equal no of 1's and -1's
>>>> or in other words equal no of 0's and 1's
>>>>
>>>>
>>>> On Sat, Jul 2, 2011 at 12:42 AM, Anika Jain wrote:
>>>>
>>>>> @sunny: in a[2,4] has 2 1s and one 0 then how is it a solution? i mean
>>>>> i didnt get wen a[i]==a[j] then a[i,j] is a solution case..
>>>>>
>>>>> On Fri, Jul 1, 2011 at 4:13 PM, sunny agrawal >>>> > wrote:
>>>>>
>>>>>> Take an array of size of the length of the string.
>>>>>> fill the array positions with one where string contains 1, and -1
>>>>>> where it is 0
>>>>>>
>>>>>> Now for each i (1,n-1) perform the following operation
>>>>>> a[i] = a[i-1] + a[i]
>>>>>> now a[i] will contains sum of values from a[0] to a[i] in original
>>>>>> array.
>>>>>>
>>>>>> Now only thing remains to find is two indexes in this array such that
>>>>>> a[i] = a[j]
>>>>>> where ever this condition is met ( i,j ] is a solution
>>>>>>
>>>>>> or if for some i a[i] = 0 in this case [0,i] will be a solution
>>>>>>
>>>>>> this can be done using hashing
>>>>>> hash the values in the array of size 2*n+1. as range of values is -n
>>>>>> to n and keep track of max interval.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Jul 1, 2011 at 3:22 PM, Anantha Krishnan <
>>>>>> ananthakrishnan@gmail.com> wrote:
>>>>>>
>>>>>>> Given a string containing 0's and 1's. One would need to find the
>>>>>>> longest sub-string such that the count of 0's is equal to the count of 
>>>>>>> 1's
>>>>>>> in the largest sub string.
>>>>>>>
>>>>>>> Regards
>>>>>>> Anantha Krishnan
>>>>>>>
>>>>>>> --
>>>>>>> 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 IV year,CSI
>>>>>> Indian Institute Of Technology,Roorkee
>>>>>>
>>>>>>
>>>>>>  --
>>>>&g

Re: [algogeeks] puzzle

2011-07-06 Thread amit kumar
thanx guys

On Wed, Jul 6, 2011 at 2:40 PM, udit sharma  wrote:

> (5*5)+(!5)/(5+5) and (((5+5)/5)^5)+5
>
> --
> Regards
>  UDIT
>  DU- MCA
>
>  --
> 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.



  1   2   3   4   >