printf returns the number of character it prints so output is ok
it is 111
see this o/p you will understand
#includestdio.hint main(){int
i=1;printf(%d\n,printf(%d\n,printf(%d,i))); return 0;}
http://codepad.org/gLGMDdoU
--
You received this message because you are subscribed to the Google
are the nodes having an extra pointer for sibling??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
@varun
c should also be in the array
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
this is O(n) solution and using O(n) space...
#includeiostream
#includevector
#includestack
using namespace std;
void leader_count(vectorint v,int *ar)
{
stackint s;
int n=v.size();
int i=n-1;
while(i=0)
{
if(s.empty())
{
ar[--n]=0;
s.push(i);
i--;
}
else
{
if(v[i] = v[s.top()])
{
here is the recursion
http://geeksforgeeks.org/?p=2686
execution:
http://codepad.org/pMszw4Y8
was it difficult to google it
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
m!=n
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
shared memory processing is fast but it is not a IPC mechanism...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
pipes
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
when the system is interrupted then before running ISR set a flag and then
run ISR
and when it returns from ISR unset the flag
after 20ms when system is interrupted again check the flag
if(flag is set)
means ISR is running
else
ISR run 20ms
--
You received this message because you are
@ashgoel
check the output of your code here:
http://codepad.org/7BSTedh5
and i don't think this idea will work
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe
yes if one having speed greater than other then at some point of time he
will catch the robber
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group,
bitwise are ony applicable to unsignedtheir behaviour is undefined on
negative numbers...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send
in my approach
a( b,c)- this implies that nodes within parenthesis are child of a where b
is left child and c is right child
if there is no left child then we can use a(,c) and
if there is no right child then use a(b) and
if there is no child use only a
--
You received this message because you
i don't think sorobber always have 3 ways to go..so he wouldn't get
caught...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
If the points are already sorted by one of the coordinates or by the angle
to a fixed vector, then the algorithm takes O(*n*) time.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
i think the question is not just about sorting non-zero values...
it is asking for a stable sort...so just swapping will not work in this
case
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@sharad
i don't think there is better solution then trie..
it is space as well as time efficient...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this
replace x++ with x
it is const so you can't change it.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
ok.. i got it..
it is 29! / 23! 6!
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more
in linux
use
comm -12 log1 log2
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more
1. the virtual memory size depends on the page size that the system is
using...
2. logical address=5+10=15 bits + (some modifying bits if they are present
like modified,copied etc..)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
look at this approach:
a1+a2+a3+a4+a5+a6+a7=23
now it means there are 23 choclates and 6 partitions(+ symbol) and arrange
these 23+6=29 items so it is 29!
now 23 choclates are identical so divide by 23!
so number of ways=29! / 23 !
--
You received this message because you are subscribed to the
it is 29! / 23!
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit
yes you can allocate 1gb using malloc but it also depends on how much heap
size is available to you..
if you try 2gb then more chances are it won't allocate because of heap is
exhausted..
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
@amit
i think your query is answered by varun..as each process do system call to
allocate memory so it is exhausting the memory for all the processesas
all processes are having the same interface...
@sharad
1.i don't think priviliges affect the user address spaceit tells that in
which
do a bfs traversal and insert a null marker after each traversal keep a
variable max for maximum nodes at any level..
O(n)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To
@amit
1. calloc gives contiguos allocated space and it is not necessary that it
can find 1gb in a row that's why it failed after allocating some memory...
it is not necessary that it will always allocate 800mb of space as in this
case...
2. whenever a process is executed in critical
it is returning the address of last operation done in the accumulator.
as the last operation is copying to s to it is returning s
you will understand try running this,,...
#includemalloc.h
char *f()
{char *s=malloc(8);
strcpy(s,goodbye);
}
main()
{
just send the inorder and preorder traversal of binary tree to other process
and recontruct it.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this
@jitendra u got it right but parent and child are using the same text region
that's why control is transferring back and forth..
try running this code and see that line numbers are repeating...because of
same text region it is working like a loop...
#includestdio.h
int main() {
int id,i;
if the array contains only numbers 1 to n then it can be done in O(n)
inplace otherwise only way is hashing or sorting.which is trivial
solution...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
see this .vote majority algorithm..
http://userweb.cs.utexas.edu/~moore/best-ideas/mjrty/index.html
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this
although CPU is busy in exexcution...it check's its registers values for the
pending interrupts ..
if any interrupt is pending at the end of the current CPU cycle...it
shedules the interrupt handler to further execute the interrupt
subroutine...
--
You received this message because you are
but logic remains the same here...instead of own stack.system stack is
being usedso wat's d difference.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To
dijkstra can be applied for longest pathif there is no cycle..
now assuming that it is directed acyclic graph(DAG)
if u multiply all weights by -1...means all weights are negative..then apply
dijkstra for shortest path and u will get your answer
--
You received this message because you
read this
http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
why the 7th race is doneand also it might be the case that E group
contains the fastest three then how it is done??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
For more
@anilkumarmylayr second step is n^2 logn so yr algo is O(n^2logn)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
For more options, visit this group at
the only other way can be the jump exponentially during search as in binary
search a[mid] is checked so if a[mid]!=x then make low=highest index of
a[mid]!=x this will reduce the comparisionsin binary search
ex-1,1,1,2,2,2,3,3,3,4,4,5,5(13 elements)
let's search for 4
modify binary search
number of back egdes in DFS=number of cycles
--~--~-~--~~~---~--~~
You 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
no use of all these logics.u have 2 calculate whole value of 100! for
summation...
use link list to store final value...after ever product...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
@Debanjan
really nice solution
--~--~-~--~~~---~--~~
You 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
traverse the array once and ge product of all elements , this is dividend
now again traverse for each a[i] do division(divisor,a[i])
code for division without using /
#includestdio.h
int dividend, divisor, remainder;
/* Division function Computes the quotient and remainder of two numbers
using
question is just to retrieve minimum element and not to do any operation
like push pop on it
so do one thing push the element on stack with one more data member that
contains minimum number seen till now...that will be enough[?]
--~--~-~--~~~---~--~~
You
try this
do the DFS analogous traversal on the tree.means
1.set level=1,push root
2.pop root
3.push both children on stack and set increment level .
4.now pop top and recursively do the same thing
every time u pop an element enque it in a max priority queue according to
level
when
in my codei am doing the same thing the winner is compared to the new
player and saved as winner and previous winner is also stored in another
variable...so comparisions r same.
--~--~-~--~~~---~--~~
You received this message because you are subscribed
It will take n comparisons.observe this code
#includeiostream
using namespace std;
int sec_largest(int ar[],int n)
{
int i,max=-32767,sec_max=0;
for(i=0;in;i++)
{
if(ar[i]max)
{
sec_max=max;
47 matches
Mail list logo