Monday 6 June 2016

Microsoft .Net Framework internal implementation Binary Search in List (Collection) - Data structure

                 In Dotnet framework System.Collections is a namespace where we can find the collection class like Stack, Queue, LinkedList ,List etc.Now in this article we are going to see the real implementation of List inside the framework and explanation of how we are using the List in our code.

                          It is designed to be fast for internal implementations, It contains lot of useful operation such as Binary Search,Sort etc.The methods on List are not virtual and so cannot be overridden.Let we see the How to code List and get the data from that collection. In List  T refers to the datatype of the collection , so because of this declaration boxing and unboxing are avoided in storing and retrieve the data from collection. We can store any type . Each type have individual object.



Output : 



Now let we see the implementation of Binary Search in List class internally in framework. This algorithm is used to find the Element exist in List and return the index of that element.

Binary Search is actually implemented in Array , It is called from List for check the item exists.

Code for Binary Search Tree :








From this article we can see the Algorthim BinarySearch used for search the item exist in List

No comments:

Post a Comment