For sorted array, binary search works with O(logn) time complexity.
A hash set is a data structure offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. There are a number of ways of implementing this data structure. This post is about the simple implementation of hashmap in Java using an array of a linked list.
A hash map (or hash table) is a data structure that maps keys to values for highly efficient lookup. There are a number of ways of implementing this data structure. This post is about the simple implementation of hashmap in Java using an array of a linked list.
The Queue ADT stores arbitrary objects and insertions and deletions of this ADT follow the first-in-first-out (FIFO) scheme i.e. insertions are at the rear of the queue and removals are from the front of the queue. As in a line or queue at a ticket stand, items are removed from the data structure in the same order that they are added.
The classic problem of the Towers of Hanoi is a mathematical game or puzzle, where you have 3 towers and N disks of different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending order of size from top to bottom, the smallest at the top, thus making a conical shape.
Memoization is a technique for implementing dynamic programming to make recursive algorithms efficient. It often has the same benefits as regular dynamic programming without requiring major changes to the original more natural recursive algorithm.
The Stack ADT stores arbitrary objects and insertions and deletions of this ADT follow the last-in-first-out (LIFO) scheme like a spring-loaded plate dispenser.
Data structure is an efficient way of organizing data for storage and access by an algorithm where as an algorithm a step by step procedure for performing some task in a finite amount of time. Algorithms and data structures are closely linked to each other.
An algorithm is a step-by-step procedure for solving a problem in a finite amount of time. The procedure should be sequential and deterministic.