These snippets represent general algorithms, in this case programmed in Java.
EXAMPLE FOR LOOP AND RESTARTING THE CYCLE IN AN ARRAY:
EXAMPLE FOR MODIFYING ARRAY CAPACITY:
EXAMPLE FOR FINDING AN ELEMENT VIA STREAM:
EXAMPLE FOR RECURSIVE SORTING:
EXAMPLE FOR LINKED LIST:
EXAMPLE FOR DOUBLE LINKED LIST:
EXAMPLE FOR QUEUE:
Round Robin structure:
the queue is made from series of collections or arrays forming a pool (here: ArrayList<Iterator<String>>)
the pool has an actual index which shows from which collection or array will be the next pulled element taken
push adds a new collection or array to the end of the pool
pull gets the first element (here: String) from the actual collection or array (here: Iteration<String>) in FIFO fashion, then jumps to the next collection or array
EXAMPLE FOR ROUND ROBIN QUEUE WITH ARRAYLIST OF STRING ITERATORS:
Round Robin structure:
the queue is made from series of collections or arrays forming a pool (here: Queue<Iterator<String>>)
the pool (Queue) follows the FIFO model
push adds a new collection or array to the queue
pull gets the first element (here: Iteration) from the queue, process the next element in it (FIFO), then add it to the queue (it will be processed again after the original last element)
EXAMPLE FOR ROUND ROBIN QUEUE WITH QUEUE OF STRING ITERATORS:
Palindrome:
the given string and its reversed form are identical (A, AA, ABA, ABBA, A A, A A, A B A, AB BA)
spaces are usually used in checking
EXAMPLE FOR CHECKING PALINDROME:
EXAMPLE FOR CLEANING SPACES AND NON-VISIBLES:
EXAMPLE FOR FINDING PRIMES WITH SIEVE OF ATKIN:
The technique gives rare chance of overlapping hashcodes for different strings.
Therefore, generate 2 hashcodes with different moduluses, and use them in pair, which significantly decreases the chance of overlapping.
Generated code interval: [0, modulus).
EXAMPLE FOR GENERATING SINGLE HASHCODE WITH POLYNOMIAL ROLLING OF STRING KEYS:
EXAMPLE FOR GENERATING HASHCODE PAIR WITH POLYNOMIAL ROLLING OF STRING KEYS: