without priority queue its .08 and with priority queue its .0.00
--
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+unsubsc
0.00 with priority_queue stl for me :)
On Thu, Jun 16, 2011 at 10:55 AM, Kunal Yadav wrote:
> Whats ur running time. Mine is 0.05 without using priority queque.
>
>
> On Wed, Jun 15, 2011 at 8:24 PM, kartik sachan wrote:
>
>> ya dude finally i applied that algo only
>>
>> --
>> You received this
Whats ur running time. Mine is 0.05 without using priority queque.
On Wed, Jun 15, 2011 at 8:24 PM, kartik sachan wrote:
> ya dude finally i applied that algo only
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this grou
Hello
I have been thinking if I can use asm in c programs to enhance my time...
So to give it a try i tried http://www.spoj.pl/problems/STREETR/
with the following code:
#include
int gcd( int a, int b ) {
int result ;
__asm__ __volatile__ ( "movl %1, %%eax;"
"movl
t,m;f(n){return n<=2?1:f(n-1)+f(n-2);}
main(){scanf("%d",&t);while(t--)scanf("%d",&m)&&printf("%d\n",f(m+11)-f(m+1)+f(6+m)%10));}
My best attempt with the c code..132 bytes still
Now gonna try perlIt definitely requires exceptional skills to bring it
down to 111 bytes but have this gut
It's ok..
char *p="hai friends"...not correct
bcz you did allocate memory for that string but assiging poiter to the base
address.. from where gcc will get the bse address of that string when u r
not actually allocate memory for it? thus it generate SIGSEG signal and give
invalid memory addre
Gives me a SEGFAULT on gcc.
Probably due to undefined behaviour.
--
DK
http://twitter.com/divyekapoor
http://www.divye.in
--
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/
Really really sorry for polluting this thread, but there's small issue in
that analysis:
The cost O(N) is in terms of reverse operations executed (that is swaps) and
not in terms of the number of comparisons. The number of comparisons remain
O(N log N) but the maximum number of swaps is O(N) whi
Oops, there's a bug in my analysis! the sort complexity is even better at
O(N) :)
If you're doing K merges of subarrays of size O( N / K ) (which is the
worst case for this algo due to the merge cost of O(min{N, M}) ) using the
reverse operation you've supplied, the result is an O(N) sort inst
On a closer look, you can clearly see that as per my approach to the
problem, I have defined something similar to the swap(i, j) operator.
Given this operator, you can implement any O(n log n) sort that you desire.
swap(i, j) = reverse(i + 1, j), reverse(i, i + 1), reverse(i+1, j)
Have fun imple
Everyone here's mentioned O(n^2) Pancake sorting. Here's a solution in O(n
log n)
A run is defined as a sequence of consecutive values in the array.
1. Go through the array and reverse descending runs - O(n) as reverse(i, j)
is supplied. Now you have an array with many runs in ascending order.
main()
{
char *p="hai friends",*p1;
p1=p;
while(*p!='\0') ++*p++;
printf("%s %s",p,p1);
}
--
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 em
problem:::
https://www.spoj.pl/problems/FIBSUM/
can anyone suggest idea to reduce my code to 111 byte..its currebt size is
about 174
int a[50]={0},t,m;
f(int n) { return a[n]=a[n]?a[n]:n<=2?1:f(n-1)+f(n-2); }
main() {
scanf("%d",&t);
while(t--)
{ scanf("%d",&m) ;
printf("%d\n",(f(m+11)-f(m+1)+f
There are only 2 types of heaps in this problem:
1. Optional heaps -> have > 1 coins
2. Non-optional heaps -> have = 1 coins
Start from the rightmost heap.
This is base case - whoever gets this heap surely wins.
Look at the heaps before it.
If it is a non-optional heap (1 element only), then the
+1 guys.
The first thing you should do is send a warning mail to the Job spammers on
the group and kick them out if they send another spam mail. :)
Best of luck and keep the forum rocking! :)
--
DK
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks
The behaviour of allowing the following code to compile:
cin >> x;
int a[x];
by gcc/g++ is due to historical reasons. This kind of a declaration is
called a variable length array however it is not supported by the C++ and C
standards.
To prove that this is the case, recompile with
g++ -pedant
Hello Associate,
Hope you are doing well!
Please go through the below requirement and let me know if you have any Java
Developer local to MA for the below position?
Job Title: Java Developer
Location: Cambridge, MA
Duration: 3-6 Months
Rate: $50
Gotta have 7 yrs Java, and strong Linux and SQL e
Hello Associate,
Hope you are doing well!
Please go through the below requirement and let me know if you have any
Siebel Developer local to FL for the below position?
Job Title: Siebel Developer
Location: Jacksonville, FL
Duration: 3 Months
Rate: $50/hr
Qualifications: We need three people who h
code blocks
On Jun 15, 9:05 pm, shashankreddy509
wrote:
> Thanks alot
> for the response.
--
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
@jeeva ... rather we can say that that the mathematician made a dot (circle
of zero radius) and declared everything inside the circle (point) outside
the fence :)
On Wed, Jun 15, 2011 at 6:41 PM, subramania jeeva wrote:
> The mathematician made a small fence around himself and declared hims
@Raghavan
if you want to fing the shortest path from a node u to v then its better to
use BFS
but according to your second post it seems you want to find path from root
node to a leaf, in that case DFS seems to be best
On Wed, Jun 15, 2011 at 9:56 PM, bittu wrote:
> I think BFS will do That isn
I think BFS will do That isn't it.?? lets say we have starting node
v & wants to find shortest path e.g leaf at lowest height say this
node u so when you will do BFS each level will represent the shortest
path between two nodes. shortest path=min dist(V,U)
DS Used Queue
Time Complexity O(N)
Co
Thanks alot
for the response.
--
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/-/302D7BLEHOAJ.
To post to this group, send email to algogeeks@googlegroups.com.
EkoPath compiler has been open sourced
recently: http://www.pathscale.com/ekopath-compiler-suite
--
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/-/j07rEcpBsq
i need compiler for windows 7...
--
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/-/Y9OZdeYwmggJ.
To post to this group, send email to algogeeks@googlegroups.c
@ ross yes its pancake sorting,although i have code using insertion
sort O(N^2) , we can use quick sort to achieve O(nlogn)
click here
http://shashank7s.blogspot.com/2011/03/pancake-sorting.html
Feel Free to Comment
Thanks
Shashank
CSE,BIT Mesra
--
You received this message because you are subs
intel icc compiler
On Wed, Jun 15, 2011 at 08:20:39AM -0700, shashankreddy509 wrote:
> can any one tell the best compiler for c and c++...
>
>
> Thanks,
> G. Shashank Reddy
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
>
In windows you can choose codeblocks or best is use linux gnu compiler
On Wed, Jun 15, 2011 at 8:50 PM, shashankreddy509 <
shashankreddy...@gmail.com> wrote:
> can any one tell the best compiler for c and c++...
>
>
> Thanks,
> G. Shashank Reddy
>
> --
> You received this message because you are
can any one tell the best compiler for c and c++...
Thanks,
G. Shashank Reddy
--
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/-/g2ZE6Sm9p-MJ.
To post to thi
ya dude finally i applied that algo only
--
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.
F
This q increased my score by directly 3 points... and thats a huge
one.. :D
@ kartik - Do it by priorty queue for better efficiency..
--
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.
i think it can be done by counting the no of starting heaps with 1 coins in
it before any heap with coin>1 in it. if all the heaps have only one coin
that player1 win if heap%2==1
if there is any heap with >1 then player1 win if (starting heap with 1 coin
in them)%2==0.
eg
player 1 win in case 1 of
Lets say:
Player1 picking first.
x : number of continuous heaps which contains only one coin at the start.
Ex.
1,2,3,1,4 (x = 1)
1,1,2,3 (x = 2)
2,1,3,4,5 ( x= 0)
case 1: x is even ( Player1 wins)
case 2: x is odd (Player2 wins)
correct me if i am wrong
On 15 June 2011 19:10, L wrote:
> T
Thanks Harshal!!
Actually changing juzz count from int to long long suffices
--
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
a
that's floating point for you.
http://en.wikipedia.org/wiki/Floating_point
--
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/-/RcduUpABmi8J.
To post to this gr
i have checked the code in broland 4.5..
i have changed some code and checked ...
int main()
{
*float a=275.6;*
printf("%.10f\n",a);//prints 275.7000122070 WHY???
if(275.7>a)
printf("Hi");
else
printf("Hello");
return 0;
}
output is 275.661035
and also look at this one as well..
int m
The ordering of coins matter for this problem.
For ex.
1 2 and 2 1 have different results.
So, i don't think that there would be a direct formula for this
problem.
We will have to traverse all the heaps of coins determining whether
the current player is in winning or losing position.
On Jun 15, 6:
yep true.
The difficult part is trying to find when Player 1 can win with heaps of
size 1.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 6:59 PM, sunny agrawal wrote:
> i think solution depends on no of heaps having single coin
> if there are even number of such heaps player 1 will win
> if there ar
no that also wont work
n=2
3,1
On Wed, Jun 15, 2011 at 6:59 PM, sunny agrawal wrote:
> i think solution depends on no of heaps having single coin
> if there are even number of such heaps player 1 will win
> if there are odd number of such heaps player 2 will win
>
>
> On Wed, Jun 15, 2011 at 6:49
i think solution depends on no of heaps having single coin
if there are even number of such heaps player 1 will win
if there are odd number of such heaps player 2 will win
On Wed, Jun 15, 2011 at 6:49 PM, Nitish Garg wrote:
> Player 1 can still win in this case: Player 1 can take 1 from the firs
Player 1 can still win in this case: Player 1 can take 1 from the first heap
forcing Player 2 to take the remaining 1. Then Player 1 can take the 2 coins
from the second heap and win.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view
@Nitish
n=2
heap 1 = 2
heap 2 = 3
Xor = 1
still player one can win :)
On Wed, Jun 15, 2011 at 6:49 PM, sunny agrawal wrote:
> @immanuel
> ohh, i read the Question wrong. :(
> i was thinking player1 is starting from least numbered heap and player 2
> from highest no heap
>
>
>
> On Wed, Jun 15,
@Nitish,
I think it fails for this condition
4 heaps with 1,2,1,2
Player 1 starts first with picking 1 coin from heap 1
Player 2 picks 2 coins from heap 2
Player 1 picks 1 coin from heap 3
Player 2 picks 2 coins from heap 4.
Player 2 wins but XOR of the number of coins in each heap is 0(if that
@immanuel
ohh, i read the Question wrong. :(
i was thinking player1 is starting from least numbered heap and player 2
from highest no heap
On Wed, Jun 15, 2011 at 6:36 PM, immanuel kingston <
kingston.imman...@gmail.com> wrote:
> Player 1 will take 1 coin from heap 1
> Player 2 has to take th
I think that when the XOR of all the coins is zero Player 1 can always win.
--
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/-/EQtViYQFACMJ.
To post to this gr
Player 1 will take 1 coin from heap 1
Player 2 has to take the other coin from heap1.
Player 1 will take both the coins in heap 2.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 6:33 PM, sunny agrawal wrote:
> check out this case
> n = 2
> both heaps having 2 coins
> player 2 will win i think
>
>
>
The mathematician made a small fence around himself and declared himself to
be on the outside the fence... :-)
Cheers
~ Jeeva ~
On Wed, Jun 15, 2011 at 5:40 PM, amit kumar wrote:
> @anika jain: will u plz xplain??
>
>
> On Wed, Jun 15, 2011 at 4:02 PM, Anika Jain wrote:
>
>> ea
check out this case
n = 2
both heaps having 2 coins
player 2 will win i think
On Wed, Jun 15, 2011 at 6:26 PM, immanuel kingston <
kingston.imman...@gmail.com> wrote:
> Yes. I am wrong. As per the example, Player 2 will win if he plays
> efficiently.
>
> Let me put my solution this way,
>
> If al
Yes. I am wrong. As per the example, Player 2 will win if he plays
efficiently.
Let me put my solution this way,
If all the the heaps are of size > 1 the Player 1 can win always.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 5:36 PM, sunny agrawal wrote:
> consider the case.
> n = 2;
> heap 1 -> no
we can even add word completion :)
On Wed, Jun 15, 2011 at 5:25 PM, immanuel kingston <
kingston.imman...@gmail.com> wrote:
> Use a trie data structure and pre-load it with all the words of a
> dictionary.
>
> Thanks,
> Immanuel
>
>
>
> On Wed, Jun 15, 2011 at 3:06 PM, Piyush Sinha wrote:
>
>> *H
The following is for LCA for 2 nodes in a n-ary tree.
A more tougher problem is to find the LCA for n nodes in the same n-ary
tree.
Node * findLCA (Node *root, Node * l, Node * r, int n) {
if (l == null || r == null) return root;
if (root == null) return null;
if (isChild(root,l) || i
@anika jain: will u plz xplain??
On Wed, Jun 15, 2011 at 4:02 PM, Anika Jain wrote:
> earth is a sphere i.e consisiting of infinite circles.. so mathematician
> had put the fence around that circle of the sphere where fence's length is
> equal to the circle's perimeter.
>
>
> On Wed, Jun 15, 201
consider the case.
n = 2;
heap 1 -> no of coins 1
heap 2 -> no of coins 2
On Wed, Jun 15, 2011 at 5:34 PM, sunny agrawal wrote:
> i think u r wrong
> what if heap size -1 is 0
> i think one should pick atleast one coin else game will draw
>
>
> On Wed, Jun 15, 2011 at 5:17 PM, immanuel kingst
i think u r wrong
what if heap size -1 is 0
i think one should pick atleast one coin else game will draw
On Wed, Jun 15, 2011 at 5:17 PM, immanuel kingston <
kingston.imman...@gmail.com> wrote:
> First Player can always win.
>
> For each heap
>Pick heap-size - 1 coins if this is not the n
Use a trie data structure and pre-load it with all the words of a
dictionary.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 3:06 PM, Piyush Sinha wrote:
> *How will you design a SpellChecker for an e-mail application?*
>
>
> --
> *Piyush Sinha*
> *IIIT, Allahabad*
> *+91-8792136657*
> *+91-748312272
First Player can always win.
For each heap
Pick heap-size - 1 coins if this is not the n-1th heap
Pick all coins from the heap if this the n-1th heap.
Please correct me if i am wrong.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 3:13 PM, Piyush Sinha wrote:
> *There are n heaps of coin(numbe
There is a tree which denotes 4 directions,
Node direction{
direction *side1,*side2,*side3,*side4;
};
makeTree(){
direction *tree;
getdirection(tree,1);
getdirection(tree->right,2);
getdirection(tree->left,1);
/*
how to form such a tree
root
side1 side2
side3 side4 side
earth is a sphere i.e consisiting of infinite circles.. so mathematician had
put the fence around that circle of the sphere where fence's length is equal
to the circle's perimeter.
On Wed, Jun 15, 2011 at 12:44 PM, Lavesh Rawat wrote:
> Engineer Physicist Mathematician puzzle - 15 june *
> * ***
Its from stack. Using int a[n] the amount of memory that can be allocated is
very small as compared to that in case of using malloc( heap allocation ).
On Wed, Jun 15, 2011 at 2:45 PM, sunny agrawal wrote:
> @kartik sachan
> This function is *not* defined in ANSI-C and is *not* part of C++, but i
Hello friends I am thinking of a combinatorics solution to this
problem on spoj but cant come up wd a formula please suggest me some
technique to solve this problem
http://www.spoj.pl/problems/CHAIR/
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks"
*There are n heaps of coin(numbered from 0 to n-1) with atleast 1 coin in
each heap. There are 2 players. First player can pick any no. of coins from
the least numbered heap, then the second player can pick any no. of coins
from the least numbered heap. Unless it is emptied, the player cant move on
*How will you design a SpellChecker for an e-mail application?*
--
*Piyush Sinha*
*IIIT, Allahabad*
*+91-8792136657*
*+91-7483122727*
*https://www.facebook.com/profile.php?id=10655377926 *
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group
*A preorder of a complete binary tree is given , prints its level order*
--
*Piyush Sinha*
*IIIT, Allahabad*
*+91-8792136657*
*+91-7483122727*
*https://www.facebook.com/profile.php?id=10655377926 *
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geek
WAP to find the LCA in a n-ary tree.
--
*Piyush Sinha*
*IIIT, Allahabad*
*+91-8792136657*
*+91-7483122727*
*https://www.facebook.com/profile.php?id=10655377926 *
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, sen
Absolutely..
Personal comments should be completely banned. And its matter of
shame for people who think that they are serving the nation by
abusing others.
On Jun 13, 5:29 pm, Umer Farooq wrote:
> +1
>
> I really like this group ... but sometimes people get rude and
> show prejudice attitude to
@kartik sachan
This function is *not* defined in ANSI-C and is *not* part of C++, but is
supported by some compilers.
and +1 to Shachindra's post...i also think memory allocation will be
from heap...not stack
On Wed, Jun 15, 2011 at 2:34 PM, Shachindra A C wrote:
> @vipul : dynamic memory al
hi guys,
Regarding the issue of new moderators I have decided to make
1)wladimirufc
2)nishanth
3)siva viknesh
as the new moderators..They will assist me to maintain the forum better.
I hope they discharge their responsibility in maintaining the dignity of the
forum...
@all: Please assist them in
@vipul : dynamic memory allocation from stack? are you sure? generally
dynamic memory allocations are done from the heap right?
On Wed, Jun 15, 2011 at 2:28 PM, kartik sachan wrote:
> hey is itoa() is supported by g++ compliers???
>
> --
> You received this message because you are subscribed to
hey is itoa() is supported by g++ compliers???
--
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.
//Prog 1
#include
int main()
{
float a=75.7;
printf("%.10f\n",a); //prints 75.669482
if(75.7>a)
printf("Hi");
else
printf("Hello");
return 0;
}
//Prog 2
#include
int main()
{
float a=275.7;
printf("%.10f\n",a);//prints 275.7000122070 *WHY???*
if(275.7>a)
printf("Hi");
else
prin
AC:
#include
#include
#include
#include
using namespace std;
void MergeSort(vector& v, long p, long r);
void Merge(vector &v, long p, long q, long r);
void PrintArray(vector v);
long long int count;
int main()
{
extern long long int count;
long n, i, t;
vector v;
//freopen("input.t
Thanks dude!!
--
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
72 matches
Mail list logo