ya it is giving error cz u r incrementing x. u cant increment x as it is
const. but there is no prob with declaration. its valid.
On 26 June 2010 11:09, sharad kumar aryansmit3...@gmail.com wrote:
pls c thz
On Sat, Jun 26, 2010 at 10:48 AM, sharad kumar aryansmit3...@gmail.comwrote:
cos if
This is a well known C Gotcha,to change a const variable will always lead to
error.
I guess the main query is Is this declaration valid and your compiler only
shows error at printf line and not in the declaration.It also states that
'x' is a read-only variable.
Hence,it accepts this declaration
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
Given two log files, each with a billion usernames (each username appended
to the log file), find the usernames existing in both documents in the most
efficient manner?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
i have to right rotate an array by k positions
1 2 3 4 5 for k=2 o/p shud be
3 4 5 1 2
P.S---do not give block reversal method for array rotation and soln must be
inplace.plzz write ur logic also along with d code
--
You received this message because you are subscribed to the Google Groups
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
I have the following sequence of integers: 104,105,106,108 and need to
write a Java statement to randomly produce one of these numbers. I
basically need a non-linear random number generator. Any ideas?
Travis
--
You received this message because you are subscribed to the Google Groups
din get it .. could you provide the pseudo code.
On Sat, Jun 26, 2010 at 3:54 PM, divya jain sweetdivya@gmail.comwrote:
yes..
i got the solution traverse till node-right!=node-right-left... at this
point u ll get height.. rite?
On 26 June 2010 11:49, Raj N rajn...@gmail.com wrote:
#define max(x,y) ((x)(y)?(x):(y))
struct Bintree{
int element;
struct Bintree *left;
struct Bintree *right;
};
typedef struct Bintree* Tree;
int height(Tree T)
{
if(T-right==T-right-left)
return -1;
else
return (1 +
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
volatile also means that you don't perform compiler optimizations on the
variable...
Anil
On Sat, Jun 26, 2010 at 5:47 PM, harit agarwal agarwalha...@gmail.comwrote:
@sharad
you made it const so it can't be changed inside same program..
but as it is volatile it will read it as a first time
lol!
Anil
On Sat, Jun 26, 2010 at 5:49 PM, harit agarwal agarwalha...@gmail.comwrote:
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
On Sat, Jun 26, 2010 at 3:51 PM, sharad kumar sharad20073...@gmail.comwrote:
assume your computer is reading characters one by one from a stream (you
don't know the length of the stream before ending). Note that you have only
one character of storage space (so you cann't save the characters
Since count is always 1, doesn't rand(0, count) always return 0? So
you always get the last item in the input.
Dave
On Jun 26, 11:00 am, Anil C R cr.a...@gmail.com wrote:
On Sat, Jun 26, 2010 at 3:51 PM, sharad kumar sharad20073...@gmail.comwrote:
assume your computer is reading characters
oops! yeah you also need to increment the count inside...
def get_random_obj( objstream ):
count = 1
obj = objstream.get()
while not objstream.end():
r = rand(0, count)
if r == 0:
obj = objstream.get()
else:
objstream.get() #discard
@amit: Need to store indices also in the tree.
Did you mean a self-balancing BST, like AVL or RB-Tree.
Else worst case is O(n^2) for all positive numbers
On Jun 25, 2:55 am, Amir hossein Shahriari
amir.hossein.shahri...@gmail.com wrote:
@divya: yes you're right my algo doesn't work
@Algoose: Thanks for correcting it. Even I have made the same mistake as
Divya. It shud be node == node-right-left
On Sat, Jun 26, 2010 at 7:20 PM, Algoose Chase harishp...@gmail.com wrote:
If the parent Pointer is available we can use
if( node-right-data node-parent-data || node-right-data
You r given a large string of characters lets call it Sbig. Then there
is a small set of characters lets call it Ssmall. You have to find
smallest substring of Sbig which contains all characters in Ssmall.
For example you are given Sbig = hello what are you doing
Ssmall= eo
answer is ello
24
--
I am assuming that nodes of this tree contain numbers and we want to
get the median of these numbers. Also is this B-Tree a search tree -
are the 3 numbers in each node (each node has 4 chidren and hence 3
values) sorted?
Regards,
Sourav Sain
On Jun 26, 8:27 am, sharad kumar
Hi , can anyone tell me how to find the diameter of a set of N points
i.e the distance between the 2 most farthest points efficiently
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@Raj
You need to examine the nature of the array from end. If form end you
move forward and you find elements are decreasing [10,12,14,16] then
for each element, the previous is next higher. So keep pushing them on
a stack. If you find an increase [say 11,10,12,14,16], then pop from
stack till
@harit
but it is static so internal linkage is there then how it can be changed
by external source
may b i m mis understanding...so plzzz make it more clear
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
Given an array of integers, {1,0,2,0,3,0,0,4,5,6,7,0,0,0}, you have to
create a new array which will be like (1,2,3,4,5,6,7,0,0,0,0,0,0,0}, without
using any other temporary array.
--
With Regards,
Jalaj Jaiswal
+919026283397
B.TECH IT
IIIT ALLAHABAD
--
You received this message because you
@jalaj: Use the same algorithm as finding the height of a normal tree (I
hope you're familiar with it) . But to know that you've reached a leaf, you
would normally use node-left or node-right ==NULL. But here in this case,
the leaves form a doubly linked list, so the former condition can no longer
int array[52];
for(i=0;i52;++i)
{
int rand=rand()%52;
swap(a[i],a[rand]);
}
On Sat, Jun 26, 2010 at 8:35 PM, Anil C R cr.a...@gmail.com wrote:
I'm assuming that the random function can generate uniformly distributed
random numbers between 0 and n(excluding n), where n is an +ive integer.
def
@jalaj
just think 0 as one array and other numbers as other array
the problem is into converted in zero one array which have to be sorted
now sort the array in O(n) with no extra space.
keep a pointer on left most 0 and find the next number in the sequence
when next number found then swap the
j = 0
for i = 1 to n
if a(i) not equal 0
j = j + 1
a(j) = a(i)
end if
end for
for i = j + 1 to n
a(i) = 0
end for
Dave
On Jun 26, 3:27 pm, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
Given an array of integers, {1,0,2,0,3,0,0,4,5,6,7,0,0,0}, you have to
create a
@above
probabilty for all numbers in d stream must be *same*.whether first or
last
--
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
Give an unsorted array find count of pairs of numbers[a,b] where a b and b
comes after a in the array.
Eg. {8,3,6,10,5}
the count of such numbers is 5. i.e. (8,3), (8,6), (8,5), (6,5) and (10,5)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
int getNum(){
int arr[]={104,105,106,108};
return arr[(int)(Math.random()*4)];
}
Anurag Sharma
On Sat, Jun 26, 2010 at 8:43 PM, trdant trd...@gmail.com wrote:
I have the following sequence of integers: 104,105,106,108 and need to
write a Java statement to randomly produce one of these
http://codepad.org/NDAeIpxR
http://codepad.org/NDAeIpxRHere is code for it
On Sat, Jun 26, 2010 at 9:54 PM, Anand anandut2...@gmail.com wrote:
you can use Longest common subsequence algorithm to solve it.
On Sat, Jun 26, 2010 at 4:04 PM, amit amitjaspal...@gmail.com wrote:
You r given a
it is... but a small mistake in the code again...
def get_random_obj( objstream ):
count = 1
obj = objstream.get()
while not objstream.end():
*count += 1*
r = rand(0, count)
if r == 0:
obj = objstream.get()
else:
objstream.get()
@trdant,
is non-linear random number different from general random number?
On Sun, Jun 27, 2010 at 9:36 AM, Anurag Sharma anuragvic...@gmail.comwrote:
int getNum(){
int arr[]={104,105,106,108};
return arr[(int)(Math.random()*4)];
}
Anurag Sharma
On Sat, Jun 26, 2010 at 8:43 PM,
33 matches
Mail list logo