How to implement the following rules in the RACKET (SCHEME language): no <name>
ID: 3817894 • Letter: H
Question
How to implement the following rules in the RACKET (SCHEME language):
no <name> i (do|can|will|would) not __change person___
yes i (do|can|will|would)
why do you ask?
how would an answer to that help you?
what do you think?
why do you ask?
i don't know
i have no idea
i have no clue
maybe
For example, rule 11:
;;; pick one random element from the list choices
(define (pick-random choices)
(list-ref choices (random (length choices))))
;;; generic responses for rule 11
(define generic-response '((that's nice)
(good to know)
(can you elaborate on that?)))
no <name> i (do|can|will|would) not __change person___
yes i (do|can|will|would)
2 _____(special topics)_______ tell me more about your (special topics)... <name> 3 why __________? why not? 4 how __________?why do you ask?
how would an answer to that help you?
5 what __________?what do you think?
why do you ask?
6 _____________?i don't know
i have no idea
i have no clue
maybe
7 ______because_______ is that the real reason? 8 i (need|think|have|want) ________ why do you (need|think|have|want) __change person_____? 9 i __________ (last word is not too) i __________ too 10 verb ________________ you verb ______________ 11 everything else good to knowthat' s nice
can you elaborate on that?
Explanation / Answer
open class BinTree {
BNode theBTRootNode;
open BinTree()/constructor
{
theBTRootNode = invalid;
}
/ - - Addition of the hub to the BST - -
secured BNode insertAB(BNode theRootNode, BNode myNewNode) {
in the event that (theRootNode == invalid) {
theRootNode = myNewNode;
/checks if the username is littler than
/the root protest, if littler adds to one side
} else if (myNewNode.anyClass.surname.compareTo(
theRootNode.anyClass.surname) < 0) {
theRootNode.leftBNode = insertAB(theRootNode.leftBNode, myNewNode);
} else {
/else if greater annexes to one side
theRootNode.rightBNode =
insertAB(theRootNode.rightBNode, myNewNode);
}
return theRootNode;
}
open void insertBST(AnyClass anyClass) {
BNode anyClassBTNode = new BNode(anyClass);
/calls embed previously
theBTRootNode = insertAB(theBTRootNode, anyClassBTNode);
}
/ - - InOrder traversal - -
ensured void inorder(BNode theRootNode) {
on the off chance that (theRootNode != invalid) {
inorder(theRootNode.leftBNode);
theRootNode.show();
inorder(theRootNode.rightBNode);
}
}
/calls the technique to do all together
open void inorderBST() {
inorder(theBTRootNode);
}
/ - Search for key name and returns ref.
/to BNode or invalid if not found -
ensured BNode search(BNode theRootNode, String keyName) {
/if the root is invalid returns invalid
on the off chance that (theRootNode == invalid) {
return invalid;
} else {
/checks on the off chance that they are equivalent
on the off chance that (keyName.compareTo(theRootNode.anyClass.surname) == 0) {
return theRootNode;
/checks id the key is littler than the current
/record if littler navigates to one side
} else if (keyName.compareTo(theRootNode.anyClass.surname) < 0) {
return search(theRootNode.leftBNode, keyName);
} else {
/if greater navigates to one side
return search(theRootNode.rightBNode, keyName);
}
}
}
/returns invalid if no outcome else returns
/the AnyClass question coordinated with the keyName
open AnyClass searchBST(String keyName) {
BNode temp = search(theBTRootNode, keyName);
in the event that (temp == invalid) {
/noresults found
return invalid;
} else {
/result found
return temp.anyClass;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.