Give 2 examples of a code optimization?
Answers were Sorted based on User's Feedback
Answer / mms zubeir
I would like to quote two things from the same area.
1. Read/Write chunks from/into a file instead of byte by
byte reading.
2. Aquire resources late and relieve it early. Example, if
you want to use a file, open the file as late as possible
and release it as early as possible after use.
| Is This Answer Correct ? | 12 Yes | 1 No |
Answer / maria
1) For checking modulo use
num1&(num2-1)
instead:
num1%num2
2) For multiplying or dividing by 2 use left and right shift
accordingly.
3) In loop use, if code allows it, decrement,like this:
for(int i = MAX_VALUE ; i > 0 ; i--)
instead:
for(int i = 0 ; i < MAX_VALUE; i++)
| Is This Answer Correct ? | 7 Yes | 7 No |
Answer / sudheer
How this num1&(num2-1) replaces num1%num2. Execute and
check before posting some thing...
| Is This Answer Correct ? | 1 Yes | 4 No |
What is purpose of new operator?
What is multithreading and what is its use?Whats are multithreading techniques used in C++?
Why do we use vector in c++?
difference between the c++ and c languages
Do the names of parameters have to agree in the prototype, definition, and call to the function?
let a,b,c be three integer numbers.write a c++ program with a function void rotate 1()such that a->b->c and c->a.
Write a struct time where integer m, h, s are its members?
Am pass the 10000 records to target in target I will take commit interval 15000 when I was stop the work flow what will happened
Is python better than c++?
Write a program that read 2o numbers in and array and output the second largest number. Can anybody help??
What is namespace std; and what is consists of?
Explain the differences between private, public and protected and give examples.