QuestionQuestion

Write a lisp program to check whether a binary tree is a Binary Search Tree. A Binary Search Tree (BST) is a tree in which all the nodes follow the below-mentioned properties:
- The left sub-tree of a node has a key less than or equal to its parent node's key.
- The right sub-tree of a node has a key greater than to its parent node's key.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

Q .2 -------

Lambda :

(setq V (list 2 6 8))
(setq VSquare (mapcar '(lambda (n) (* n n)) V))
(setq VSqrt (sqrt (+ (car VSquare) (cadr VSquare) (caddr VSquare))))

Iteration :

(setq V (list 2 6 8))
(setq i 0)
(setq sum 0)
(loop while (< i (length V)) do
   (setq sum ( + sum (* (nth i V) (nth i V))))
   (setq i (1+ i))
)
(print (sqrt sum))



Q.3 ------------

(defun SubProcessList(argList)
   (let ((len 0)(i 0))
       ; Anything within let stays local for defined variables .. which are len and i in this case
       (setq len (length argList))      
       (setq i 0)
       (loop while (< i len) do
          (setq item (nth i argList))
          (cond
               (
                  (listp item)
                  ; Check if the current item if is type list, Call SubProcessList recursivly
                  (SubProcessList item)
               )
               (
                  (symbolp item)
                  ; check if the current item is symbol
                  ; Append in finallst is the item is not a member in finallst
                  (if(null (member item finallst))
                   (setq finallst (append finallst (list item))))
                )
          )
          (setq i (1+ i))
       )
      finallst   
    )
)

(defun ProcessList (argList)
   (SETQ finallst NIL)
   (setq finallst(SubProcessList argList))
   (print finallst)
)

(setq lst '( (n) 2 (6 h 7.8) (w f) (n) (c) n) )
(ProcessList lst)

Q.4 -----



(defun even-indices-rec(argList argIndex)
      (cond...

By purchasing this solution you'll be able to access the following files:
Solution.txt.

$35.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available LISP Family Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats