Bloomberg LP Interview Question for Financial Software Developers


Country: United States
Interview Type: Phone Interview




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

There are many ways to implement this in C++

Basically it runs on the algo where you need to make sure the Object in Context is having any reference or not.

One simple implementation uses something called a Counter Class which basically Counts the number of reference to a particular object. So when the reference becomes 0, it deallocates the memory.

Another and more prominent way uses something more in complex algo. This is a daemon that is schedule to run periodic to check the object is in the state of removal or not and for every such check it increments the counter. Actually this algo is beyond the scope of discussion here but being real time implemented in case of JVM Garbage Collector.

- hprem991 February 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Reference Counting for each object. Deletion is triggered when counters reach down to 0
2. Periodically check all heap objects. Deletion is triggered if there is some object which has no reference pointing to.
There is some naive idea to implement 2) in a way of customization.
a) customize or overload new operator such that all used heap addresses are stored in @HeapObjects.
b) customize a new reference/pointer class such that all references are stored in @References.
c) delete (HeapObjects - References) set of objects.
Triggers for 2) is arguable. Some designs except peridoic checking are setting upper bound of used heap, etc. (not much from at top of my head)

- waiging.lau February 18, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can set aside a ctr for every space that we allocate using new. This ctr will contain the number of ref for that space.

Scanning for every ctr after some time interval, and it ctr is 0 then that memory is garbage.

- DashDash February 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Read cracking the coding interview (smart pointers)

- balani.kunal June 10, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In c++ it makes no sense to mimic java reference graphs. A more practical approach is to use a factory design pattern and use smart pointers.

- Noobie December 22, 2013 | 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