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

It's called compression. Not everything can be compressed in a way that will produce gains, but often text written in a natural language can benefit at least somewhat from compression.

- Anonymous July 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

String type in Java is Immutable i.e. if you do any operation it creates a new string. So if dealing with large number of Strings using StringBuffer is a better alternative.
Storing :: We can store strings in a trie.

- loveCoding July 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

is there a way to save strings in some other format inorder to save on bytes occupied by strings ? u r working on limited memory .

- chad July 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Tries can actually have high space usage.

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

Stringbuffer can be used

- Shobhit July 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Drawback of String is being the immutable that you have to create a new instance all time. As suggested stringbuffer is the way to go.
A trie could be used on this as well - but the question specifically mentioned that there is no space - so I would go by something space worthy which would be compression.

- ethioer July 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Strings are immutable. Any new string defined or changed (I.E. by calling any method on string) always creates a new string. All these new strings are present in common string pool (for the sake of re-usability). So, use string builder to keep one string and do a lot of changes to it without filling up the string pool. Event better, use char arrays for extreme efficiency.
As far as saving space goes, use an encoding which can accommodate all your character s in minimum bytes, plus, use compression algorithms (will cause CPU overhead).

- level42 July 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

As mentioned above we can use Trie structure. Tries takes use the fact that many of such string will share the same prefix. For a common prefix it allocates memory only once.

- Ashok July 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Increase the Permgen space..

- Dinakar July 17, 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