Pages

8.01.2013

Notes on... Programming Interviews Exposed Part I

If you state on your CV that your Java knowledge is advanced, the least you can do is answer what is the difference between a primitive type and an object at your job interview!

Fine, if you don't know, then you don't know.  As part of your interview prep is to google search for common java interview questions.


There are also many great books, and online blogs and forums that provide great interview questions.

One of these books is Programming interview Exposed.


These are a few notes on it:



Chapter 1, 2:
  • Sanitise online profiles.
  • Sanitise CV.
Chapter 3: Approaches to Programming Problems.
  • Talk through questions before starting to write.
  • Write: function or method, class definition or a sequence of related code modules.
  • Brush up on the languages you expect to use and write you best code.
  • If you mention a technology, make sure you have brushed up on it.
  • During the interview demonstrate:
    • logical thought process.
    • knowledgeable about computers.
    • communication skills.
  • Solving questions
    1. Make sure to understand the problem.
    2. Once you understand, try an example to solidify your understanding.
    3. Focus on the algorithm and talk throught the process.
    4. Explain the solution to the interviewer.
    5. While coding, explain what you’re doing.
    6. Ask questions.
    7. Trace through code with an example.
    8. Check for errors, special cases and boundary conditions.
  1. When stuck
    1. Maintain interest and keep trying to solve it.
    2. Go back to an example.
    3. Try a different data structure.
    4. Consider a less-commonly used or more advance aspects of language.
  2. Analyzing your solution
    1. Understanding of big-O analysis.


1. Big-O Analysis.
Example: Consider a simple function that returns the maximum value stored in an array of non-negative numbers.
- input size = n (find out what n means in terms of the input). ex. number of elements in an array.
- times the input items is examined (what does examine mean). ex. compare two array values.
  • when the comparison is done once for each element. O(n).  
  • when comparison of one to all. O(n2).
Procedure:
1. Figure out what the input is what n represents.
2. Express the number of operations the algorithm performs in terms of n.
3. Eliminate all but the highest-order terms.
4. Remove all constant factors.


Chapter 4: Linked Lists


Programmer Competencies Matrix on Data structure (More on this in another Post):


2n (Level 0)
n2 (Level 1)
n (Level 2)
log(n) (Level 3)


Doesn't know the difference between Array and LinkedList
Able to explain and use Arrays, LinkedLists, Dictionaries etc in practical programming tasks
Knows space and time tradeoffs of the basic data structures, Arrays vs LinkedLists, Able to explain how hash tables can be implemented and can handle collisions, Priority queues and ways to implement them etc.
Knowledge of advanced data structures like B-trees, binomial and fibonacci heaps, AVL/Red Black trees, Splay Trees, Skip Lists, tries etc.


There are three basic kinds of linked list:
  • singly-linked lists - linear list where each element has a next pointer (link) to the next element.
    • can be traversed only in the forward direction.
    • need a pointer to the first element (head) of the list.
    • first element (head), last element (tail).
  • doubly-linked lists - list where each element has a next and previous pointer.
    • can be traversed in either direction.
    • can be traversed from any element.
  • circularly-linked
    • no head or tail.
    • primary traversal problem - cycle avoidance.


Basic Linked List Operations:
  • tracking head element - always keep track of the head element
  • traversing the list - always check for the end of the list.
  • inserting or deleting list elements - use to pointer for the element and previous element.


A stack is a LIFO data structure and a particular kind of abstract datatype or collection.
It is restricted because a limited number of operations can be implemented and these happend at one end of the stack, the top.
Operations:
Push
Pop
Top or peek

This is just a glimpse... more will come soon. At least we hope!

No comments:

Post a Comment