Write a program to generate prime factors of a given integer?
Answer Posted / kalee
Pseudo code: Algorithm ....
If N is the integer, then, any number greater than sqrt(N) will not be a factor of that integer...
so it is enough to check till sqrt(N) integers, that is it is divisible or not... further, if N is odd... forget all the even integers, as they cannot be a part of factors.. :)
Happy coding...
Is This Answer Correct ? | 6 Yes | 9 No |
Post New Answer View All Answers
Explain what is a 'locale'?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
How will you divide two numbers in a MACRO?
write a program to generate address labels using structures?
What is the size of structure in c?
Can we compile a program without main() function?
What are the 5 data types?
Why do we write return 0 in c?
Explain the use of keyword 'register' with respect to variables.
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
What is the advantage of a random access file?
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
What is the difference between int main and void main in c?
You have given 2 array. You need to find whether they will
create the same BST or not.
For example:
Array1:10 5 20 15 30
Array2:10 20 15 30 5
Result: True
Array1:10 5 20 15 30
Array2:10 15 20 30 5
Result: False
One Approach is Pretty Clear by creating BST O(nlogn) then
checking two tree for identical O(N) overall O(nlogn) ..we
need there exist O(N) Time & O(1) Space also without extra
space .Algorithm ??
DevoCoder
guest
Posted 3 months ago #
#define true 1
#define false 0
int check(int a1[],int a2[],int n1,int n2)
{
int i;
//n1 size of array a1[] and n2 size of a2[]
if(n1!=n2) return false;
//n1 and n2 must be same
for(i=0;i
What is hungarian notation? Is it worthwhile?