Written in scheme please (e) (11 pts) Write a recursive function (intersection A B), which returns...
Write a recursive scheme function EXP-DEPTH that returns the depth of the most nested parentheses in a list. (EXP-DEPTH ’A) is 0, (EXP-DEPTH ’( )) is 1, (EXP-DEPTH ’(1 2 3) ) should return 1. (EXP-DEPTH ’(I J ((K) L) M)) should return 3, since the element K is nested in three levels of parentheses. Please use scheme function
ML LANGUAGE.
1. Use ML patterns to write a function member (e, L) that returns true if e is an element of ist L. 2. Use ML patterns to write a function less (e, L) that returns the list of all elements of L that are less than e. 3. Use ML patterns to write a function union (S1, S2) that returns the union of sets S1 and S2. We implement sets as unordered lists of elements, without repetitions. Hint:...
C++ Write a recursive function that passes no parameters which returns the reverse of a global variable string str. It should be structured like this: string recursive() { return reversed_string; }
1) (10 pts) Write a recursive function that counts and returns the number of nodes in a binary tree with the root root, that store an even value. Please use the struct shown and function prototype shown below. (For example, if the tree rooted at root stored 2, 3, 4, 8, 13, 18 and 20, the function should return 5, since there are five even values [2,4,8,18,20] stored in the tree. typedef struct node { int data; struct node* left;...
Write a recursive function that takes a string as an input and returns the reverse of the string. Write a recursive function rec_string that produces the output shown below for the corresponding function calls. Write a main function to test the function. Method call rec_string(‘abcde’), will produce the following output: * e de cde bcde abcde Method call rec_string(‘abc’), will produce the following output: * c bc abc
(a) Write a recursive function int find(const int A[], int n, int x); which returns the first index i = 0, . . . , n − 1 such that A[i] == x, or n if it is not found. (b) Write a recursive function int rfind(const int A[], int n, int x); which returns the last index i = 0, . . . , n − 1 such that A[i] == x, or n if it is not found....
Write a recursive function that compares two given binary trees. It returns 1 if the two trees are different, and it returns 0 otherwise. The function signature is: int treeDiff (node "a, node *b); Write a recursive function that counts how many nodes in a tree have a single child. The function signature is: int countoneChild(node "root);
Write a recursive function that returns the minimum key value in a binary search tree of distinct (positive) integers. Return -1 in case the tree is empty. (b) Write a recursive function that returns the predecessor of the key value k in a binary search tree of distinct (positive) integers. This is the key value that precedes k in an inorder traversal of the tree. If k does not exist, or if k has no predecessor, your function should return...
C++ Write a recursive function named sumSquares that returns the sum of the squares of the numbers from to num, in which num is a nonnegative int variable. Do not use global variables; use the appropriate parameters. Also write a program to test your function.
Write a recursive function named arithmeticSum that takes a positive integer parameter n and returns the sum of the integer numbers from 1 to n Please write in C++