Python question
Your code can make use of any of the BinarySearchTree ADT methods: BinarySearchTree(), insert_left(), insert_right(), get_left(), get_right(), set_left(), set_right(),get_data(), set_data(), search(), __contains__ and insert().
Define a function called create_bst_from_list(values) which takes a list of values as a parameter. The function should create a binary search tree by using the insert() method.
Note: You can assume that the BinarySearchTree class is given and the parameter list is not empty.
For example:
| Test | Result |
|---|---|
tree = create_bst_from_list([7, 12, 4, 9, 20]) print_tree(tree, 0) |
7 (L) 4 (R) 12 (L) 9 (R) 20 |
tree = create_bst_from_list([8, 3, 1, 6, 4, 25, 78]) print_tree(tree, 0) |
8 (L) 3 (L) 1 (R) 6 (L) 4 (R) 25 (R) 78 |
class BinarySearchTree:
def __init__(self, data, left=None, right=None):
self.__data = data
self.__left = left
self.__right = right
def insert_left(self, new_data):
if self.__left == None:
self.__left = BinarySearchTree(new_data)
else:
tree = BinarySearchTree(new_data, left=self.__left)
self.__left = tree
def insert_right(self, new_data):
if self.__right == None:
self.__right = BinarySearchTree(new_data)
else:
tree = BinarySearchTree(new_data, right=self.__right)
self.__right = tree
def get_left(self):
return self.__left
def get_right(self):
return self.__right
def set_left(self, left):
self.__left = left
def set_right(self, right):
self.__right = right
def set_data(self, data):
self.__data = data
def get_data(self):
return self.__data
I need answers soon. Please!
In: Computer Science
1. List and briefly describe the types of Parallel Computer Memory Architectures. What type is used by OpenMP and why?
2. What is Parallel Programming?
In: Computer Science
Based on your professional and/or educational experience, how often do you believe system log files should be checked? How vigilant are you regarding regular checks of these files? When discussing, please also outline some of the reasons why an administrator might tend to ignore these files.
In: Computer Science
Normalizing schema to third normal form (3NF) ,no coding needed! SHIPPING (ShipName, ShipType, VoyageID, Cargo, Port, ArrivalDate) Key: ShipName, ArrivalDate FD1: ShipName > ShipType FD2: VoyageID > ShipName, Cargo FD3: ShipName, ArrivalDate > VoyageId, Port
1.Normalize SHIPPING to 3NF showing PKs, any FKs, functional dependencies. Show the normal form of the schema at each step in the process (e.g. 2NF?, 3NF?).
2..Please list the final set of 3NF schema including all its keys.
3 .Do any of the finalized 3NF schema have determinates that are not candidate keys? If yes, explain - which schema(s)? Why?
In: Computer Science
function TreeSuccessor(x)
if x.right != NIL
return TreeMinimum(x.right) // TreeMinimum is on page 291
y = x.p // parent
while y != NIL and x == y.right
x = y
y = y.p
return y
Tree-Minimum(x)
1 While x.left != NIL
2 x = x.left
3 return x
Consider the following algorithm.
procedure MysteryWalk(x)
y = TreeMinimum(x)
while y != NIL
print y
y = TreeSuccessor(y)
Determine what this algorithm does, and compute its running time, giving a justification for your answer.
In: Computer Science
What is the typical application structure in Windows Azure? What type of communication is used to exchange data between application components and why?
In: Computer Science
Since OSI model is a virtual model; based on your reading this week, why do you think the data communication industry would use the layered OSI reference model? What does modeling mean to you? How would you model something from your life now that you know about technology models? Be creative and interact with your classmates. Get started on the discussions early in the week and tell your classmates what you think about their posts.
In: Computer Science
C++ Programming in Linux
The program will read the five grades from the keyboard, calculate the median, and then then display it. In addition, the program will calculate the average of the five grades and display it as well. Your program should ask the user to input the five grades and then return the median and average. Continue until the user quits.
In: Computer Science
Question # 5.
a. Pretty Good Privacy (PGP) is broadly used to secure email communication. Explain the steps needed prior to exchanging email messages with privacy and authenticity guarantees for a pair of users using PGP.
b. Estimate the time required to crack a 56-bit DES key by a brute-force attack using a 3000 MIPS (million instructions per second) computer, assuming that the inner loop for a brute-force attack program involves around 15 instructions per key value, plus the time to encrypt an 8-byte plaintext. Perform the same calculation fora 128-bit IDEA key.
Extrapolate your calculations to obtain the cracking time fora 300,000 MIPS parallel processor (or an Internet consortium with similar processing power).
In: Computer Science
Write a function template sort that takes two references to generic objects and switches them if the first argument is larger than the second. It is only assumed that operator<() and a default constructor are defined for the objects considered.
In: Computer Science
Mobile and wireless devices are being increasingly used in the Business Administration and Management Industry. write a three-page paper that discusses three (3) mobile apps that could be used in business management. How do these apps increase the productivity of business managers and their customers? Are there any drawbacks involved in using these apps?
Your paper should include:
1. A three-page discussion of the problem.
2. A conclusion and list of all academic references used.
In: Computer Science
Question 2 : Aggregate Scores: Write a program that opens 2
files, quiz.txt, and hw.txt. The program will
read each file and aggregate these values into the associated class
variables. Using a list of Students, the
program keeps track of each student's scores. The program will then
write out to the scores.txt file, the
students score in homework, quizzes, and their overall score.
Related input files.
Each student is supposed to have 3 quiz scores and 3 homework
scores. If a score is not present in the file,
then it defaults to 0 points.
Files will be formatted as a Name followed by a tab followed by a
score.
Note: Refer to the Pre-Lab for the student class, and how to work
with classes.
How to Calculate Grades:
Homework Percent can thus be calculated as:
Homework_Points/3
Quiz Percent can be calculated in the same way:
Quiz_Points/3
Student’s overall score will be computed using the following
formula
HW_Score_Percent * .5 + Quiz_Score_Percent * .5
These scores work as each assignment is out of 100. Thus the
homework percent is calculated as
hw_percent = student.HW/300 * 100, which equals hw_percent =
student.HW/3
Required Design Schematic:
You must use the Student class. You must use a list of students.
You must not use global variables.
● Write a function find_student(student_list, name)
o Either returns a student or an index to the student in the
list
o Should return None if a student with name is not found
● Write a function get_HW_Scores(file_name, student_list)
o Opens the file
o Reads the file
▪ Divide the line into a name and score
▪ Finds the student
▪ Adds the score to the students homework score
o Closes the file
● Write a function get_Quiz_Scores (file_name, student_list)
o Opens the file
o Reads the file
▪ Divide the line into a name and score
▪ Finds the student
▪ Adds the score to the students quiz score
o Closes the file
● Write a function assign_grade(score)
o Returns a string containing a letter grade matching the percent,
see the week 3 lab for scoring
brackets
o Feel free to copy your lab function for use here
● Write a function output_Scores(student_list)
o Opens the file scores.txt
o Loops over every student in the list
▪ Writes the students name + "\n"
▪ Writes "HW_Percent: " + str(hw_percent) + "% \n"
▪ Writes "Quiz_Percent: " + str(quiz_percent) + "% \n"
▪ Calculate num to be the overall score for the student
▪ Writes "Overall: " + str(num) + "%" "(" + assign_grade(num) + ")"
+ "\n"
o Closes the file
● Write a function main to call the above and other functions as
needed to complete the task
Note: You are allowed to create as many helper functions as you
need.
Sample Input File:
Apple 100
Cube 69
Apple 100
Cube 50
Apple 100
Circle 85
Circle 89
Circle 88
Sample Output File:
Apple
HW_Percent: 100.0%
Quiz_Percent: 83.33333333333333%
Overall: 91.66666666666666%(A-)
Cube
In: Computer Science
Research the internet for companies that have executed data science projects. Pick one company and describe a possible data science life cycle for that project. Make use of both information that you have researched as well as the information provided in the data science life cycle models.
In: Computer Science
Write a Java Program using the following instruction:
Create the following 3 methods that calculate and display the sum or product of the integers from 1 to the number input.
getNum Receives no input. Prompts the user to enter a number, use a loop to validate. Returns the result.
calcSum Receives an integer as input. Calculates the sum of the integers from 1 to this number. Returns the result.
calcProd Receives an integer as input. Calculates the product of the integers from 1 to this number. Returns the result.
Main should: Prompt for a character that determines if you want to calculate the sum (‘S’ or ‘s’) or product (‘P’ or ‘p’). You should use a switch to process the choices. Upper and lower case values should work the same way. Use default to give an error message if anything else is entered. (You can input as String or char)
if a valid option is entered, use getNum to prompt for the number
Note that calcSum and calcProduct RETURN the result to main, and the output is printed in main. For example, if you input 5 as the number, and ‘S’, the program should calculate 1 + 2 + 3 + 4 + 5 and display the sum as 15. If you input 5 and ‘P’ the program should calculate 1 x 2 x 3 x 4 x 5 and display the product as 120. . The process should repeat as long as the user wants to continue. This loop should be in main. DO NOT use System.exit command to end the program. . See sample output below.
Enter S for sum, P for prod:z
Invalid choice Again(y/n)? y
Enter S for sum, P for prod:s
Enter an integer greater than 1: 1
Must be greater than 1, re-enter: -3
Must be greater than 1, re-enter: 3
The sum of the numbers from 1 to 3 is 6 Again(y/n)? y
Enter S for sum, P for prod:p
Enter an integer greater than 1: 4
The product of the numbers from 1 to 4 is 24 Again(y/n)? n
In: Computer Science
Why should a time-based authentication system invalidate the current password on a successful authentication?
In: Computer Science