Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a recursive procedure called reverse that takes a binary tree BinTree as input and returns its reverse as the output. A binary tree is

Write a recursive procedure called reverse that takes a binary tree BinTree as input and returns its reverse as the output.

A binary tree is reversed if its left subtree is replaced with its right subtree and vice versa.

Below are a few examples of inputs/outputs of the reverse procedure.

> (reverse 7)

7

> (reverse '(+ 7 8))

'(+ 8 7)

> (reverse '(* (+ 7 8) (- 10 11) ) )

'(* (- 11 10) (+ 8 7) )

BinTree is defined by the following grammar. In this grammar, Int denotes an integer number and Symbol denotes +,-,/ and *.

Bintree ::= Int | (Symbol Bintree Bintree)

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

1. How does Kiwi Experience maintain a continual customer focus?

Answered: 1 week ago