In Java, please write the code for the prompt in the following TWO pictures. -Pl
ID: 3863730 • Letter: I
Question
In Java, please write the code for the prompt in the following TWO pictures.
-Please write the program as simply as possible.
-Please read and follow the prompt closely.
-Your program should run.
-Your program should create a username and password, and save this information.
-It should allow previously-created usernames to log in and access their previously-inputted food items.
-Your program should be able to save and display user-inputted food items. I recommend using a bufferedReader/Writer. The tricky part of this is keeping the file associated with the appropriate username.
-Your program MUST implement and use STACK class methods.
-MUST use a separate class to represent Objects for Stack.
-MUST search through Stack at some point.
All of the details of the program can be found in the following pictures. Thank you!
Explanation / Answer
Give a binary search tree and a number, inserts a new node
with the given number in the correct place in the tree.
Returns the new root pointer which the caller should
then use (the standard trick to avoid using reference
parameters).
*/
struct node* insert(struct node* node, int data) {
// 1. If the tree is empty, return a new, single node
if (node == NULL) {
return(newNode(data));
}
else {
// 2. Otherwise, recur down the tree
if (data <= node->data) node->left = insert(node->left, data);
else node->right = insert(node->right, data);
return(node); // return the (unchanged) node pointer
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.