The Java Algorithms online test assesses candidates' algorithmic-thinking skills and their ability to implement algorithms using Java.

It's an ideal test for pre-employment screening. A good developer will be able to design and implement algorithms that are both correct and efficient. Computational complexity is important not only when scaling applications but when creating responsive, maintainable, and efficient code.

This online test requires candidates to analyze or design an algorithm using Java as the programming language.

##### Recommended Job Roles
Back-End Developer
Java Developer
Web Developer

## Binary Search Tree

15min
-
Easy
-
CODE

Java Algorithmic thinking Data structures Public Binary search tree (BST) is a binary tree where the value of each node is larger or equal to the values in all the nodes in that node's left subtree and is smaller than the values in all the nodes in that node's right subtree.

Write a function that, efficiently with respect to time used, checks if a given binary search tree contains a given value.

For example, for the following tree:

• n1 (Value: 1, Left: null, Right: null)
• n2 (Value: 2, Left: n1, Right: n3)
• n3 (Value: 3, Left: null, Right: null)

Call to contains(n2, 3) should return true since a tree with root at n2 contains number 3.

## Song

15min
-
Easy
-
CODE

Java Algorithmic thinking Searching Public

A playlist is considered a repeating playlist if any of the songs contain a reference to a previous song in the playlist. Otherwise, the playlist will end with the last song which points to null.

Implement a function isRepeatingPlaylist that, efficiently with respect to time used, returns true if a playlist is repeating or false if it is not.

For example, the following code prints "true" as both songs point to each other.

``````Song first = new Song("Hello");
Song second = new Song("Eye of the tiger");

first.setNextSong(second);
second.setNextSong(first);

System.out.println(first.isRepeatingPlaylist());``````

## Two Sum

30min
-
Easy
-
CODE

Java Algorithmic thinking Searching Public

Write a function that, when passed a list and a target sum, returns, efficiently with respect to time used, two distinct zero-based indices of any two of the numbers, whose sum is equal to the target sum. If there are no two numbers, the function should return null.

For example, findTwoSum(new int[] { 3, 1, 5, 7, 5, 9 }, 10) should return a single dimensional array with two elements and contain any of the following pairs of indices:

• 0 and 3 (or 3 and 0) as 3 + 7 = 10
• 1 and 5 (or 5 and 1) as 1 + 9 = 10
• 2 and 4 (or 4 and 2) as 5 + 5 = 10