Technical Interview

Home
Technical Interview
Interview Process
Introduction Questions
Quantitative Problems
Google & Microsoft
Algorithms
C/C++ Questions
Java Questions
Data Structures
Fundamental Questions
Puzzles
Resume Tips
Added Recently
Links
Contact Us
Submit Question/Answer
 What are some of the commonly used techniques to optimize code? 

- Code level optimization
such as
1. Optimize function calls
- use fast call, which doesn't use the stack but uses some processor registers. This is limited only when the parameters are not greater than 64 bit.

 
2. Optimize repeated calls
Use inline functions and macros instead of calling functions for small procedures, which abuse the stack.

3. Allocate memory all at once
instead of re-allocating memory each time you add an element.

4. Use objects instead of heap pointers as much as you can.

5. Be wise in using loops.