Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Interview question for Bloomberg in NYC

171 views
Skip to first unread message

Robert Hutchings

unread,
Nov 10, 2014, 1:42:48 PM11/10/14
to
Hi all,

Here is a question from Bloomberg ----

Given the following structure Record and we have million of records on disk.

struct Record
{
char[257] name;
int startTime;
char[257] description;
}

Now we want to keep a in-memory cache which is represented in class
ManageRecords to perform 2 methods GetDesriptions and GetRecords.
Given that we have very big memory and we can use any data structure so
that the 2 methods can be performed really quick.
Here are the questions:

1. what should be the return type for method GetDesriptions
2. what should be the return type for method GetRecords
3. what data structure should we use in the private part as commented
out below


class ManageRecords
{
public:

ManageRecords();

? GetDesriptions(char[] name);

? GetRecords(int begin, int end); //do a range search based on
startTime of structure Record

private:

// what data strcture should we use here?
}

Wouter van Ooijen

unread,
Nov 10, 2014, 1:58:41 PM11/10/14
to
Robert Hutchings schreef op 10-Nov-14 7:42 PM:
> Hi all,
>
> Here is a question from Bloomberg ----
>
> Given the following structure Record and we have million of records on
> disk.
>
> struct Record
> {
> char[257] name;
> int startTime;
> char[257] description;
> }
>
> Now we want to keep a in-memory cache which is represented in class
> ManageRecords to perform 2 methods GetDesriptions and GetRecords.
> Given that we have very big memory and we can use any data structure so
> that the 2 methods can be performed really quick.
> Here are the questions:
>
> 1. what should be the return type for method GetDesriptions

GetDesriptions
------=------=

I don't want no desriptions!

More seriously, what do kind of answer do they expect for something that
seems to return multiple things? Maybe a class that has begin() and
end() methodes to facilitate

for( auto & record : GetDesriptions() ){
do a lot of desriptive things
// should deleting a record and/or changing
// its description be allowed here?
}

Or maybe they expect a container that contains copies of those things?

Or a container that contains references, or shared_ptr's?

Or maybe it is a trick questions: no real specification => turn in an
empty answer?


Wouter

Robert Hutchings

unread,
Nov 10, 2014, 2:09:27 PM11/10/14
to
Yeah, I guess they want to see your thinking process on vague questions
like this...I would think that GetDescriptions would return a collection
of 1 or more "descriptions"??

Christopher Pisz

unread,
Nov 10, 2014, 2:14:41 PM11/10/14
to
You already know what they want.
They want to see if you are going to be silly and copy millions of
records by value or whether you know better.


Robert Hutchings

unread,
Nov 10, 2014, 2:19:53 PM11/10/14
to
One person answered the question with this...

"Have a balanced BST holding records sorted on timestamp. The question
will reduce to find nodes in given range in a bst. For descriptions keep
a hash with values pointer to the nodes in the balanced BST nad return
all matching descriptions".

Mr Flibble

unread,
Nov 10, 2014, 2:37:33 PM11/10/14
to
Extra point for not re-inventing the wheel and using std::set and
std::map instead.

/Flibble

Mr Flibble

unread,
Nov 10, 2014, 2:38:24 PM11/10/14
to
Or more realistically std::multiset and std::multimap.

/Flibble

Mr Flibble

unread,
Nov 10, 2014, 2:40:41 PM11/10/14
to
Or possibly even unordered_multimap.

/Flibble

Rosario193

unread,
Nov 10, 2014, 3:56:13 PM11/10/14
to
On Mon, 10 Nov 2014 12:42:26 -0600, Robert Hutchings wrote:
>Hi all,
>
>Here is a question from Bloomberg ----
>
>Given the following structure Record and we have million of records on disk.
>
>struct Record
>{
> char[257] name;
> int startTime;
> char[257] description;
>}

possibly it is better write as first element of struct int startTime;
because i believe that each recod for align that int waste 3 chars

>Now we want to keep a in-memory cache which is represented in class
>ManageRecords to perform 2 methods GetDesriptions and GetRecords.
>Given that we have very big memory and we can use any data structure so
>that the 2 methods can be performed really quick.
>Here are the questions:
>
>1. what should be the return type for method GetDesriptions

a pointer to char

>2. what should be the return type for method GetRecords

one u32 one index

>3. what data structure should we use in the private part as commented
>out below
>
>
>class ManageRecords
>{
> public:
>
> ManageRecords();
>
> ? GetDesriptions(char[] name);
>
> ? GetRecords(int begin, int end); //do a range search based on
>startTime of structure Record
>
> private:
>
> // what data strcture should we use here?

but if i have to choose [i not use private]:

public:

Record *a;

>}

Rosario193

unread,
Nov 10, 2014, 3:58:57 PM11/10/14
to
On Mon, 10 Nov 2014 21:55:58 +0100, Rosario193
<Ros...@invalid.invalid> wrote:

