Goldman Sachs Interview Question for Analysts






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

List
-Searching O(n)
-Inserting, deleting, moving O(1)
-Elements may be ordered. (order from which they are added)
-Elements may be sorted.
-Elements may be duplicate.

Set
-Searching (logarithmic in size).
-Insert and delete (logarithimic in general).
-Elements are un-ordered. (they are sorted on insert, doesn't keep the order it was inserted)
-Elements are always sorted from lower to higher.
-Elements are unique.


a set is always sorted, a list can be sorted on insert too depend on setting.
a set is kind of a subgroup of a list with more restriction but better performance.
Just remember that values are unique.
As far as I know a set is sorted, but I'm sure this is a debatable subject, might be some people that created set object/list that aren't sorted on insert... but as far as I know, a set is suppose to sort value on insert...

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

In addition, set contains data in sorted order whereas list does not.

- rajendra February 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@rajendra: (5,4,2,1,3) is also a set but not sorted.... Set is just a collection of distinct elements..

- Anonymous February 21, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

also @rajendra: list generally preserves order while set does not guarantee it.

- woohoo February 27, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Set doesn't maintain Order of insertion but List does.

- Amar August 26, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

List is implemented as doubly link List. so we can push element at the back and front . similarly we can also pop element from back and front . complexity for push and pop is O(1).

Sets are containers which store only unique values . The values in the sets are stored in some specific order (like ascending or descending). compexity for inserting and searching any value is O(logN) .

- rahulgoyal030 July 04, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Set does not allow duplicates and list allows duplicates

- Anonymous January 27, 2011 | 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