Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a ) Complete the following function to return number of occurences of the first parameter in the second parameter list. occurs 1 [ 1 ,

a) Complete the following function to return number of occurences of the first parameter in the second parameter list. occurs 1[1,2,3,1,2] will return 2 since 1 has 2 occurrences in the list. occurs 3[1,2,3,1,2] will return 1 and occurs 4[1,2,3,1,2] will return 0.
occurs -[]=0
occurs a (x:x5)=1 et rest=occurs a xs
in if a==x then
else
b) Complete the following function to return number of occurences of the first parameter in the nodes of the second parameter tree. The definition of tree is given below. In the sample tree t the calls return the corressponding values:
occurst 1t6
occurst 2t2
occurst 3t1
occurst 4t0
data Tree a = Node (a, Tree a, Tree a) I Empty deriving Show
occurst - Empty =0
occurst a (Node , left, right
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

ISBN: 0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

Assess three steps in the selection process.

Answered: 1 week ago

Question

Identify the steps in job analysis.

Answered: 1 week ago