首页 > 代码库 > JI_5

JI_5

Part I. The CV Review

  1. Pass the CV to THREE developers
  2. Each dev should mark YES/NO on the CV
  3. Reject any CVs with TWO No‘s

Part II. The Phone Interview

1. What *EXACTLY* did you code last?

  1. Have them explain in detail..
  2. Then discuss within that context…

Interviewer: Looking for them to bring up things like: OO, Composition over inheritance, SOLID, threading issues, patterns.

2. What design pattern would you apply (if you don’t know a design pattern – then describe what you would make) in this case:

Client has asked you to update their code to allow specific customer processing logic for their custom categories.
    Categories include: Basic, Premium, Sponsor
    When processing requests for a user in the:

Multi-threaded programming (15 points)

  • Q1: List severalthread-safe objects (or your platform of experience, e.g. Unix, Java). (2 points)

       A: CriticalSection, Event, Mutex and Semaphore, scoped lock, othertypes of boost data structures. Metered Section is rare.

  • Q1b: What isthe difference between a mutex and a semaphore. (2 points)
  • Q2: Cana Critical Section be used across processes? Are they more or lessefficient than other thread sync objects? (4 points)

       A: They synchronize exclusive access to shareddata between threads within a single process. Because the critical section doesnot have a named kernel object associated with it, one of its maindisadvantages is that it cannot synchronize access between processes.

       A: As long as no contention for gaining accessto a critical section exists, the critical section code runs entirely in usermode, making it extremely fast. When there is contention for a criticalsection, however, all is not lost; it simply falls back to using a kernel eventobject for synchronization.

  • Q3: What is deadlock?How can it be avoided? (4 points)

       A:Thread 1 acquires lock A.

       Thread 2 acquires lock B.

       Thread 1 attempts to acquire lock B, but it isalready held by Thread 2 and thus Thread 1 blocks until B is released.

       Thread 2 attempts to acquire lock A, but it isheld by Thread 1 and thus Thread 2 blocks until A is released.

       How to avoid: 

  • Always acquire locksin a well-defined order. A more advanced solution is Lock Leveling (also knownas lock hierarchy or lock ordering) to factor locks into numeric levels,permitting components at specific architectural layers in the system to acquirelocks only at lower levels. 
  • Q4: From C++, use ofRAII (Resource Acquisition Is Initialization) is especially important whendealing with thread synchronization objects. In particular, how can you applyRAII to the ensure that you enter and, in particular, leavea CriticalSection? (3 points)

       A: Wrap the Enter/Leave semantics into theCtor/Dtor of a wrapper class, and declare an instance of this on the stack atthe point in which you want to acquire the CriticalSection.

       Comment: commonly known as a Scope Guard 

