1.Create a procedure (decreasing L) that takes a list of numbers as input and returns a list of all of the consecutive decreasing subsequences in the input list.
Note: a decreasing subsequence is a sequence of two or more numbers ( ni ni+1 ) such that ni > ni+1.
E.g.,
(decreasing (3 6 8 9 7 4 8 6 3)) ((9 7 4) (7 4) (8 6 3) (6 3))
(decreasing (7 6 5 4 8 5 2 5 1 5 2 1)) ((7 6 5 4) (6 5 4) (5 4) (8 5 2) (5 2) (5 1) (5 2 1) (2 1))
(decreasing (1 2 3 3 3 4 5)) ()
2.Write a function (tree-merge T1 T2) that takes two trees as arguments and merges them according to the following rules:
Merging two trees is done by recursing through their structure and merging their subtrees.
The root of T1 is merged with the root of T2
The first child of T1 is merged with the first child of T2
Second with second etc, etc, etc,
Merging two leaf nodes is done by multiplying their values (you may assume they are numbers).
Merging a leaf node with a subtree is done by scaling the subtree by the value of the leaf.
Merging a subtree with an empty tree, is simply the non-empty subtree.
E.g.:
Programming
[SOLVED] CS 1. Create a procedure (decreasing L) that takes a list of numbers as input and returns a list of all of the consecutive decreasing subsequences in the input list.
$25
File Name: CS_1.__Create_a_procedure_(decreasing_L)_that_takes_a_list_of_numbers_as_input_and_returns_a_list_of_all_of_the_consecutive_decreasing_subsequences_in_the_input_list..zip
File Size: 1563.72 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.