Programming Quiz

Email address

Zip code
  1. How many times does the character 'a' get printed in the following pseudocode:
    container = new Array(10); // array of size 10
    for (i = 0; i <= 5; i++) {
        container[i] = 'a'
        print container[i]
    }
  2. 0
    1
    5
    6
    10

  3. What strategy allows for fast searches in a sorted array that isn't possible in a sorted linked list?
  4. Quicksort
    Hashmap
    Binary Search
    Indexing
    Iterator

  5. How many node variables are required to write a function that removes an element from a singly linked list if you want to return the head element? Include inputs.
  6. 0
    1
    2
    3
    4

  7. What is the best strategy for printing the numbers in a balanced binary search tree in numerical order?
  8. Pre-order traversal
    In-order traversal
    Post-order traversal
    Reverse pre-order traversal
    Reverse post-order traversal

  9. Which data structure should be used to implement a breadth first search of a tree?
  10. Set
    Hash Table
    Stack
    Queue
    Graph

  11. What is the output of the following pseudocode?
    int foo(int bar) {
        if (bar > 0)
            return bar * foo(bar - 1)
        else
            return 0;
    }
    foo(10)
  12. 0
    3628800
    362880
    stack overflow
    buffer overflow

  13. What's the fastest possible running time of a comparison sorting algorithm?
  14. O(n^2)
    O(2nlogn)
    O(nlogn)
    O(2logn)
    O(logn)

  15. You have an infinite supply of water and two containers, a 3 quart bucket and a 5 quart bucket.
    You fill the 5 quart bucket from the supply, then fill the 3 quart bucket using the 5 quart bucket.
    You empty the 3 quart bucket.
    Then you pour the contents of the 5 quart bucket into the 3 quart bucket.
    You refill the 5 quart bucket and then fill up the 3 quart bucket using the contents of the 5 quart bucket, taking care not to spill anything.
    How much water is in your 5 quart bucket?
  16. 0 quarts
    3 quarts
    4 quarts
    5 quarts
    Not enough info

  17. Choose the regular expression that will change the before code to the after code.

    Before:

    // Float here.
    float waterfloat = 0.01; // this is a float
    bool isfloat(float input) {
            return true;
    }
    isfloat(waterfloat);

    After:

    // double here.
    double waterfloat = 0.01; // this is a double
    bool isfloat(double input) {
            return true;
    }
    isfloat(waterfloat);

  18. s/float/double
    s/float/double/i
    s/float/double/ig
    s/\bfloat\b/double/i
    s/\bfloat\b/double/ig

  19. What is the binary representation for the number 19?
  20. 11111
    10011
    11001
    10001
    10110