@Balaji : By using Dave's algo it gives TLE and it should be ...try taking n
as large as 10^18. How did u reduce the no. of iterations in this case
??
On Mon, May 23, 2011 at 9:07 PM, Balaji S balaji.ceg...@gmail.com wrote:
@Dave: nice idea.. ll this give AC ?
--
You received this
--
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
#define MAX_BITS_FOR_INT=32;
int getIthBit(int n, int i) {
return (n 1i) i;
}
bool isPalindrome(int num) {
int i=0;
int j= MAX_BITS_FOR_INT - 1;
while (i j) {
int ithbit = getIthBit(num, i);
int jthbit = getIthBit(num, j);
if ( ithbit ^ jthbit)
@Dave,Balaji,Samby.. Without the matrix exponentiation, the time is not
possible, and without using the intermediate modulo operater as suggested by
Dave, the value cannot be accommodated, as the 300th fibinocci number alone
comes to
--
Ball Hole science puzzle SOLUTION
* *
**
*Your last good ping-pong ball fell down into a narrow metal pipe imbedded
in concrete one foot deep.How can you get it out undamaged, if all the tools
you have are your tennis paddle, your shoe-laces, and your plastic water
bottle, which does not fit into
@immanuelthe question doesn't require you to check with the whole
32 bit number...
For example, taking 10's binary representation as 1010...according to
question it wil be a palindrome...but according to ur algo it will
return false...
On 5/24/11, immanuel kingston
@Piyush, yes true. and thanks for the clarification.
int getIthBit(int n, int i) {
return (n 1i) i;
}
bool isPalindrome(int num) {
int i=0;
int j= MAX_BITS_FOR_INT - 1;
*while(getIthBit(num, j)) j--;*
while (i j) {
int ithbit = getIthBit(num, i);
It's done. Today I tried it.
Simply for N=0 and N=1 answer is (0,0) = 0 and (1,1)=2 respectively.
For other cases, you can get the solution with fib(N+3). Starting fib(1) =
1, fib(2) = 1...
Matrix Exponentiation, and Modulus for given constraints are necessary to
pass the solution.
On Mon,
@aakash
the cases are clear but can you explain how you did the matrix
exponentiation part ??..explain plz...i'm not getting it...
On Tue, May 24, 2011 at 1:25 AM, Aakash Johari aakashj@gmail.comwrote:
It's done. Today I tried it.
Simply for N=0 and N=1 answer is (0,0) = 0 and (1,1)=2
correct me if I am wrong.
String convertFloatToBinary(float num) {
String str = ;
int numBeforeDecimal = (int)num;
float decimalPart = num - (float)numBeforeDecimal;
int sign=1;
if (numBeforeDecimal 0 ) sign = -1;
if (sign 0) str[str.length] = '-';
An intense study of asm is not requiredchek ds out
http://www.codeproject.com/KB/cpp/edujini_inline_asm.aspx if its of any
help..
On Tue, May 24, 2011 at 3:14 PM, Dumanshu duman...@gmail.com wrote:
hmm... so i need to think purely from C's point and not from asm or do
i need to
Hi don ..We can Approach Like this this..See we can assume earth as a
Sphere there n points lies on that sphere so if any points lie on
that it must satisfy equation of sphere. okk.. then find the distance
of all the points from the center of sphere find the distance of
location form center .
Two Step Process:
1) Finding the distance to every point for the requestion point
2) Finding the min among those.
(n+n) -- O(n).
I think it cannot be this simple.. more inputs please...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
@sravanreddy001
u r not at plain surface its sphere :P :D. u have to go by angle
--
Anshuman Mishra
IIIT Allahabad
-
anshumishra6...@gmail.com
rit2007...@iiita.ac.in
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
I think that calculating the three Dimentional distance should be fine
right?
The distance between two points on the sphere will be proportional to the
chord connecting them.
Which is nothing but the three dimentional distance. and then going with the
2nd step of finding the min, value among
@sravanreddy001
no u will go from point A to point B by walking on the surface not by making
the tunnel in the earth.
--
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
yeah...sravan is absolutely rite. Assuming makin a tunnel wont affect affect
d result as far as finding relative closeness is needed.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Mind it...its given the database stores latitude and longitudes...We
need to devise a formula that calculates distances between two points
based on latitudes and longitudes of two points..HOW CAN U FIND CHORD
LENGTHS BASED ON LATITUDES AND LONGITUDES
On 5/24/11, bhavana bhavana@gmail.com
The input number is n. Find the closest Fibonacci series number i where i n.
Show the time complexity of the problem.
For eg : if n = 10, the output i should be 8
--
*Piyush Sinha*
*IIIT, Allahabad*
*+91-8792136657*
*+91-7483122727*
*https://www.facebook.com/profile.php?id=10655377926 *
--
@piyush
suppose A is latitude
nd B is longitude, R is raduis of earth
z = Rsin(A);
r' = Rcos(A); radius of circle at z height;
x = r'cos(B);
y = r'sin(B);
(x,y,z) is coordinate of point assuming (0,0,0) is the center of earth;
--
You received this message because you are
click on this link and register . it will take less than half a minute
and you will really help me a lot
http://www.earnparttimejobs.com/index.php?id=3407956
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Dear Professional,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*
Please reply at
Dear Professional,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*
Please reply at
@Anyone worked on this before?
I'm thinking of a time complexity of *(log N)^2 -- Square of (log N)*
I've to prove on this..
If someone have time.. can you *prove that, the T'th fibinocci number is
always greater than 'N'*
*where T = (log N)^2 *
--
You received this message because you
what about precomputation and then binary search...?
On Tue, May 24, 2011 at 6:37 AM, sravanreddy001 sravanreddy...@gmail.comwrote:
@Anyone worked on this before?
I'm thinking of a time complexity of *(log N)^2 -- Square of (log N)*
I've to prove on this..
If someone have time.. can you
@anshu.. I wanted to say to that.. even though I couldn't think of the
trignometic stuff..
thanks.. :)
--Sravan.
--
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
its equal to calculating the Fibonacci numbers till we get a number
which is closest to and lesser than N...anything better??
On 5/24/11, Aakash Johari aakashj@gmail.com wrote:
what about precomputation and then binary search...?
On Tue, May 24, 2011 at 6:37 AM, sravanreddy001
if u have many test cases, this approach is helpful.
On Tue, May 24, 2011 at 6:42 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
its equal to calculating the Fibonacci numbers till we get a number
which is closest to and lesser than N...anything better??
On 5/24/11, Aakash Johari
@sravan,
What i meant was get the jth digit in the representation of i to the base
NUM_PER_DIGIT. ie 3rd digit of (2137)8 which is 2.. 7 is the 0th digit, 3
being 1st digit, 1 being 2nd digit and 2 being 3rd digit.Here 2137 is a base
8 representation.
Thanks,
Immanuel
On Tue, May 24, 2011 at
yes, that depends on what limits u have been given. for the unknown one, i
ll have to think..
On Tue, May 24, 2011 at 6:48 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
@Aakash Sir...if it is so, can u elaborate ur logic??i mean what
should be maximum limit on the precomputation??
On
suppose its maximum limit is unsigned int onlythen u mean to say
we need to precompute till the maximum limit of unsigned which is
unnecessary taking up size if we give input say 50
On 5/24/11, Aakash Johari aakashj@gmail.com wrote:
yes, that depends on what limits u have been given. for
@all
it is simple binary search problem
we can write
f(n) = f(n/2 + 2)*f(n/2) + {f(n/2 + 1)}^2 if n is even similary u can get
formula when n is odd.
f(3), f(4), f(5) f(6)
f(6), f(7), f(8) f(12)
.
.
.
as soon as you got a fibnocci number greater than n suppose p-- than you
have two
@ps: no, suppose for given N testcases, get the maximum one, and generate
fibs greater than that. and then for others u can get with binary search
only,
u will have to improve the fib generator, so basically matrix expo, can
help. other way of doing this is described in above post.
On Tue, May
@Aakash Sir...can u clarify giving some exampleslike i give input
N=10,it should O/P 8if N=51,O/P=34
On 5/24/11, Aakash Johari aakashj@gmail.com wrote:
@ps: no, suppose for given N testcases, get the maximum one, and generate
fibs greater than that. and then for others u can get
@bittu: yes, this can be the way. just make ur fib generator faster(using
matrix expo.) for less complexity.
On Tue, May 24, 2011 at 7:33 AM, bittu shashank7andr...@gmail.com wrote:
@all geeks
I have already posted it 2-3 forums..here let me post it again its
O(n) but the basic idea is
@all geeks
I have already posted it 2-3 forums..here let me post it again its
O(n) but the basic idea is clear if got the problem stmt correct then
we have to find out the largest Fibonacci number that is small then
given number n so say if n=10 then should be 8
for n=13 i=8
n=14 i=13 similarly
U r using he same approach which I mentioned it before...I knew about
this approach but it sounded to me too naive solution...so I was
thinking whether there exists any shortcurt method/mathematical
formulae for it or not..
On 5/24/11, bittu shashank7andr...@gmail.com wrote:
@all geeks
I have
search OEIS.. and tell if you find something interesting :)
On Tue, May 24, 2011 at 7:37 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
U r using he same approach which I mentioned it before...I knew about
this approach but it sounded to me too naive solution...so I was
thinking whether
I'm more interested in finding a good data structure to store the
points so that it is quick to narrow down the search to the points
which are fairly close. Think of a database with millions of points,
and there is not time to compute a distance to each one.
Don
On May 24, 8:15 am,
@aakash...so above algo is fine working fine i forget to put else
stmt after if otherwise unnecessary comparison so
you can add if(finalc)then final=c
else break; in above program will post
O(logn) program soon
Thanks
Shashank
--
You received this message because
yes, as to my knowledge. there's a similar problem on SPOJ also. I can
remember that i solved that in similar way (with matrix expo.). If anyone
finds better way, please post here.
On Tue, May 24, 2011 at 8:02 AM, bittu shashank7andr...@gmail.com wrote:
@aakash...so above algo is fine working
int fibArray[INTEGER_MAX_VALUE] = {0};
int fibonacci (int n) {
if (n = 0) {
return 0;
} else if ( n 0 fibArray[n] != 0) {
return fibArray[n];
} else {
if (n == 1) return (fibArray[n] = 1);
return (fibArray[n] = fibonacci(n - 1) + fibonacci(n-2));
@piyuesh..i posted the naive because geeks are so confused about this
quest. i have seen some geeks saying terrible time complexity of it.
so above approach will make 1st of all every1clear optimization 2ndary
step...
As i have told earlier its similar to find nth Fibonacci number can
be done
Hello,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*Please reply at soh...@panzersolutions.com
*
Title
Dear Professional,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*Please reply at
Hello,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*Please reply at soh...@panzersolutions.com
*
Title
Its enough.. dont we have some moderator looking at this group??
Posting jobs on a group where we discuss about algorithm is a spam..
Moderator please block these kind of mails..
On Tue, May 24, 2011 at 7:23 PM, sohail.panzer8 sohail.panz...@gmail.comwrote:
Hello,
Hope you are doing well.
I
Hello,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*Please reply at soh...@panzersolutions.com
*
Title
Dear Professional,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*Please reply at
Ur algo's complexity will not be O(logn)..it will be O(nlogn)..
On 5/24/11, bittu shashank7andr...@gmail.com wrote:
@piyuesh..i posted the naive because geeks are so confused about this
quest. i have seen some geeks saying terrible time complexity of it.
so above approach will make 1st of all
Hello,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*
*
*Please reply at soh...@panzersolutions.com
*
Hello,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*
*
*Please reply at soh...@panzersolutions.com
*
@Piyush:
I don't think 1010 (and any even number) will be a binary palindrome (Unless
u allow single leading zero)...(Either you allow all or allow none)
If its not so what about 1001 then ? Whether it will be a palindrome or not
?[?]
Don't you think, it isn't possible to do this in less than
Fill the pipe with water so that the ball floats out.
Don
On May 24, 2:22 am, Lavesh Rawat lavesh.ra...@gmail.com wrote:
Ball Hole science puzzle SOLUTION
* *
**
*Your last good ping-pong ball fell down into a narrow metal pipe imbedded
in concrete one foot deep.How can you get it out
Hello,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
*
Please reply at soh...@panzersolutions.com
*
Title
Ignoring leading zeros in the number:
bool isPalindrome(int N)
{
int i = 0, j = N;
while(n)
{
i = (i 1) | (j 1);
j = 1;
}
return(i == N);
}
Dave
On May 23, 2:11 pm, Piyush Sinha ecstasy.piy...@gmail.com wrote:
Find whether the binary representation of a
If you are ignoring the leading zeros, no even number can be a palindrome.
hence we can ignore them and only will check for the odd ones.
#include stdio.h
int palindrome(int x)
{
int y = 0;
int temp = x;
if ( !(x % 2) )
return 0;
while (
Okay. That wouldn't change the order. But allowing any number of
leading zeros in the number:
bool isPalindrome(unsigned int N)
{
unsigned int i = 0, j = N;
while(n)
{
i = (i 1) | (j 1);
j = 1;
}
while(i N)
i = 1;
return(i == N);
}
Dave
On May
Hello,
Hope you are doing well.
I am a technical recruiter with Panzer Solutions LLC Software Implementing
and IT consulting company located in CT. Please go through the Job
Description and send me your updated resume with contact information.
Please reply at soh...@panzersolutions.com
Title
There is a class A which contains just one parameterized constructor
A(int a). How would you initialize an array of objects of this class.
--
**With Regards
Deoki Nandan Vishwakarma
IITR MCA
Mathematics Department*
*
--
You received this message because you are subscribed to the Google Groups
Hiii...can anyone tell me a better approach towards optimal stopping
problem(secretary problem) other than N/e strategy??
--
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
what is n in the while loop?
--
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
@Balaji: Oops. The n in the while(n) statements in my two algorithms
should both be j: while(j).
Dave
On May 24, 11:10 pm, Balaji S balaji.ceg...@gmail.com wrote:
what is n in the while loop?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
http://www.java2s.com/Tutorial/Cpp/0180__Class/Initializeanarrayofobjectsbyreferencingtheconstructordirectly.htm
http://www.java2s.com/Tutorial/Cpp/0180__Class/Initializeanarrayofobjectswithoutreferencingtheconstructordirectly.htm
Thanks,
Immanuel
On Wed, May 25, 2011 at 7:34 AM,
Answer pls.. ;-)
Class A
{
int a;
public:
A(int m = 0)
{
a = m;
}
int main()
{
int i = 0;
/*
Create the 32 Objects { nObjects[32] } of Class A
Initialize the nObjects[i].a = i during the constructor call ( 0 = i = 31
)
*/
}
--
With Regards,
Balaji.S
--
You received this message
This way you can do:
#include iostream
using namespace std;
class A {
public:
int a;
A(int m) {
a = m;
}
A() {
}
};
int main()
{
int i;
A *obj[32];
Use Demarau-Levenshtein for this purpose :)
On Tue, May 24, 2011 at 10:24 PM, Akshata Sharma
akshatasharm...@gmail.comwrote:
what changes should we make in the edit distance algorithm to include the
swapping of adjacent elements so as to get min edit distance?
eg. pantera can be converted
This way you can do:
#include iostream
using namespace std;
class A {
public:
int a;
A(int m) {
a = m;
}
A() {
}
};
int main()
{
int i;
A *obj[32];
for (
@Akash:
I have implemented Demarau-Levenshtein algorithm but for the eg. I gave
above, it outputs 5 instead of 4. For some inputs it is giving the correct
output.
I think the demarau-levenshtein algo is just:
if(I0 J0 s1[I]==s2[J-1] s1[I-1]==s2[J])
table[i][j] =
but
constructor is
A(int *m=0*)
{
a=m;
}
not
A*(int m*) {
a = m;
}
???
--
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
70 matches
Mail list logo