Saturday, May 11, 2013

A Simple Collection of Complex Objects or the Complex Collection of Simple Objects, which one is better ?

This questions seems quite abstract at the very first glance and its little difficult to find the intent of the interviewer here.

Interviewer is definitely asking something about the data structure and algorithms here.

"A Simple Collection of Complex Objects "
As it states that very complex objects with all kind of business logic inside them are stored in a simple collection like an simple Array.

"Complex Collection of Simple Objects"
Objects are simple in this case but the collection holding these objects is complex in nature like auto-balanced binary tree - red black tree holding collection of employee objects (which is just a POJO with minimal or no logic in it)

Complex collections are build to solve problems of performance & scalability. Thus using a red-black tree we can expect a logarithmic time for locating the next smaller sibling which otherwise is not possible using a simple array of complex objects. Thus its a open question for the discussion with interviewer if he looking for performance & scalability or something else ?

No comments:

Post a Comment

Your comment will be published after review from moderator