main()
{ int i=5;
printf(%d,fun(fun(fun(fun( fun(i));
}
void fun (int i)
{
if(i%2)
return (i+(7*4)-(5/2)+(2*2));
else
return (i+(17/5)-(34/15)+(5/2));
}
--
With Regards,
Balaji.S
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
@Dumanshu:
min dist: you will terminate the algo when atleast 2 of the lists have their
indices reached the end of their respective lists in the process.
On Sat, Jun 18, 2011 at 12:37 AM, Dumanshu duman...@gmail.com wrote:
@Harshal: your terminating condition would be -
lets say we have set the
compiler error?? if the void is replaced by int, ans=155.
On Sat, Jun 18, 2011 at 11:33 AM, Balaji S balaji.ceg...@gmail.com wrote:
main()
{ int i=5;
printf(%d,fun(fun(fun(fun( fun(i));
}
void fun (int i)
{
if(i%2)
return (i+(7*4)-(5/2)+(2*2));
else
return
@DK: absolutely..actually mutex is a kinda semaphore...and unlike
semaphores it does not have any list(of waiting processes) associated
with it and just is a kind of lock and key model with no waiting
Q.someone can say that they are Binary semaphore since binary
semaphore have only two values
Hi
*
*
*Puzzle Digest Of The Week 13th-June to 17th June*
*
*
*
http://dailybrainteaser.blogspot.com/2011/06/friday-13th-riddle.html?lavesh=lavesh
*
**
*
http://dailybrainteaser.blogspot.com/2011/06/number-trick-riddle.html?lavesh=lavesh
*
*
*
*
CONT1D and D1ONE already defined
When compile with -O2, gcc 4.3.2 tries to inline short functions like
gcd(). Thus the labels CONT1D and D1ONE get redefined.
1) Try gcc 4.0.3.
or 2) use local labels instead. eg.
__asm__ __volatile__ ( movl %1, %%eax;
0: cmpl
@kk : Your approach looks like o(n^2) and only o(n) is likely to pass TLE.
On Fri, Jun 17, 2011 at 5:38 PM, KK kunalkapadi...@gmail.com wrote:
http://www.spoj.pl/problems/MINMOVE/
This code is showing TLE after some 20th test case what else can be
optimized???
try:
import psyco
new and delete are functions available in C++ and not in C. m i right?
On Jun 17, 2:34 pm, rohit rajuljain...@gmail.com wrote:
how to free memory allocated to an array with new function?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
Yes SPOJ uses the nasm assembler.
On Jun 18, 7:02 am, saurabh singh saurab...@gmail.com wrote:
I am using standard gcc 4.3.2 and the code does not requires any flag to be
required.I also checked the alias if gcc has been aliased to be used with
some option,but that was not the case.My
you are right unless new and delete are operators rather than functions.
On Sat, Jun 18, 2011 at 4:54 PM, Dumanshu duman...@gmail.com wrote:
new and delete are functions available in C++ and not in C. m i right?
On Jun 17, 2:34 pm, rohit rajuljain...@gmail.com wrote:
how to free memory
In fact new and delete are not even technically functions,,,
On Sat, Jun 18, 2011 at 2:24 PM, Dumanshu duman...@gmail.com wrote:
new and delete are functions available in C++ and not in C. m i right?
On Jun 17, 2:34 pm, rohit rajuljain...@gmail.com wrote:
how to free memory allocated to an
sorry for needless words in the last letter.
On Sat, Jun 18, 2011 at 4:56 PM, oldman fenghaungyuyi...@gmail.com wrote:
you are right unless new and delete are operators rather than functions.
On Sat, Jun 18, 2011 at 4:54 PM, Dumanshu duman...@gmail.com wrote:
new and delete are functions
Came across this sort read in a blog.The author called it sleep sort...A
very funny implementation of radix sort I think.?
#!/bin/bash
function f() {
sleep $(echo $1 / 10 |bc -l)
echo $1
}
while [ -n $1 ]
do
f $1
shift
done
wait
--
Saurabh Singh
B.Tech (Computer Science)
@DK: So u mean to say that Mutex and binary semaphores provide
completely same functionality. Right?
Say u have a resource R and u can provide access to this particular
only one at a time (lets say multiple threads are there).
Now we can use mutex. One by one the threads will lock it and will use
Those who are new to bash scripting the input will be given as command
line argument
--
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
@Ashish: In ur example you have found a min distance for a and c. Now
to proceed because we have to find out min distance for two out of
three arrays with the third array in between i.e. u need to find
occurrence of a c b or a b c or b a c or ... in the merged array. Now
quite possible these
whether u write your code in assembly or c or even in Machine code it will
take the same time..
because after-all ,on system ...your executable runs not ur code
and which is not in c not in assembly but in machine code
On Thu, Jun 16, 2011 at 9:11 AM, saurabh singh saurab...@gmail.com wrote:
you can use a set to do that. Put the map elements into a set providing a
functor to compare the map elements on their value. Use the set now to
retrieve the elements in the required order.
On Sat, Jun 18, 2011 at 10:08 AM, nicks crazy.logic.k...@gmail.com wrote:
Is it Possible to Sort the stl
btw, i didn't understand the reason/motive behind this question? was
it some kind of test??
On Sat, Jun 18, 2011 at 11:45 AM, Harshal hc4...@gmail.com wrote:
compiler error?? if the void is replaced by int, ans=155.
On Sat, Jun 18, 2011 at 11:33 AM, Balaji S balaji.ceg...@gmail.com wrote:
It does matter. suppose u write the c code and the compiler generates
assembly level code later u get machine code which runs. here in this
process many optimizations can be employed which are not done by gcc.
So including asm code in ur c code can actually make ur code to run
very fast provided u
@Aditya I have been doing this for sometime now,and it does seem to work
mainly because compiler works at a general level,it knows nothing what your
code is trying to achieve(It does predicts somethings).So if you have
patience enough to write asm codes and u are miser enuf to optimize it you
but in a set elements are not in any order...and also set cannot be
indexed...
if u want to sort in the basis of key use vector with pair...
Correct me if m wrong
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
There is a data structure called a bimap. You can access the elements by key
and value and they are interlinked. Do a quick google on it. I think that's
what you're looking for.
--
DK
http://twitter.com/divyekapoor
Http://www.divye.in
--
You received this message because you are subscribed
Okay. Worst possible test case is string of all 'a' with length equal to string
length which makes it quadratic.
--
DK
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
@KK,
yes set is not indexed, but you can insert the map elements in set in sorted
order( based on value, here by providing your own comparison class), and
using an iterator over this set, you can access each element(each map
element). say, from set.begin() to set.end(), you will have the map
Okay. Worst possible test case is string of all 'a' with length equal to string
length which makes it quadratic. You can fix this quite easily. Think about
how. ;) a change in approach is recommended.
--
DK
--
You received this message because you are subscribed to the Google Groups
we could maybe keep an array of keys and sort them according to the values
stored in the hashtablejust my 2 cents
On Sat, Jun 18, 2011 at 6:10 PM, Harshal hc4...@gmail.com wrote:
@KK,
yes set is not indexed, but you can insert the map elements in set in
sorted order( based on value, here
Hey guys,
A semaphore is an extension of a mutex. A mutex allows one thread
inside the critical section, a semaphore allows n threads in a
critical section (when the number n is given as a parameter on the
initialization). A semaphore is useful when a resource has more than
one instance, and a
Yeah terence was rightThat was the case...
On Sat, Jun 18, 2011 at 5:25 PM, saurabh singh saurab...@gmail.com wrote:
@Aditya I have been doing this for sometime now,and it does seem to work
mainly because compiler works at a general level,it knows nothing what your
code is trying to
I have come up with this approach. Take first two arrays and compute the min
absolute difference between two elements. Then with this mingap2 between A1
and A2, add each element and check what is the least value possible.
Below is the code. Think it should work. I have not considered negative
Sukhmeet can you please explain your approach ?
On Fri, Jun 17, 2011 at 3:48 PM, sukhmeet singh sukhmeet2...@gmail.comwrote:
Can be done by any standard disk scheduling methods.. i guess
On Tue, Jun 14, 2011 at 2:01 PM, Akshata Sharma akshatasharm...@gmail.com
wrote:
Design an elevator
How to find median of a Binary Search Tree without storing it in a linear
data structure by in-order traversal?
--
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
traverse the BST , get the count of no. of nodes . now inorder
traverse again till n/2 . and print that node
On Sat, Jun 18, 2011 at 11:18 PM, Akshata Sharma
akshatasharm...@gmail.com wrote:
How to find median of a Binary Search Tree without storing it in a linear
data structure by in-order
if no recursion and extra space is allowed??
On Sat, Jun 18, 2011 at 11:20 PM, Vipul Kumar vipul.k.r...@gmail.comwrote:
traverse the BST , get the count of no. of nodes . now inorder
traverse again till n/2 . and print that node
On Sat, Jun 18, 2011 at 11:18 PM, Akshata Sharma
then you can use iterative method instead of 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
@Monsieur: You're wrong. A mutex would be useless if it couldn't maintain a
queue of waiting processes. A binary semaphore is equivalent to a mutex only
under very restricted use cases. See the mail below for details.
@Dumanshu: No. In fact I mean to say the exact opposite. A binary semaphore
A small change to the code for the mutex using semaphores:
void f() {
// Locking code
sem_wait(sem1);
mutex_owner = getpid();
// CS
// Unlocking code
if(getpid() == mutex_owner) {
sem_post(sem1);
} else {
abort(); // Invalid program operation: mutex not owned
Hi Guys/Girls,
I've created an interesting question. It's not strictly algorithmic, but
it's fun:
Given the following code, hack it to run calc.exe (on windows) or xcalc (on
linux) or prove that such exploitation is not possible.
It might or it might not be a simple challenge... but give it
a 1,10,12,14,16
b 5,6,9,12
c 16,19,22,25
this approch will fail
the fact that two pointers should move atleast to find minDistance is not
getting addressed completely in this solution
in this example min D = 5-1=4 to start with
then pointer in arr a moves, abs(5-10), abs(10-16) both are
39 matches
Mail list logo