Bloomberg LP Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
1
of 1 vote

Vector is a well-designed data structure that takes care of many edge cases that char* would have failed at (or coded manually):

push and pop (tail only)
resize
reverse iteration (can retur a reverse iterator)

There are other goodies but those ones are major operational benefit that wins over array.

The Vector has more memory usage than a corresponding-size array due to its overhead and memory reserveration for expansion.

The c array can be very efficient when used correctly but it is quite difficult to do that.
A veteran c programmer can probably do resize, garbage collection, push/pop and other operation on the fly and claim it's so much more efficient that everybody should do it. but how much time does it take him to code all these? Manager don't like to wait, nor customers.

It's a choice, not a rule. I would explain this to interviewer and if he still not happy with using a Vector, I tell him I will make an effort to learn c array prior to start. That should be safe.

- Sudo Man March 31, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think one of the main advantages is that vector automatically frees allocated memory while you can forget to do this in case of c array leading to memory leaks..

- Anonymous April 03, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Why would vector free up memory?

- BJ September 15, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Static array would not lead to memory leak.

- orangetime23 May 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Vectors have flexible size, C array has constant size.
When we pass a C Array to a function, we have to pass the size of the array also. Vectors know their size.
Vectors have options whereby we do not cross over the boundaries.
Every time Vectors need to increase their size, the system does it for us. This increment is based on some algorithm and is optimized. With C array it is left to us to determine how much to increase the array size. Generally speaking we cannot do as good an estimate as the program.
Because Vector is a class and C array is not, Vector users benefit from all the advantages of the class. The advantages of the class include inheritance, encapsulation, polymorphism, overloading, etc.

- ACK December 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Vectors are good at:
Accessing individual elements by their position index (constant time).
Iterating over the elements in any order (linear time).
Add and remove elements from its end (constant amortized time).

- Ajay Yadav Aricent June 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A vector has an underlying array, because the specification requires the use of a block of continuous memory. Which is what a C array would be.
How is vector more efficient than a C array? It's not! A vector introduces overhead due to various checks upon its method calls. For example, it checks whether it needs to grow. If you use a plain array, which is basically a chunk of continuous memory, you will access it very directly with no frills, resulting in slightly better performance.

- Antonio January 18, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Could be that the vector does not need any specific ordering of elements like a heap !!

- Anon1 March 30, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Could be that the vector does not need any specific ordering of elements like a heap !!

- Anon1 March 30, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More