Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 3.1 Suppose we wanted to use our tree as a binary search tree for Church numerals. Write expressions for the following functions. briefly describe

image text in transcribed

Exercise 3.1 Suppose we wanted to use our tree as a binary search tree for Church numerals. Write expressions for the following functions. briefly describe how they work, but you do not need to give fully worked examples. (INSERT tr should return a tree which is the same as t, except with r inserted at the correct leaf position (reminder of the basic algorithm: if x is less than the element at the current position, move left, otherwise move right, until you find an empty place to put the element as a new leaf). (SEARCH t r) should return TRUE if r exists in t, or PALSE otherwise. (note: you don't have to implement a balanced binary search tree. An unbalanced one is fine.) xercise 3.2 (INORDER t) should return an inorder traversal of the tree as a list) Exercise 3.3 (SORT a) should sort a list using the treesort algorithm (make a binary search tree using the elements of the list, then return the inorder traversal of the tree as a list). Exercise 3.4 Modify your algorithm and data structure so that it accepts an arbitrary comparison function (instead of assuming we're always using numbers)

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

u = 5 j , v = 6 i Find the angle between the vectors.

Answered: 1 week ago