Binary Search Trees with Lazy Deletion
Implement binary search tree class with lazy deletion that has TreeNode as nested class in Java.
Design the class, TreeNode to have following class variables:
int key; // All Keys are in the range 1 to 99
TreeNode leftChild;
TreeNode rightChild;
boolean deleted;
Your program method must have routines to do the following operations.
1. insert
//Should insert a new element to a leaf node. If new element is aduplicatethen do nothing. If the new element is previously deleted one, then do not add other copy just mark the previous deleted as valid now
2. delete
//Should not remove the element from the tree. It should just mark the element as deleted.
Lazy deletion, meaning you will not be deleting the node but only mark it for deletion. It is ok to display the deleted node put an * before it to indicate it is deleted.
3. findMin
//Should return the minimum element, butif it is marked deleted return appropriate minimum
4. findMax
//Should return the maximumelement, butif it is marked deleted return appropriate maximum
5. contains
//Should return true if a particular element is in the tree and is not marked as deleted
6. In order tree Traversal
//Should print the in order traversal of the tree. Indicating with * symbol for elements that are marked deleted
7. Height ( returns the height of the tree)
//Return the height of the tree, count all the elements even the ones that are marked as deleted
8. No Of nodes ( returns number of nodes + number of deleted nodes)
//Return and print size of the tree, count all the elements even the ones that are marked as deleted. And also return the number of deleted elements.
The Java program should prompt user with options to do one of the above routines.
In: Computer Science
A programmer that you work with, Peter, is a jerk. He is responsible for an array that is a key part of an important program and he maintains a sum of the array value.He won't give you access to this array; however, your boss has told you that you need to get input from the user and then place it into the array.Each evening Peter will scan the code and remove any illegal references to his array.
Using pointers, access Peter's array without him knowing it and place three values that you got from the user ONLY AT POSITIONS 3, 6, and 9. Recalculate the sum value and update it.
STARTER CODE BELOW:
#include <stdio.h>
#include
<stdlib.h>
int main(){
int petersArray[10] = {100,200,300,400,500,600,700,800,900,1000}; i
int petersArraySum = 0;
printf("Peter's Array:\n");
for (int loop = 0; loop < 10; loop++) {
printf("%d ",petersArray[loop]);
petersArraySum += petersArray[loop];
}
printf("\n");
printf("Peter's Array Sum: %d\n\n",petersArraySum);
return 0;
In: Computer Science
IP adress is 195.20.1.0/24
- The company is composed of 3 Branches, namely: Head Office (HO), Northern Governorate Branch (NGB) and Southern Governorate Branch (SGB).
- Each branch is represented by a router. Utilize 1841 routers.
- These branches are separated by WAN links where the HO is connected to both branches.
- HO has 2 LANs and NGB and SGB have 1 LAN each. Use 2960 switches.
- Utilize any Class C address and assign the appropriate IP addresses for the interfaces and end devices.
- Place 5 hosts in each LAN.
- Label your network.
Rubrics:
3 points – correct LAN design
4 points – correct LAN addresses
3 points – correct serial link addresses
TOTAL= 10 points
3 points – correct Router LAN port configuration
2 points- correct Router WAN port configuration
3 points – correct end devices addresses
2 points – complete network convergence
TOTAL= 10 points
In: Computer Science
python:
people = {
"Molan": {
"age": 46,
"seIdentity": "Dan Jukes",
"supowers": [
"Radiaon Immunity",
"Turni tiny",
"Radiati blast"
]
},
"Etlame": {
"age": 1800,
"seIdentity": "Unknown",
"supowers": [
"Immortality",
"Heat Immunity",
"Inferno",
"Teleportation",
"Interdi travel"
]
}
#output all people ages as set
# out old people age from dict with name
In: Computer Science
C++
Please create 4 different files with this respective names
main.cpp , Pokemon.h , Pokemon.cpp Move.h
16.5 Homework 5
Introduction
Students will create a C++ program that simulates a Pokemon battle mainly with the usage of a while loop, classes, structs, functions, pass by reference and arrays. Students will be expected to create the player’s pokemon and enemy pokemon using object-oriented programming (OOP).
Scenario
You’ve been assigned the role of creating a Pokemon fight simulator between a player’s Pikachu and the enemy CPU’s Mewtwo.
You need to create a simple Pokemon battle simulation that will run until one of the pokemon’s health points (HP) reaches 0. In the simulation, the player’s Pikachu will battle the enemy Mewtwo. The Mewtwo will always be the first one to attack, then you’ll attack, and so on until the simulation ends (one of the players runs out of health points). Additionally, Mewtwo will only use one attack on the player, whereas the player's Pikachu has 3 attack options. They can either use “Thundershock”, “Quick Attack”, or “Electro Ball”. Once the battle is over, you will be greeted with the message “You win” or “You lose” depending on whether or not the player’s pokemon won the battle.
Instructions to complete the assignment
Your code must perform these major operations:
Move.h (Move Struct) Each move struct must have the following attributes:
Pokemon.h and Pokemon.cpp (Pokemon Class) Each pokemon class must have the following (pritvate) attributes:
And will have the following (public) member functions:
Thunderbolt, Electro Ball, or Quick Attack
Pokemon stats
main.cpp
In the main file, create two pokemon objects (a Mewtwo and a Pikachu) and a loop with the following sequence of actions:
Please Test the files.......
Console Input/Output
• Sample input 1
Thunderbolt Electro Ball Thunderbolt Thunderbolt
Sample output 1
Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Thunderbolt Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Electro Ball It confused Mewtwo! Thunderbolt, Electro Ball, or Quick Attack Pikachu used Thunderbolt Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Thunderbolt You win
Sample input 2
Thunderbolt Quick Attack Electro Ball Quick Attack
Sample output 2
Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Thunderbolt Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Quick Attack Mewtwo used Psycho Cut Thunderbolt, Electro Ball, or Quick Attack Pikachu used Electro Ball It confused Mewtwo! Thunderbolt, Electro Ball, or Quick Attack Pikachu used Quick Attack Mewtwo used Psycho Cut You lose
In: Computer Science
In: Computer Science
You are to write a program using Java that will simulate a slot machine with four wheels. It will determine the amount of money won for each spin. The four wheels spin and stop showing a value between 0 and 9 inclusive. It costs $2 to play.
•You win $500 (but not the $2 you bet) if you get 4 wheels the same.
•You win $10 (but not the $2 you bet) if you get exactly 3 of a kind.
•You win $5 (but not the $2 you bet) if you get two pairs.
•You win $2 if you get 2 wheels the same (That is, you break even).
•You win nothing and lose your $2 bet if you get no matches.
Your program must use 4 methods:
1.One to randomly generate the 4 wheel values.
2.One to output the result of the spin.
3.One to compute the win or loss and print the correct message
4.Finally, one to output new balance and a nice line break graphic as seen below.
Input and Output:Your program will randomly generate a starting balance between $100 and $200 inclusive. Your program will randomly generate four integers (1 for each wheel).Your program will output a description of the input combination and the amount you won or lost.Your program will output your new balance after each spin.
Please help
In: Computer Science
It is very important to see oppression as a structural issue without taking on individual guilt for historical injustices. Explain what this means and why it is important. Why does this matter? Be sure to include the concept of the "luxury of obliviousness" in your answer. (Can someone answer this as long as possible)
In: Computer Science
Software Engineering Process Models
Question 4
(a) Give a description of the waterfall process model. In your
answer you should describe the main tasks that are conducted, and
the order in which they are carried out. You may want to include a
diagram to clarify your answer.
[7 marks]
(b) Describe one advantage and one disadvantage of adopting the
waterfall process model in comparison to other process
models.
[4 marks]
(c) Describe the key principles which underlie Agile software
development.
[8 marks]
(d) Risk management is an important part of software project
planning. Describe what is meant by a risk and give two examples of
risks which could seriously affect a project.
[4 marks]
In: Computer Science
Explain in your own words what is meant by the .NET term of "master pages"? Include an example.
In: Computer Science
Visit the web site of one of the following government agencies:
• Federal Trade Commission
• FFIEC
• Federal Drug Administration
Search the site for information about the agency’s standards related to information security. Study the information you find and draw some conclusions about it. How are the regulations presented? How easily can businesses access and follow these regulations? Summarize your findings in a brief report (06 - 08 pages)
In: Computer Science
In: Computer Science
Give an example of a non-regular Context-Free Language that can be recognize by a Deterministic Pushdown automata and one that cannot.
In: Computer Science
Using C# create a new grade book program for a teacher.
We have a class with 10 students who have each taken 5 tests. Create an array to hold:
Use a random number generator to generate the test scores for each student. The student names may be hard-coded into the array.
Create and call a method that calculates and stores each student’s average in the array.
Create and call a method that displays the grades and average for each student.
In: Computer Science
C++
Modify FunctionTable.cpp so each that each function returns a string(instead of printing out a message) and so that this value is printed inside of main().
//: C03:FunctionTable.cpp
// Using an array of pointers to functions
#include <iostream>
using namespace std;
// A macro to define dummy functions:
#define DF(N) void N() { \
cout << "function " #N " called..." << endl; }
DF(a); DF(b); DF(c); DF(d); DF(e); DF(f); DF(g);
void (*func_table[])() = { a, b, c, d, e, f, g };
int main() {
while(1) {
cout << "press a key from 'a' to 'g' "
"or q to quit" << endl;
char c, cr;
cin.get(c); cin.get(cr); // second one for CR
if ( c == 'q' )
break; // ... out of while(1)
if ( c < 'a' || c > 'g' )
continue;
(*func_table[c - 'a'])();
}
}
In: Computer Science