Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help in writing these functions in OCaml functional programming language asap!!!! Write a function called that takes two arguments: an and a returns if

image text in transcribedimage text in transcribedPlease help in writing these functions in OCaml functional programming language asap!!!!

Write a function called that takes two arguments: an and a returns if the is present in the tree, or otherwise. Note: The levels of the trees don't matter for this function. 2. and Write the two rotation functions described above; call them and_. Note that not all trees can be changed by a skew or a split operation; if a tree is not able to be skewed or split, just return the tree unchanged. Note also that these functions are not recursive; they only act on the top of the tree. Both of these functions can be written in a few lines of code each. You will want to use OCaml's pattern-matching capabilities on constructors. Remember that pattern-matches on recursive datatypes can be more than one level. For instance, a pattern match on a Node constructor doesn't have to be just: If and/or are also s, you can put them right into the pattern-match. For instance: INode(lvl,v,Node(lvl2,v2,ll,lr),Node(lvl3,v3,rl,rr)) If the subtrees are not Node s, the pattern won't match. Of course, you don't have to do this sort of thing, but it can shorten the code you need to write. When you convert the diagrams given above to the rotation code, make sure to notice which parts of the trees change and which parts don't. This can also shorten the code. You might find this helper function to be useful: (* Level of an AA tree. ) let level = function | Leaf 0 | Node ( lvl,_,_-_) lvl

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

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

Were members encouraged to participate?

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago