thanks for the link. i have read it.
now i want to know is there any advantage of coding naive bayes in python rather than any other language like c++?
henrySh commented: you need a for loop to enter an read the members from the array +0
thanks for the link. i have read it.
now i want to know is there any advantage of coding naive bayes in python rather than any other language like c++?
the formula for naive bayes is
P(A/B1,B2,B3...Bn) =
[ P(A) * P(B1/A) * P(B2/A) * . . . P(Bn/A) ] / [ P(B1) * P(B2) *....P(Bn) ]
i am working on a project to classify email as spam or not. i have a large data set.
i am using nltk package in python.
my question is how to find the probabilities of the right side of the expression.
and after that how should i set my threshold value?
that they made an unwarranted assumption
yeah..i take 'n' as 11 and got score 20 .
unfortunately i cant message any participant.
should i mark this question solved or unsolved?
@deceptikon i have already mailed them twice and also message on fb (when i started this contest) but got no reply till now. but what amazed me is when i saw people submitted their solution in C and C++ and got points.
you determine those sizes yourself before you even create them
well if you have read the question(in the link), then you will know that these arrays are not 'created' by me, these are input to me. if you have participated in any Topcoder SRM then you will better 'understand' this.
i request you to please 'read' all the comments in this post.
i have seen people submitted in C and C++ too. dont know how?
i take the screenshots of the question and saved them in doc file.
this is the dropbox link to download the file.
after reading the question, please read my first post then you will better understand what problem i am facing.
i give a link but i dont know why you guys cant open it and read the question and answer my query?
@tinstaafl i know what the question is . my main problem is how to get the length of the two arrays?
@sepp2k i have already tried i<N but this is giving error as N is undefined.
by the way in CSHARP ,Length is giving the length of the array.
@sepp2k i dont know what is 'N' so i cant use it in loop.
the admins of that site was not replying to my mails. i am assuming there is no way to find the length of arrays.
in input specification it is mentioned both of array size will be equal to 'N' and nothing else.
i have seen some score of people who submits it. i found CSHARP solution has got points .
is there any way in this language?
@all
there is a question and i need to submit it online.
#include<stdio.h>
#include<string.h>
int median(int input1[],int input2[])
{
//Write code here
}
here i cant use vector and cant pass the size from main function. i just need to complete the median function and submit it.
there is function :
int median(int a[], int b[])
{
}
how do i find the number of elements in a and b?
i am doing sizeof(a)/sizeof(int) but it does not give right results.
P.S. i need to submit the function only in online compiler so i dont know what is the length of array.
@deceptikon i have given i/p yesterday and it works .
and yes,you are right. i declared 'n' aand 'k' global and i got success.
thanks.
@deceptikon i also think so but i remember a lot of times i got 'success' without any i/p.
@ tinstaafl it is also working fine on my dev-c++ but why it giving RTE on ideone?
what is static function in c++?
when should a function is made static?
@deceptikon can you please explain the printf statement?
i want to print a 'double' variable upto 8 decimal places without trailing zeroes.
for eg:
if a= 10.1234 then print 10.1234
if a= 10.00 then print 10
if a= 10.11111111111 then print 10.11111111 (max of 8 decimal places).
how to do it?
i searched for it and found this:
printf("%g",a);
this work fine but print upto 6 decimal places.
@deceptikon does strlen() function give the length of string in O(n) or O(1)?
@moschops i am trying to avoid that loop. thats why i am using memset which fails.
@lucaci Andrew..your answer is same as of Moschops but the link you provide solves my problem. i have to use fill_n() instead of memset();
but it works only for 1-D array. for 2-D it gives error.
got it.
now how should i set every 4th byte to '1' using memset?
i am trying to initialize the array 'a' elements to integer 1 but it initialize with '16843009'. or some other garbage values when i tried with integer 2,3 ,4 etc.
it correctly sets values 0 and -1 only.
why it doesnot works for values other than 0 and -1
i mean when i tried to print values of array 'a' after memset() then it shows incorrect values.
int a[100];
memset(a,0,sizeof(a)); ///it works
memset(a,-1,sizeof(a)); ///it works
memset(a,1,sizeof(a)); ///it doesnt
what is the use of string.xml file in android?
is it like defining global strings if we have multiple .java files in android application? correct me if i am wrong
what is lvalue and rvalue?
please explain with simple example.
@rithish...you print the string in reverse order. that not the question. you have to store it too.
@straylight...your solution to first part is:
for 2nd part
1. you have to use the above generated string for this.
2. do the above steps for each word (i mean till every space in a string).
you get the desired answer. check it yourself
can you please write how to do it using intrptr_t?
but bitwise operation can be performed only on integers
Since in XOR linked list current pointer store the XOR of addresses of previous and next node.
my question is how do we XOR two pointers?
when there are no comments even then i cant delete it?
@all..one of the foolish question i have ever asked. as soon as i posted it i realized the answer.
@admin..why there is no option to delete a post?
where is union required?
please explain with an example where having union is a better choice than any data structure.
why c[0] is adding to 512?
int i=512;
char *c=(char *)&i;
c[0]=2;
printf("%d",i);
o/p is 514
if we have an array 3,1,3,2,2
then do xor all the numbers start with 0.
0^3 = 3
3^1 = 2
2^3 = 1
1^2 = 3
3^2 = 1
1 is the ans. works only if all numbers occurs twice and only one number occurs once.
Xor all the numbers as you input them. at the end you will left with the number occurs once.
2 loops are enough for all permutation of 'n' bit binary number.
for(i=0;i<(1<<n);i++)
{for(j=0;j<n;j++)
{
if(bit is set) print "1";
else print "0";
}
}
does that means that order in which i write the structures elements matter to calculate the offset and hence size changes?
also 3 bytes are free here.. isnt it memory wastage though small?
how performance is increased?
are structure elements location in memory contiguous? if yes, in this case then there is free memory blocks after char variable as size is greater than individual sum? correct me if i am wrong.
struct abcd
{
char q;
int w;
//long int e;
};
why size of this structure is 8 bytes and if i include long int e , size becomes 12 bytes?
i am checking this : **if((temp.info.compareTo(max.info))>0) **
but its not working
i mean what should i write in compareTo function?
if i write this temp.info.compareTo(max.info) then i need to define compareTo function. then still i need to have a check in that function. what is the if condition ?