Use the following problems to test your programming prowess based on arrays, collections, and data structures. I strongly encourage you to give each problem a try before you turn to the solutions and download the example programs:
- Sorting an array: Write several programs that exemplify different sorting algorithms for arrays. Also, write a program for shuffling arrays.
- Finding an element in an array: Write several programs that exemplify how to find the given element (primitive and object) in a given array. Find the index and/or simply check whether the value is in the array.
- Checking whether two arrays are equal or mismatches: Write a program that checks whether the two given arrays are equals or whether there is a mismatch.
- Comparing two arrays lexicographically: Write a program that compares the given arrays lexicographically.
- Creating a stream from an array: Write a program that creates a stream from the given array.
- Minimum, maximum, and average of an array: Write a program that computes the maximum, minimum, and average of the given array.
- Reversing an array: Write a program that reverses the given array.
- Filling and setting an array: Write several examples for filling up an array and setting all elements based on a generator function to compute each element.
- Next Greater Element (NGE): Write a program that returns the NGE for each element of an array.
- Changing array size: Write a program that adds an element to an array by increasing its size by one. In addition, write a program that increases the size of an array with the given length.
- Creating unmodifiable/immutable collections: Write several examples that create unmodifiable and immutable collections.
- Mapping a default value: Write a program that gets a value from Map or a default value.
- Computing whether absent/present in a Map: Write a program that computes the value of an absent key or a new value of a present key.
- Removal from a Map: Write a program that removes from a Map by means of the given key.
- Replacing entries from a Map: Write a program that replaces the given entries from a Map.
- Comparing two maps: Write a program that compares two maps.
- Merging two maps: Write a program that merges two given maps.
- Copying HashMap: Write a program that performs a shallow and deep copy of HashMap.
- Sorting a Map: Write a program that sorts a Map.
- Removing all elements of a collection that match a predicate: Write a program that removes all elements of a collection that match the given predicate.
- Converting a collection into an array: Write a program that converts a collection into an array.
- Filtering a collection by List: Write several solutions for filtering a collection by a List. Reveal the best way of doing this.
- Replacing elements of a List: Write a program that replaces each element of a List with the result of applying a given operator to it.
- Thread-safe collections, stacks, and queues: Write several programs that exemplify the usage of Java thread-safe collections.
- Breadth-first search (BFS): Write a program that implements the BFS algorithm.
- Trie: Write a program that implements a Trie data structure.
- Tuple: Write a program that implements a Tuple data structure.
- Union Find: Write a program that implements the Union Find algorithm.
- Fenwick Tree or Binary Indexed Tree: Write a program that implements the Fenwick Tree algorithm.
- Bloom filter: Write a program that implements the Bloom filter algorithm.