DATA STRUCTURES ANDALGORITHMS (15 Points)

  •  Q1: How do you analyse, quantify, comparerunning time of different algorithms designed to provide solution for a givenproblem space. 

       The most commonly used method is asymptoticanalysis.  can talk about order of growth, Big-O Notation

  • Q2: What is anassociative array? What data structures can be used to build an associativearray?

       A collection of (Key, Value) pairs, where thevalue could be found using a key. Expect the candidate to mention datastructures like self balancing Binary Trees,  Hash Tables. 

  • Q3: When would you useBinary Tree ? Why trees have to be balanced ? What is the time complexity ofdifferent operations of a self balancing binary tree ?

       Binary Trees offer logarithmic complexity forall operations. If we need quick look up as well as a requirement to iteratethe contents of the container in order, a binary tree is a good candidate,Other wise it may be better to use a hash table with a good hash function.Without balancing, the binary tree can deteriorate into a linked list for aworst case data set. Implementations like Red Black Trees have O(logn)complexity for search, insert and delete operations.

  • Q4: When would you usea Hash Table ? What is the time complexity of operations in a hash table ? Howis a Hash Table implemented ?

       Hash Tables offer constant O(1) averagecomplexity, provided the hash function has a uniform distribution. A hash tablewith few or no collisions can perform look ups at O(1). The average timecomplexity of an insertion or deletion is O(1). However the worst case timecomplexity is O( n ) due to re-hashing. Expect the candidate to talk aboutbuckets, Hash function, Collision resolution (separate chaining, openaddressing etc.. - http://en.wikipedia.org/wiki/Hash_table), re-hashing, load factor, how to reducerehashing.

  • Q5: What is a stablesort ? Do you know the Best, Worst case run time for the following sorts ?

       A sort is considered stable, if it maintains the relative order of equal values inthe data set (that is to be sorted).

       QuickSort - Best nlogn Worst n2

       Merge Sort- Best nlogn Worst nlogn

       Insertion Sort Best n Worst n2 

       Counting Sort - n + r (where r is the range ofnumbers to be sorted)

SQL (10 Points)

  • Q1: How do I selectall rows (and all columns) from a table called Person? (3 points)

       A: select * from Person

  • Q2: What‘s a primarykey? What‘s foreign key? (4 points)

       A: A primary key is used to uniquely identifyeach row in a table. The values that compose a primary key column are unique;no two values are the same.

       A: A foreign key is a field in a relationaltable that matches the primary key column of another table. 

  • Q3: How do I selectall the rows in table Person whose PersonID? value is also present in table Audit?What type of join is this? Describe the other type of join? (3 points)

       A: select * from Person P inner joinAudit A on (P.!PersonID = A.!PersonID)

       or select * from Person where PersonID in(select PersonID from Audit)

       A: This is an INNER JOIN.

       A: A LEFT|RIGHT OUTER JOIN is all ofthe records in the LEFT/RIGHT hand (primary) table with any matching rows fromthe other (secondary) table in the query. Where matching rows are not found inthe secondary table NULLs are returned for the missing column data. Thejoin is either LEFT orRIGHT indicating which table to use as theprimary table i.e. the table whose complete set of rows is kept. 

 

Object-Oriented Programming

 

What is the difference between an interface and an abstract class?

ð  (long answer) – I like to hear something about how an interface defines a “role” something can perform, while an inheritance relationship provides a set of base behavior that something can “specialize on” or “extend”;

 

What is polymorphism?  Provide a real-world example where this is useful.

ð  (long answer) – something about different behaviors for a common interface / set of method signatures;

 

Why is the Main method or application entry point a static?

 

What is the difference between the keywords override and new when applied to a method in C#?

ð  The new keyword is used to hide a base implementation – casting to the base type will still call the base implementation;

 

Name some of the built-in interfaces you have used in C#.

ð  IDisposable, IComparable, ICloneable, etc.

 

Name some design patterns you have used.

ð  Singleton, Abstract Factory, Builder, etc.

 

Can you declare an overridden method as static?           No

Can a static method be declared as virtual?                    No

Can you override a private virtual method?                     No

ð  trick question – compiler will not allow you to declare a private method as virtual;

Can an interface method be declared as virtual?             Yes

 

What does protected internal mean?

ð  Access to a class member is restricted to the assembly containing the class, or to types derived from the containing class;

Multi-Threading

 

What is the lock keyword used for?

ð  Synchronization – Prevents simultaneous execution of a block of code by more than one thread at the same time.

Mention some alternative mechanisms to achieve synchronization in C#.

ð  Reader-Writer Lock, Monitor.Enter/Exit

 

How do you create a thread?

ð  new Thread(), ThreadStart, thread.Start()

ð  thread.Name, thread.IsBackground

 

What does the thread.IsBackground property do?

ð  background thread will terminate once the last foreground thread has stopped.

ð  NOT related to the priority of the thread!

 

Web Services

 

What is the class to inherit from to create a web service?

ð  System.Web.Services.WebService

 

How do you expose a method in a web service?

ð  Apply the attribute [WebMethod] to the method

 

What is WSDL?

ð  Web Service Definition Language

 

What exception is normally thrown when a call to a web method fails?

ð  System.Web.Services.Protocols.SoapException

 

What is the DynamicUrl property?

ð  Dynamically sets the URL used to access a web service from a WebReference.

SQL

 

What is normalization?

ð  Eliminating duplication of data in a table or across tables, by optimizing data structures using entity relationships, such as parent/child, many-to-one, etc.

 

What is referential integrity?

ð  Use foreign keys to enforce constraints between entities, such as parent/child; ensure relationship-integrity requirements are met for inserts, deletes, updates, etc.

 

What are the types of indexes?

ð  Clustered, non-clustered

What is a covered index?

ð  A covered index is an index that can satisfy a query just by its index keys without having the need to touch the data pages. This is one of the fastest methods to retrieve data in SQL Server.

 

What are the types of joins?

ð  INNER, LEFT OUTER, RIGHT OUTER, CARTESIAN PRODUCT

What is a FULL OUTER join?

ð  A join which returns back all rows between the tables involved matching the where clause and with NULLS where the join condition has failed to be met

 

What are the pros to writing stored procedures?

ð  Maintainability, reusability

ð  Performance – the first time the proc is executed, the execution plan is cached on the server;

 

How would you find out who is currently accessing the database?

ð  sp_who, sp_who2

 

Why should you not name stored procedures with the prefix “sp_“ ?

ð  This is the standard prefix for built-in procs, so naming a user-defined proc with this prefix will result in poor performance – SQL Server will loop through the master db before looking at the actual db for the stored proc.

 

What is the difference between the DELETE and TRUNCATE commands? In what situations can you not use truncate?

ð  DELETE command removes the rows from a table based on the condition that we provide with a WHERE clause. TRUNCATE will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.

ð  TRUNCATE will not work when there are Foreign Key references present for that table.

 

What is the most efficient method of deleting a large number of records from a table that has multiple foreign keys?

ð  Batch delete to reduce the load on tempdb; (could delete/recreate relationships but this would require DBO permissions)

 

What is the difference between WHERE and HAVING?

ð  WHERE is used to filter a set of results from a SELECT or other query, but HAVING is used to filter intermediate records in an aggregation step, used in conjunction with a GROUP BY statement.

 

What is the difference between UNION and UNION ALL?

ð  The ALL keyword includes duplicate rows in the combined result set.

 

What does the keyword NOLOCK do?

ð  A NOLOCK hint is a hint to the SQL Server to perform a query (only applies to SELECT) without taking out any locks on the affected objects. It is essentially a dirty read (i.e. it can read uncommitted transactions).

 

What command can be used to determine how much transaction log space is being used?

ð  dbcc sqlperf(logspace)

 

How do you measure the performance of a stored procedure and investigate issues?

ð  (Should hopefully say something about viewing execution plan in Query Analyzer)

 

JI_5