Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question : Write a lisp program to check whether the two binary trees have the same structure. The structure of a binary tree is represented

Question :

Write a lisp program to check whether the two binary trees have the same structure. The structure of a binary tree is represented through list as (root left right). For two trees to have same structure the values dont need to be the same. A sample tree structure can be displayed as (23 (9 (5)) (18 9 (45 14 27)))

what I have until know is the following :

( defun myf(t1 t2 ) ( cond ( (xor (null t1) (t2)) nil ) ( (xor (atom t1) (atom t2)) nil) ( t (and (myf (car(cdr t1)) (car(cdr t2))) ( myf ( car(cdr(cdr t1))) ( car(cdr(cdr t2)))))) ) )image text in transcribed

Write a lisp program to check whether the two binary trees have the same structure. The structure of a binary tree is represented through list as (root left right). For two trees to have same structure the values don't need to be the same. A sample tree structure can be displayed as (23 (9 (5)) (18 9 (45 14 27))) 23 9 18 9 45 5 14 27

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 Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Describe specific developments that advanced cognitive psychology.

Answered: 1 week ago