Question: All solutions in C# language. Task 1: You've got a binary tree. Each node within the tree contains an X value, and a reference to
All solutions in C# language.
Task 1:
You've got a binary tree. Each node within the tree contains an X value, and a reference to the left and right child node. A path within the tree is defined as a set of nodes from the root node to a given leaf node. A node is considered visible if all of the nodes before it on the path have their X values smaller than this node. Root node is always visible. Count the visible nodes.
Task 2:
You've got a string representing a binary number, where max length of the string <= 1,000,000. Execute a procedure, whereby on each step you divide the number by 2 if the number is odd, or subtract 1 if its even (the input is the given number on each step). Count the number of steps necessary to reach 0.
Task 3: An array of signed integer represent a set of points on a straight line. Write a function taking an int[] A and an int M as parameters and return the number of points in a subset of A that has maximal number of points the distance between any two of which is divisible by M. The distance between any two element of A, see A[i] and A[j], is defined as Math.Abs(A[i]-A[j]).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
