thanks ankit
On Fri, Jul 15, 2011 at 1:07 AM, ankit sambyal ankitsamb...@gmail.comwrote:
Change the printf statement to :
printf(root-%x--root--%x--(root-data)=%x--(root-left)=%x--(root--right)=%x--*root--%d,root,root,(root-data),(root-left),(root-right),*root);
Actually printf behaves
Hi,
See the below link for detailed explanation of special printf format
specifiers in C...
http://www.cplusplus.com/reference/clibrary/cstdio/printf/
--
Regards:
---
D Kranthi kumar
Computer Science Engg.
1st Mtech, IIT Madras.
--
You received this message because you
This should help you out.
http://msdn.microsoft.com/en-us/library/f90831hc.aspx
Regards,
Sandeep Jain
On Fri, Jul 15, 2011 at 11:15 AM, abhishek kumar
mailatabhishekgu...@gmail.com wrote:
@Sandeep Jain
sandeep, please be more clear about lvalue rvalue assignment.
--
You received
Whats wrong in this?
o/p is-- %.#s Zi
*%.#s *is printed as usual and *Zi *is printed coz of *%.2s *it will print
only 2 characters as written after decimal place. :)
It wil ignore 2nd str
On Fri, Jul 15, 2011 at 1:31 AM, rShetty rajeevr...@gmail.com wrote:
#includestdio.h
int main()
{
char
use consistency hashing
see chord
On Fri, Jul 15, 2011 at 3:22 AM, DK divyekap...@gmail.com wrote:
@Sagar: And how would you resolve hash collisions?
--
DK
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the
it is simple n*n ways.
On Thu, Jul 14, 2011 at 11:36 PM, tendua 6fae1ce6347...@gmail.com wrote:
We are given n by n boolean matrix ( n = 20). Output of matrix should
be such that every row and every column should have only one true
value ( true=1, false=0). Input matrix can have any number
O(n!)
On Fri, Jul 15, 2011 at 12:17 PM, Sarvesh kumar.sarv...@gmail.com wrote:
it is simple n*n ways.
On Thu, Jul 14, 2011 at 11:36 PM, tendua 6fae1ce6347...@gmail.com wrote:
We are given n by n boolean matrix ( n = 20). Output of matrix should
be such that every row and every column
#includestdio.h
int main()
{
int a=1,k=2,n=3;
int diff=n-k;
if(diff=0){
while(k1)
{
k--;
a=(a1) | 1;
}
while(diff=1)
{
a=a1;
diff--;
}
printf(%d,a);
}
else
printf(value not applicable: %d,a);
return 0;
}
--
what is the question
???
On Fri, Jul 15, 2011 at 2:16 PM, ani natarajananitha...@gmail.com wrote:
#includestdio.h
int main()
{
int a=1,k=2,n=3;
int diff=n-k;
if(diff=0){
heres another approach.
For given n sets, all permutations have a { in the beginning and } in
the end. So, we need to permute the middle string with (n-1) sets. I
have generated all the permutations of n sets i.e. say n ==3 then
generate all permutations of (n-1==2 sets) {}{} string. Now before
Left shift operation is equal to
xy=x*2^y
so 11=2
2 | 1=3;
finally 31=3*2^1=6
Right shift operation is equal to xy=x/2^y..
--
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.
You are provided with a bit generator which generates 1 and 0 with equal
probabilities i.e. (1/2). You are required to design a function which
generates numbers form 1-1000 with equal probabilities i.e. (1/1000).
--
You received this message because you are subscribed to the Google Groups
int a=(int)rand()%1001; //1-1000
int b=(int)rand()%2; // 0-1
On Fri, Jul 15, 2011 at 3:01 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote:
You are provided with a bit generator which generates 1 and 0 with equal
probabilities i.e. (1/2). You are required to design a function which
generates
@sagar
did you read the question before posting
On Fri, Jul 15, 2011 at 3:17 PM, sagar pareek sagarpar...@gmail.com wrote:
int a=(int)rand()%1001; //1-1000
int b=(int)rand()%2; // 0-1
On Fri, Jul 15, 2011 at 3:01 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote:
You are provided with a
oh sorry...
On Fri, Jul 15, 2011 at 3:21 PM, sunny agrawal sunny816.i...@gmail.comwrote:
@sagar
did you read the question before posting
On Fri, Jul 15, 2011 at 3:17 PM, sagar pareek sagarpar...@gmail.comwrote:
int a=(int)rand()%1001; //1-1000
int b=(int)rand()%2; // 0-1
On Fri, Jul
If rand() generates equi-probable numbers within range [1 - n] and n is a
multiple of 1000 then your above code will be correct.
You should utilize the bit-generator function.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
Read Dave solution
https://groups.google.com/forum/#!msg/algogeeks/nE3REQZ-YBc/Y02NVHYBhdkJ
On Fri, Jul 15, 2011 at 3:23 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote:
If rand() generates equi-probable numbers within range [1 - n] and n is a
multiple of 1000 then your above code will be
its correct.
--
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
int bit_generator(); // function which returns 1 and 0 with equal probabilities
int generator()
{
int generated_num[10],i,n;
for(i=0;i10;i++)
{
generated_num[i]=bit_generator();
}
n=generated_num[0];
i=1;
while(i10)
{
n*=10;
I don't think so that probability would be exact 1/1000 .
suppose number is ( a9 a8 a7 a6 a5 a4 a3 a2 a1 a0) where a0 is least and a9
is most significant bit then you can generate each of the bit ai using given
bit generator
but if but at a time (a9 , a8 , a7 , a6 , a5 , a3 ) and any other bit
delete all the numbers found in list2 from list1 recursively or iteratively
Also optimize ur algo when list1 is sorted in ascending order and list2 is
sorted in descending order
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
Hi,
#includestdio.h
char *c[]={ENTNG,NST,AMAZI,FIRBE};
char **cp[]={c+3,c+2,c+1,c};
char ***cpp=cp;
void main()
{
printf(%s,**++cpp);
printf(%s,*--*++cpp+3);
printf(%s,*cpp[-2]+3);
printf(%s,cpp[-1][-1]+1);
}
The answer is AMAZING BEST ... Can somebody explain the last printf
alone.??
--
nos [1001,1023] are neglected as if their probabilities are set to zero and
recalculated.As nos [1,1000] are only considered and as they are generated
with equal probabilities i.e. 1/1024. I feel the above solution to be
correct.
--
You received this message because you are subscribed to the
but suppose you have to generate numbers between [1,513] then also it would
generate numbers them each with probability 1/1024 which could make a big
difference and I feel the above solution to be incorrect . May be we could
think of a better one .
--
You received this message because you are
How will you delete duplicate odd numbers from a linked list in 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
last printf
*(*(cpp-1)-1)+3
gives =ST
second last printf
*(*(cpp-2)) +3 give BE
On Fri, Jul 15, 2011 at 10:45 PM, swetha rahul swetharahu...@gmail.comwrote:
Hi,
#includestdio.h
char *c[]={ENTNG,NST,AMAZI,FIRBE};
char **cp[]={c+3,c+2,c+1,c};
char ***cpp=cp;
void main()
{
after third printf cpp points to c+1 then c[-1][-1] let it point to
c+2+(-1) which is c+1 .. next its easy just add one to the string pointed
out ..!!
On Fri, Jul 15, 2011 at 10:45 PM, swetha rahul swetharahu...@gmail.comwrote:
Hi,
#includestdio.h
char *c[]={ENTNG,NST,AMAZI,FIRBE};
char
i don't think it is possible to do it in O(n)... rather not even in O(nlogn)
without modifying the list
On Fri, Jul 15, 2011 at 11:23 PM, Nishant Mittal mittal.nishan...@gmail.com
wrote:
How will you delete duplicate odd numbers from a linked list in O(n) time
--
You received this message
@rishab, here it generates numbers which are powers of 2 until n gets to 0
int bit_generator(); // function which returns 1 and 0 with equal
probabilities
int generator(int n)
{
int generated_num[10],i;
int lg = (int)floor(log(n));
n -= pow(lg,2);
int m = 0;
i=0;
count number of elements from both lists and reverse list with minimum
number of elements, go ahead with checking and deleting linearly
surender
On Fri, Jul 15, 2011 at 10:38 PM, Nishant Mittal mittal.nishan...@gmail.com
wrote:
delete all the numbers found in list2 from list1 recursively or
@Surender Your solution in correct one .
--
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.
I agree with skript: Number of ways of doing this is n!
One in the first row can be placed in n ways.
After one in first row has been placed,
we can place One in second row in n-1 ways and so on.
So total num of ways is n*(n-1)*...*1 = n!
One possible solution to this problem can be coded as
Use a Hash Table.
Aseem
On Sat, Jul 16, 2011 at 12:28 AM, shady sinv...@gmail.com wrote:
i don't think it is possible to do it in O(n)... rather not even in
O(nlogn) without modifying the list
On Fri, Jul 15, 2011 at 11:23 PM, Nishant Mittal
mittal.nishan...@gmail.com wrote:
How will
Does anyone have any tips for this problem?
My code is time limit exceeded
#define MAX 86028122
bitset MAX primo;
long long int lista[501];
long long int cont;
void crivo(){
long long int i,j;
long long int limite;
for(i=2;iMAX;i++) primo.set(i,1);
for(i=4;iMAX;i=i+2)
give the hashing function ??
On Sat, Jul 16, 2011 at 12:51 AM, aseem garg ase.as...@gmail.com wrote:
Use a Hash Table.
Aseem
On Sat, Jul 16, 2011 at 12:28 AM, shady sinv...@gmail.com wrote:
i don't think it is possible to do it in O(n)... rather not even in
O(nlogn)
You just need to maintain the array for the odd words which encountered
during traversing the list and using hashing this can be done :) but of
course not in O(n) :(
On Sat, Jul 16, 2011 at 12:51 AM, aseem garg ase.as...@gmail.com wrote:
Use a Hash Table.
Aseem
On Sat, Jul 16, 2011 at
On Friday 15 July 2011 16:21:51 Wladimir Tavares wrote:
Does anyone have any tips for this problem?
My code is time limit exceeded
#define MAX 86028122
bitset MAX primo;
long long int lista[501];
long long int cont;
void crivo(){
long long int i,j;
long long int limite;
can any tell and explain the output of following code
#includestdio.h
main()
{ int a =5, b=5;
int res1=(++a)+(++a)+(++a);
int res2=(++b)+(++b)*10+(++b)*100;
printf(%d\n%d\n,res1,res2);
}
--
You received this message because you are subscribed to the Google Groups
sorry I don't know how to post new thread so posting my query here and
please some one tell how to do that
can any tell and explain the output of following code
#includestdio.h
main()
{ int a =5, b=5;
int res1=(++a)+(++a)+(++a);
int res2=(++b)+(++b)*10+(++b)*100;
@sagar:o/p is #s zi..can u explain y?
On Sat, Jul 16, 2011 at 1:45 AM, Antony Kotre antonyko...@gmail.com wrote:
can any tell and explain the output of following code
#includestdio.h
main()
{ int a =5, b=5;
int res1=(++a)+(++a)+(++a);
int
@sagar... I know this solution but it was strictly asked to do in O(n) time
and O(1) space complexity and what if range of numbers is very large
On Sat, Jul 16, 2011 at 1:09 AM, sagar pareek sagarpar...@gmail.com wrote:
You just need to maintain the array for the odd words which encountered
@surender thanx for ur algo but tell me about the 1st part when numbers are
not sorted.
i think if we apply merge sort on both the list then it would be easy to
delete after sorting.
correct me if i m wrong
On Sat, Jul 16, 2011 at 12:40 AM, surender sanke surend...@gmail.comwrote:
count
if lists are unordered, make a map of list2 and during traversal of list1
search for map, if found delete that node
surender
On Sat, Jul 16, 2011 at 2:02 AM, Nishant Mittal
mittal.nishan...@gmail.comwrote:
@surender thanx for ur algo but tell me about the 1st part when numbers are
not
Can the admins please state why posting from the Web interface was disabled
for this group? I'm sure a number of people (me inclusive) use the web
interface to view the group posts and reply to them.
---
DK
http://www.divye.in
http://twitter.com/divyekapoor
--
You received this message because
@Sagar: You misunderstand my concern.
When I say hash collisions, I mean:
Consider 2 very different images X and Y - both have the same hash value H.
Such X and Y will always exist because you're mapping a larger informational
space to a smaller one (by pigeonhole principle in a sense).
Without
@Anatony
the output will be compiler dependent
res1 is not defined .. as C don't allow to change the value of a variable
more than once between a sequence point..
A sequence point occur while assigning a value , calling a function or
returning from it..
Hence both res1 and res2 would give arbitary
Given a file containing 4,300,000,000 integers, how
can you *find **one* that *appears* at *least **twice*
--
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
just hash it
On Fri, Jul 15, 2011 at 6:28 PM, Anand Shastri
anand.shastr...@gmail.com wrote:
Given a file containing 4,300,000,000 integers, how
can you find one that appears at least twice
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
file any way contains integers why do we need hash those integers? why not
use the same integers to index an array.
On Fri, Jul 15, 2011 at 6:36 PM, radha krishnan
radhakrishnance...@gmail.com wrote:
just hash it
On Fri, Jul 15, 2011 at 6:28 PM, Anand Shastri
anand.shastr...@gmail.com
if number is (131) -1 u declare a 2GB array ?
On Fri, Jul 15, 2011 at 6:59 PM, Anand Shastri
anand.shastr...@gmail.com wrote:
file any way contains integers why do we need hash those integers? why not
use the same integers to index an array.
On Fri, Jul 15, 2011 at 6:36 PM, radha krishnan
File has 4,300,000,000 integers if you hash it will create a distinct hash
for 4,300,000,000 integers.
On Fri, Jul 15, 2011 at 7:09 PM, radha krishnan
radhakrishnance...@gmail.com wrote:
if number is (131) -1 u declare a 2GB array ?
On Fri, Jul 15, 2011 at 6:59 PM, Anand Shastri
thats the challenge man ! if u are declaring a static Array of 2GB and
u might find the repeated element in second step then memory is waste
!
Thats why hashing ! hashing has complexity of O(n) only !
Instead you can simply use a BBST but complexity is O(n lgn)
On Fri, Jul 15, 2011 at 7:11 PM,
Hi,
Can anyone help me in understanding the following code
http://www.algorithmist.com/index.php/Longest_Increasing_Subsequence.cpp
I am not able to understand what is the exact purpose of vector p in the
above mentioned code.
A little detail explanation will be helpful.
~Neeraj
--
You
@Shady: You'll find the original question, and several responses, at
http://groups.google.com/group/algogeeks/browse_thread/thread/0cfa6215ccf4b292#.
The code you referenced is not a correct solution. I think you'll find
that my code is correct.
Dave
On Jul 15, 3:52 am, shady sinv...@gmail.com
done :)
On Sat, Jul 16, 2011 at 2:22 AM, Divye Kapoor divyekap...@gmail.com wrote:
Can the admins please state why posting from the Web interface was disabled
for this group? I'm sure a number of people (me inclusive) use the web
interface to view the group posts and reply to them.
---
DK
Hi
Can anyone help me in understanding the following code
http://www.algorithmist.com/index.php/Longest_Increasing_Subsequence.cpp
I am not able to understand what is the exact purpose of vector p in the
above mentioned code.
A little detail explanation will be helpful.
I have already
if hashing is allowed then it can be done in O(n)... space complexity in
this case again will be O(n) this won't work for large numbers...
On Sat, Jul 16, 2011 at 1:58 AM, Nishant Mittal
mittal.nishan...@gmail.comwrote:
@sagar... I know this solution but it was strictly asked to do
@Antony: To post in this group..Just login to your gmail account. Compose
new mail containing your question and send it to algogeeks@googlegroups.com
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
58 matches
Mail list logo