Tuesday 20 May 2014

Algorithm Mistakes I made

  1. Initialize a BST with a parent pointer, but forgot to initialize parent pointers.
  2. Pointers and References. Wrong Assignment.
    (Reference is better in the functions passing; Pointer is better as variables)
  3. Private Access Attributes in Class.
  4. Forgot to design functions to replace function copy.
  5. Forgot to initialize all parameters, especially pointers.
  6. Check whether pointer is NULL. (not null)
  7. Sorting:
    1. Merge Sort: stop_condition if(end-start<=0) return; [not 1]
    2. Quick Sort: Partition Function has return value, the middle point.
    3. Heap Sort: be careful on the boundary: < or <=.
  8. Class & Struct ending with semicolon.
    1. struct {}; 
    2. class {};
  9. Be careful when copy codes;
  10. Pointers operations cannot be passed into another function.
    1. example function:
    2. movePointers(Pointer* p); will not affect the original pointer!!
  11. Did not test the idea before implementation.
  12. Strictly follow the algorithm flow chart.
  13. Be careful to use Recursive Algorithm, it tends to be exponential and slow. Analysis the performance cost first.
  14. AA

No comments:

Post a Comment