General Programming Knowledge 1

  1. What is your definition of good code?
    • Passes all the test: Reliability, efficiency, Solid
    • Cleary expresses intention: Clarity, Elegance, Readability
    • Has no duplication, Layering, Modularity
    • Has the fewest number classes and methods: Simplicity, Design
  2. What’s the difference a linked list and an array?
    1. Linked Lists
    • A sequence of nodes, each containing arbitrary data fields and one or two references (“links”) pointing to the next and /or previous nodes.
    • Does not permit random access to individual elements
    • Access to individual elements is time proportional to the number of elements traversed (O(N)). Constant time (O(1)) insertion and removal of nodes at any point in the list.
    • The principal benefit is that the order of the linked items may be different from the order that the data items are stored in memory or on disk, allowing the list of items to be traversed in a different order.
    1. Arrays
    • Compact contiguous data structures with no per-element overhead.
    • Constant time (O(1)) random access to individual elements.
    • Moving elements requires time proportional to the number of elements moved (o(N)).
  3. What C++ data structure (other than an array  or linked list) can be used to store collections of things and when do you use them?