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 several
    thread-safe objects (or your platform of experience, e.g. Unix, Java). (2 points)

A: Critical
Section, Event, Mutex and Semaphore, scoped lock, other
types of boost data structures. Metered Section is rare.

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

A: They synchronize exclusive access to shared
data between threads within a single process. Because the critical section does
not have a named kernel object associated with it, one of its main
disadvantages is that it cannot synchronize access between processes.

A: As long as no contention for gaining access
to a critical section exists, the critical section code runs entirely in user
mode, making it extremely fast. When there is contention for a critical
section, however, all is not lost; it simply falls back to using a kernel event
object 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 is
already held by Thread 2 and thus Thread 1 blocks until B is released.

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

How to avoid:

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

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

Comment: commonly known as a Scope Guard

DATA STRUCTURES AND
ALGORITHMS (15 Points)

  •  Q1: How do you analyse, quantify, compare
    running time of different algorithms designed to provide solution for a given
    problem space.

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

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

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

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

Binary Trees offer logarithmic complexity for
all operations. If we need quick look up as well as a requirement to iterate
the 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 a
worst case data set. Implementations like Red Black Trees have O(logn)
complexity for search, insert and delete operations.

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

Hash Tables offer constant O(1) average
complexity, provided the hash function has a uniform distribution. A hash table
with few or no collisions can perform look ups at O(1). The average time
complexity of an insertion or deletion is O(1). However the worst case time
complexity is O( n ) due to re-hashing. Expect the candidate to talk about
buckets, Hash function, Collision resolution (separate chaining, open
addressing etc.. - http://en.wikipedia.org/wiki/Hash_table), re-hashing, load factor, how to reduce
rehashing.

  • Q5: What is a stable
    sort ? 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 in
the 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 of
numbers to be sorted)

SQL (10 Points)

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

A: select * from Person

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

A: A primary key is used to uniquely identify
each 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 relational
table that matches the primary key column of another table.

  • Q3: How do I select
    all 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 join
Audit 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 of
the records in the LEFT/RIGHT hand (primary) table with any matching rows from
the other (secondary) table in the query. Where matching rows are not found in
the secondary table NULLs are returned for the missing column data. The
join is either LEFT orRIGHT indicating which table to use as the
primary 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)

时间: 2024-07-31 15:55:48

JI_5的相关文章