C#.NET collections — Which of the following types are present in the System.Collections.Generic namespace? 1) Stack 2) Tree 3) SortedDictionary 4) SortedArray

Difficulty: Easy

Correct Answer: 1 and 3 only

Explanation:


Introduction / Context:
The System.Collections.Generic namespace provides strongly typed collections. Knowing what types actually exist there is a common interview and exam topic.



Given Data / Assumptions:

  • We compare four names: Stack, Tree, SortedDictionary, SortedArray.
  • We focus on generic collections.


Concept / Approach:
System.Collections.Generic includes Stack and SortedDictionary. There is no generic type named Tree in the BCL and no type named SortedArray (a sorted array is an algorithmic concept, not a built-in collection class).



Step-by-Step Solution:

Identify known types: Stack → exists; SortedDictionary → exists.Eliminate non-existent types: Tree (no such BCL type), SortedArray (no such BCL type).Therefore, 1 and 3 are correct.


Verification / Alternative check:
Browse the namespace reference listing; you will also see List, Queue, Dictionary, SortedList, HashSet (later), etc., but not Tree or SortedArray.



Why Other Options Are Wrong:
They include types that are not part of the namespace.



Common Pitfalls:
Assuming “Tree” exists because many data structures use trees internally. The BCL exposes dictionaries and sorted lists, not a raw tree interface.



Final Answer:
1 and 3 only

More Questions from Generics

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion