Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. A search tree can be represented in LISP as follows: (a) if the search tree contains a single leaf node L, it can

1. A search tree can be represented in LISP as follows: (a) if the search tree contains a single leaf node L,Test your program on at least these inputs: > (BFS (ROOT)) (ROOT) 1 > (BFS '((((LE) F) T))) (T F L E) > (BFS

1. A search tree can be represented in LISP as follows: (a) if the search tree contains a single leaf node L, it can be represented by atom L (b) if the search tree has more than one node and is rooted at N, then it can be represented by a list (S1 S2... Sk) where Si represents the ith subtree of N. Consider for example the following search trees, whose LISP representations are shown later. 0 /\ OTRO 0 LE /*/*/* /\ OF Io /\ /\ HT i /1 o C To E AO /\ | A o D | B /I\ H R E /\ o B /\ Co OD I E Write a single LISP function, called BFS. It takes a single argument FRINGE that represents a list of search trees, and returns a top-level list of leaf nodes, in the order they are visited by left-to-right breadth-first search. The inital call to BFS passes a FRINGE list with a single element: the root of the search tree. Test your program on at least these inputs: > (BFS (ROOT)) (ROOT) 1 > (BFS '((((LE) F) T))) (T F L E) > (BFS '((R (I (G (H T}}}}}} (RIGHT) > (BFS '(((A (B)) C (D}}}} (C A D B) > (BFS '((T (HR E) E))) (TEHRE) > (BFS ((A (CC ((E) D)) B}}}} 3 (A B C D E) 1 1. A search tree can be represented in LISP as follows: (a) if the search tree contains a single leaf node L, it can be represented by atom L (b) if the search tree has more than one node and is rooted at N, then it can be represented by a list (S1 S2... Sk) where Si represents the ith subtree of N. Consider for example the following search trees, whose LISP representations are shown later. 0 /\ OTRO 0 LE /*/*/* /\ OF Io /\ /\ HT i /1 o C To E AO /\ | A o D | B /I\ H R E /\ o B /\ Co OD I E Write a single LISP function, called BFS. It takes a single argument FRINGE that represents a list of search trees, and returns a top-level list of leaf nodes, in the order they are visited by left-to-right breadth-first search. The inital call to BFS passes a FRINGE list with a single element: the root of the search tree. Test your program on at least these inputs: > (BFS (ROOT)) (ROOT) 1 > (BFS '((((LE) F) T))) (T F L E) > (BFS '((R (I (G (H T}}}}}} (RIGHT) > (BFS '(((A (B)) C (D}}}} (C A D B) > (BFS '((T (HR E) E))) (TEHRE) > (BFS ((A (CC ((E) D)) B}}}} 3 (A B C D E) 1

Step by Step Solution

3.47 Rating (150 Votes )

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions