28 May 2004

interview questions

  1. Write a function that computes the N-th fibonacci number.
  2. Work in base 7: addition, multiplication, division.
  3. You are given a tree as a list of edges, each described as a line "<from> <to>" in the input file. You are also given a set of interesting nodes from the console (cin). Find a common parent of the interesting nodes that is as far as possible from the tree's root.
  4. Compare a linked list structure with an array. Example: ArrayList and LinkedList in Java.
  5. Implement remove_if
  6. Count the number of set bits in a 32b integer. Optimize for time/space.
  7. Implement next_permutation.
  8. Print the data in a binary tree level by level.
  9. Write a function that generates all subsets of a set. Now write a function that generates all subsets for which the product of elements is less than a limit. Optimize for speed.
  10. Compare two languages.
  11. When should a destructor be virtual in C++? What is a "virtual constructor"?

No comments:

Post a Comment

Note: (1) You need to have third-party cookies enabled in order to comment on Blogger. (2) Better to copy your comment before hitting publish/preview. Blogger sometimes eats comments on the first try, but the second works. Crazy Blogger.