Implementing hash function and using it into Own implemented HashMap

First what is a hash function? A hash function is a function which maps keys to indices of an array. So if k is the key and we have an array of size 10, then h(k) will be some integer value ranging between 0 to 9. So this means the hash function h maps the ...

Circular Queue implementation in Java using array. 3

Queue is an abstract data type which support below operation. new() – > for making new Queue. enqueue() – > insert element at rear. dequeue() – > remove an element from front. Supporting methods will be : size() isEmpty() isFull() Let’s start implementation of Queue via circular array. Below is the circular array: In queue ...

Implementing Own Stack in Java 3

Lets implement own Abstract Data Type : Stack. So stack is an abstract data type which support LIFO i.e last in first out. Lets now have a look what are the operation it will support: 1. new -> making a new stack 2. push -> insert an object 3. pop -> remove the top object ...

To find out whether your single linked list is circluar 2

Problem is : How to find out whether your single linked list is circluar. Lets have a look on the “The Tortoise and the Hare Algorithm”. Time Complexity :  O(n) Simultaneously go through the list by ones (slow iterator) and by twos (fast iterator) or there will be one slow pointer and one will be ...

Intersection of Two Linked Lists 1

The linked list L1 is  (1 -> 2 -> 3 -> 7 -> 8 -> 9 -> 4 -> 5 -> 6) having a length n and linked list L2 is (-1 -> -3 -> 9 -> 4 -> 5 -> 6) having a length m. So above both L1 and L2 are intersecting at ...