CS 4337- Spring 2023- Assignment#1

.pdf

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

4337

Subject

Computer Science

Date

Dec 6, 2023

Type

pdf

Pages

2

Uploaded by SuperHumanCrowMaster636

CS/CE 4337 - Assignment#1 Due Date: 2/10/23, 11:59 pm 1-Draw the internal representation for the following lisp list(s). (cons '( ((apple () orange ()) ( (( () orange))) banana)) '() ) (cons '( () (( apple(((( (grape)()))) banana ()))) orange ) '((apple)) ) (cons '( ((()apple ()) orange (grape ()) banana)) '(apple) ) 2-Determine the output of the following functions (You must show your works) (cdaar '( ((orange grape((orange grape) apple () ()) banana)) apple banana)) (cddaar '( ((orange grape((orange grape) apple () ()) banana)) apple banana)) (cadadr'( orange ((()) (grape () (apple)) banana))) 3-Give combinations of cars and cdrs that will pick 7 from each of the following lists ,(1 (2 3) 7), (((1 (7)))), and (1(2(3(4(5(6(7))))))) 4-Fully explain each predict in the following scheme function. Then manually trace the function with the given input. Please study provided examples in the lecture notes to learn how you should manually trace our procedure. 5-The following scheme function takes a tree (represented as a list) and returns a list whose elements are all the leaves of the tree arranged in right to left order. For example, ( leaves '(((1) (2)) ((1 2) (3 4))) ) returns ‘(2 1 4 3 2 1). Fully ex- plain each predict in the following scheme function. Then manually trace the function with the given input. CS/CE 4337-Spring 2023- Assignment#1 1
6-Fully explain each predict in the following scheme function. Then manually trace the function with the given input. 7-Fully explain the following scheme function. Then, manually trace the function with the given input. 8-The following pattern of numbers is called Pascal’s triangle. The numbers at the edge of the triangle are all 1, and each number inside the triangle is the sum of the two numbers above it. Write a procedure that computes elements of Pascal’s triangle by means of a recursive process. Note: Your function should produce 5 rows of Pascal’s triangle and should return (1 2 4 8 16) as sum of elements for each row 9-Define a scheme procedure that takes a set (a list of distinct elements) and generates a list of all subsets of the set. For example, (subsets '(a b c )) returns ((a b c) (b c) (a c) (c) (a b) (b) (a) ()). Then, Manually trace your procedure with the provided example. Please study provided examples in the lecture notes to learn how you should manually trace our procedure. CS/CE 4337-Spring 2023- Assignment#1 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help