Serving the Quantitative Finance Community

 
User avatar
saliq
Topic Author
Posts: 0
Joined: April 10th, 2005, 1:55 am

C++ program in Interview..

April 4th, 2007, 10:33 am

Can Someone tell me, some points to consider ,in case when there is a big task (in 2 hour time) in technical test to develop a C++ program on PC ? So what sort of general programming techniques would be suitable to show my skills in C++..regardsSaliq.
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

C++ program in Interview..

April 4th, 2007, 12:34 pm

You should knowCopy constructorsauto_ptrsome exceptions safetybasic algoritms in STLnot to return pointers to stack objects (I'd guess 50% of all interviews have that one)
 
User avatar
shettydiwakar
Posts: 0
Joined: January 21st, 2007, 5:49 am

C++ program in Interview..

April 4th, 2007, 4:54 pm

QuoteOriginally posted by: DCFCYou should know> Copy constructors> auto_ptr> ........Remove auto_ptr from that list. Once you start using it for real life programs, you would soon realise that you are better off using the raw pointer or Boost:shared_ptrThanksDiwakar
 
User avatar
twofish
Posts: 0
Joined: February 18th, 2005, 6:51 pm

C++ program in Interview..

April 4th, 2007, 6:01 pm

QuoteOriginally posted by: shettydiwakarQuoteOriginally posted by: DCFC> auto_ptr> ........Remove auto_ptr from that list. Once you start using it for real life programs, you would soon realise that you are better off using the raw pointer or Boost:shared_ptrrThat's what you should know :-) :-) :-)
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

C++ program in Interview..

April 5th, 2007, 7:13 am

shettydiwakar is wrong, as is twofish.I am a headhunter they aren't. I include several types of pointer in my lectures, and the shettydiwakar's remark about raw pointers tells me a great deal about how he writes his code, not all of that is good.Someone who said that when being interviewed by me would either fail utterly, or have a very good explanation of why it makes sense. You would get more points for the latter, but is a high risk strategy.We can have an argument over the relative merits of smart pointers if you like, but the question was about what could quickly be learned for an interview.I was thus optimising probability of being asked with respect to the time available to learn it.That's not the same as saying a good programmer knows X.Yes of course I want newbies to know Boost, but typically they don't.If we're talking of pointers, I'd expect someone who said they knew better than me to go beyond sequence points, page optimisation, write locking and inline optimisation.Interviews are often at least partly free format, and a good interviewer will drill down.That means if you say something like "raw pointers are better than auto_ptr" you will have to justify that, and that would include at an absolute minimun that you could intelligently discuss the implementationof smart pointers using only that which you happen to remember or work out in real time.You feeling lucky punk ?A person who could explain threading issues in auto_ptr would do very well indeed, but on the real world you're not going to get that far in a day or two.
Last edited by DominicConnor on April 4th, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
ananihdv
Posts: 0
Joined: August 8th, 2006, 8:02 pm

C++ program in Interview..

April 5th, 2007, 10:55 am

auto_ptr is still a hot interview question though it is not used in practice. I was asked to explain why they don't work with stl containers.
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

C++ program in Interview..

April 5th, 2007, 11:20 am

Indeed, in some ways they are too compatible with raw pointers...A great answer is of course to explain which of the smart pointers, preferably from Boost that you'd use instead.The best answer is to demonstrate understanding of the design issues that lead you into the place where you're making this decision, and whether that is good or not.
 
User avatar
shettydiwakar
Posts: 0
Joined: January 21st, 2007, 5:49 am

C++ program in Interview..

April 5th, 2007, 1:14 pm

> QuoteOriginally posted by: saliq> in case when there is a big task (in 2 hour time) in technical test to develop a C++ program on PC ? > So what sort of general programming techniques would be suitable to show my skills in C++..Saliq, Here are the programming techniques which I would look out for:(You can try out the "banker-tellers, bank mgr and customers problem)1) How extensible is the design ? (For e.g: If your problem states two types of accounts (Savings & Current), how much code change would be involved if 2 months down the line a third type of account is required to be added. Polymorphism feature of any OO language would help you here)2) How much less of reinventing of wheel is being done ? (For e.g.: STL algorithms and GoF design patters would help here)3) How good are the unit test cases and functional test cases ? (For e.g: Writing the test cases first helps) (If you have an automated test harness then nothing beats it, but in 2 hour test its difficult)4) How much code duplication is there ? (For e.g: Breaking into small reusable functions helps)5) Is the code efficient to a reasonable degree ? (For e.g.: Avoiding unnecessary copies when references would do) (For e.g: Usage of appropriate STL containters instead of say "vector" everywhere) (For e.g: If making blocking calls then usage of multi-threading) (Use the 80-20% rule if existing code has to be optimised)6) Does the code handle most of the exceptions ? (For e.g. at least log the exception before re throwing when you cant handle it)7) Does the code contain "assert" stmnts for debug build ?8) Does the code contains logging for debug, and various levels at run time ? (For e.g: Use a open source logging lib like pantheios with which you can change the logging levels at run time)9) How well the code is documented ?Thats all I can think for now.DCFC,Maybe you are right. Maybe usage of auto_ptr would be appropriate depending upon the requirement.But I would still stick to my original statement.ThanksDiwakar
 
User avatar
saliq
Topic Author
Posts: 0
Joined: April 10th, 2005, 1:55 am

C++ program in Interview..

April 5th, 2007, 11:30 pm

Thanks guys for ur response.So far I had 2 C++ assesment test at different places. And What I found in both places, that the problem involve some processing and calculation on data and they want data to be generic in term of size and values.So I found map and multimap structres are very important which could be usefull to find relative entries from various dataset. and with iterators to procees data and perform some calculation, however there are also some class designing which I belive need good skills to work on datasets.therefor the thing to consider that I found so far are:1: Data file loading and typecasting string to numerics2: Map and Multimap with Iterators 3: Strong Class Designing with some dynamic memory allocated member 4: String oprations5: some mathematical calculations that could be vary on problem to problem.In addition the important point that i feel is lack of practice on C++ , because in test there was no help or MSDN so somethings which i could workout very easily at home, took long time to figureout in term of syntax and in term of built-in library fuctions.regardsSaliq
 
User avatar
Cuchulainn
Posts: 22926
Joined: July 16th, 2004, 7:38 am

C++ program in Interview..

April 6th, 2007, 7:34 am

Quote(For e.g: Usage of appropriate STL containters instead of say "vector" everywhere)Yes, that's a bit like having a toolbox but I use a hammer for everything!In the past students did a course on Data Structures and Complexity Analysis and then you know when to use vector versus list versus map etc.Using the wrong container may affect performance
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

C++ program in Interview..

April 6th, 2007, 8:07 am

Saliq has a valid point, a good programming test should be "open book", and sometimes I've done it that way myself.In that scenario I've had stuff set up on a laptop, and said "make it do X".An interesting issue is whether you want someone who knows Boost multi_index, or someone who can spend 2 minutes on that section of a manual and learn it quickly ?One accidental byproduct of the CQF C++ stuff I've been doing has been a set of worked problems, which I rather fancy turning into an evaluation of people's ability.For entry level people, it would go like:Here is a file of price data, it covers N stocks. Depending upon experience, I'd ask them what attributes they'd expect to find in that sort of data. Calculate the vol of these stocks.The data will contain a few values that are clearly wrong, negative, too large etc.Can they filter, how intelligently ?Do they cope with numeric exceptionsYou then get told that the file contains bond data as well.Can their data input routine cope with data that has varying attributesAsk them what analytics they would do on bonds, and get them to write them.At some point they ought to be able to articulate what patterns they are choosing to use.Are they making good choices between inheritance and templates ?Is data being stored in sensible containers ? Can they explain their choice or do they bung everything in a vector<> ?Thing is would employers pay 4-500 per candidate for a test, when online tests cost 20-50 ?Is a better test carried out by human worth ten times as much...
 
User avatar
samyonez
Posts: 0
Joined: October 7th, 2004, 10:01 am

C++ program in Interview..

April 7th, 2007, 10:20 am

hi saliqthat's certainly information worth knowing on the format of your testing...can you divulge who you were interviewing for? (you can pm me if you like)does anyone else have any inside info on what's the format of c++ tests at 1st tier banks? i have a 2nd round coming up shortly, i think, & they are looking for an "exceptional" c++ guy, so i guess it's going to be pretty intensive.i'm hoping for something exactly along the lines of what dcfc suggests - "Here's a laptop with your favourite compiler, boost, internet access to get to all your usual resources. Here's the task. Away you go.", then with some discussion afterwards of whether i can justfy what i did and the way i did it.i fear paper based tests, multiple choice, having to write algorithms with a pen, etc. these are the kind of things i've faced before, admittedly at smaller institutions and for lesser positions. Anyone else any ideas or first hand experience of what the practice is?
Last edited by samyonez on April 6th, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

C++ program in Interview..

April 8th, 2007, 3:49 pm

I know of no bank that does live C++ testing with a PC, so samyonez is not likely to get what he wants, and frankly should be getting.One of the reasons that I'm not impressed with banks testing is that the set of questions asked is not actually that large.Smayonez you have a pm...