Introduction to Singly Linked ListSingly Linked List is a variant of Linked List which allows only forward traversal of linked lists. This is a simple form, yet it is effective for several problems such as Big Integer calculations. A singly linked list is made up of nodes where each node has two parts:
The beginning of the node marked by a special pointer named START. The pointer points to the fist node of the list but the link part of the last node has no next node to point to. The main difference from an array is:
In Singly Linked List, only the pointer to the first node is stored. The other nodes are accessed one by one. To get the address of ith node, we need to traverse all nodes before it because the address of ith node is stored with i-1th node and so on. Binary Search on Singly Linked ListGiven a singly linked list and a key, find key using binary search approach.
In main function, function InsertAtHead inserts value at the beginning of linked list. Inserting such values(for sake of simplicity) so that the list created is sorted. C++
Java
Python
C#
Javascript
Output:
Present
Time Complexity: O(N)
Article Tags :
Divide and Conquer Linked List Searching
Binary Search Practice Tags :
Linked List Searching Divide and Conquer Binary Search |