Given a string, return true if the number of appearances of "is" anywhere in the string is equal to the number of appearances of "not"...
Search Results
Individual Exercises
We'll say that a "triple" in a string is a char appearing three times in a row. Return the number of triples in the given string. The...
We'll say that a lowercase 'g' in a string is "happy" if there is another 'g' immediately to its left or right. Return true if all the...
Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are the same.
Given a string, look for a mirror image (backwards) string at both the beginning and end of the given string. In other words, zero or...
Given a string, return the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more...
Given a string, return a string where every appearance of the lowercase word "is" has been replaced with "is not". The word "is" should...
Write an ArrayBasedStack<T>
member method called reverseString()
that takes a String as a parameter, then uses an ArrayBasedStack...
Write an ArrayBasedStack<T>
member method called decimalToBinary()
that takes a decimal as an int parameter, then uses an...
Write a function in Java that implements the following logic: Given a string, if the string begins with "red" or "blue" return that color...
Write a function in Java that implements the following logic: Given 2 ints, a and b, return their sum. However, sums in the range 10..19...
Given a binary tree, write a recursive function to return the difference between the sum of all node values at odd levels and sum of all...
Write a recursive function BSTsmallcount
that, given a BST and a value key
, returns the number of nodes having values less than key
. Your...
Write a recursive function BSTsmallcount
that, given a BST and a value key
, returns the number of nodes having values less than key
. Your...
Given a binary tree, check if the tree satisfies the property that for each node, the sum of the values of its left and right children...
Write a recursive function that returns true if there is a node in the given binary tree with the given value, and false otherwise. Note...
Given a binary tree, write a recursive function to return the difference between the sum of all node values at odd levels and sum of all...
The height of a binary tree is the length of the path to the deepest node. An empty tree has a height of 0, a tree with one node has a...
Write a recursive function that increments by one the value for every node in the binary tree pointed at by root
, then returns the...
Write a recursive function to count the number of leaf nodes in the binary tree pointed at by root
. You must use the isLeaf
method to...
We define a "root-to-leaf path" to be any sequence of nodes in a tree starting with the root node and proceeding downward to a leaf. The...
Write a recursive function to set the value for each node in a binary tree to be its depth then return the modified tree. Assume that...
Write a recursive function that returns the sum of the values for all of the nodes of the binary tree with root root
.
Here are methods...
Given two binary trees, return true if and only if they are mirror images of each other. Note that two empty trees are considered mirror...
Given two binary trees, return true if they are identical (they have nodes with the same values, arranged in the same way).
Here are...