>On Mon, 10 Nov 2014 12:42:26 -0600, Robert Hutchings wrote:
>>Hi all,
>>
>>Here is a question from Bloomberg ----
>>
>>Given the following structure Record and we have million of records on disk.
>>
>>struct Record
>>{
>> char[257] name;

i don't know i know "char name[257];" not "char[257] name;"

Robert Hutchings

unread,
Nov 10, 2014, 4:15:43 PM11/10/14
to
Okay, when you said "one u32 one index" are you talking about a Struct?

Ian Collins

unread,
Nov 10, 2014, 4:38:47 PM11/10/14
to
Robert Hutchings wrote:
> Hi all,
>
> Here is a question from Bloomberg ----
>
> Given the following structure Record and we have million of records on disk.
>
> struct Record
> {
> char[257] name;
> int startTime;
> char[257] description;
> }
>
> Now we want to keep a in-memory cache which is represented in class
> ManageRecords to perform 2 methods GetDesriptions and GetRecords.
> Given that we have very big memory and we can use any data structure so
> that the 2 methods can be performed really quick.

Is that verbatim? The grammar looks like a Nigerian phishing scam...

--
Ian Collins

Robert Hutchings

unread,
Nov 10, 2014, 4:44:51 PM11/10/14
to
No, it's from a web page that is supposedly an "interview prep"
site...and, yes, the grammar is strange...

Ian Collins

unread,
Nov 10, 2014, 4:56:27 PM11/10/14
to
That, couple with the near 50% syntax error per line ratio says all that
needs to be said about that site.

--
Ian Collins

Rosario193

unread,
Nov 10, 2014, 5:10:42 PM11/10/14
to
u32 isize;

i forgot to write the size index

so at end of construction "a" point to space for number isize Record

>>> }
>>
>Okay, when you said "one u32 one index" are you talking about a Struct?

one array of structs Record

so a[0] would be the first record and a[isize-1] the last record
Record...

Chris Vine

unread,
Nov 10, 2014, 7:54:31 PM11/10/14
to
On Mon, 10 Nov 2014 12:42:26 -0600
Robert Hutchings <rm.hut...@gmail.com> wrote:
> Hi all,
>
> Here is a question from Bloomberg ----
>
> Given the following structure Record and we have million of records
> on disk.
>
> struct Record
> {
> char[257] name;
> int startTime;
> char[257] description;
> }

If you look carefully I expect you will find that this is a site
concerned with the D language. It seems difficult to believe the site
could be as incompetent as to claim that it is valid C or C++.

What's the URL?

Chris

Mr Flibble

unread,
Nov 10, 2014, 8:14:38 PM11/10/14
to
For some strange reason I parsed it as valid C++ probably because my
thought process dismissed the idea of it being 100% wrong C++.

/Flibble

Message has been deleted

Robert Hutchings

unread,
Nov 11, 2014, 8:08:04 AM11/11/14
to
Here is the website I was given (by a recruiter)
http://www.careercup.com/question?id=5641227835801600

Drew Lawson

unread,
Nov 11, 2014, 1:29:03 PM11/11/14
to
In article <b6qdnaOUnKpv__zJ...@giganews.com>
Y'all have far different experiences with interview questions than
I do. I would expect that the hoped for response would start with
"Disregarding the inverted syntax . . ."

IIRC (it's been a year), one of the code examples I was handed when
interviewing for the current job had some problems that were expected
to be obvious. It is a quick way to screen out the people with
over-padded resumes.


--
Drew Lawson | What is an "Oprah"?
| -- Teal'c
|

Richard

unread,
Nov 11, 2014, 4:12:28 PM11/11/14
to
[Please do not mail me a copy of your followup]

dr...@furrfu.invalid (Drew Lawson) spake the secret code
<m3tkgq$19h5$1...@raid.furrfu.com> thusly:

>IIRC (it's been a year), one of the code examples I was handed when
>interviewing for the current job had some problems that were expected
>to be obvious. It is a quick way to screen out the people with
>over-padded resumes.

Meh. I'm not such a fan of asking people to be a human compiler,
particularly on paper without a computer under interview conditions.

We have used a piece of code that compiles but has algorithmic errors
and told people "this code has 7 errors. How many can you identify?".
It hasn't been a particularly useful predictor, but it does give you
more information from which to build a picture of the candidate beyond
their resume.

The best predictor has been to give someone one or more coding problems
ahead of time and have them work a solution on their own time at their
own pace.

Even better than that is to pair program with them for a day.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

Jack Chuge

unread,
Dec 30, 2014, 10:07:44 AM12/30/14
to
Richard 於 2014-11-12 5:12 寫道:
> [Please do not mail me a copy of your followup]
>
> dr...@furrfu.invalid (Drew Lawson) spake the secret code
> <m3tkgq$19h5$1...@raid.furrfu.com> thusly:
>
>> IIRC (it's been a year), one of the code examples I was handed when
>> interviewing for the current job had some problems that were expected
>> to be obvious. It is a quick way to screen out the people with
>> over-padded resumes.
>
> Meh. I'm not such a fan of asking people to be a human compiler,
> particularly on paper without a computer under interview conditions.
>
> We have used a piece of code that compiles but has algorithmic errors
> and told people "this code has 7 errors. How many can you identify?".
> It hasn't been a particularly useful predictor, but it does give you
> more information from which to build a picture of the candidate beyond
> their resume.
>
> The best predictor has been to give someone one or more coding problems
> ahead of time and have them work a solution on their own time at their
> own pace.
>
> Even better than that is to pair program with them for a day.
>


Great points

--
Jack
0 new messages