Questions
Code using JAVA: must include "Main Method" for IDE testing! /** * Definition for a binary...

Code using JAVA:

must include "Main Method" for IDE testing!

/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
vector<int> preorderTraversal(TreeNode* root) {
  
}
};

Given the root of a binary tree, return the preorder traversal of its nodes' values.

Example 1:

Input: root = [1,null,2,3]
Output: [1,2,3]

Example 2:

Input: root = []
Output: []

Example 3:

Input: root = [1]
Output: [1]

Example 4:

Input: root = [1,2]
Output: [1,2]

Example 5:

Input: root = [1,null,2]
Output: [1,2]

Constraints:

  • The number of nodes in the tree is in the range [0, 100].
  • -100 <= Node.val <= 100

In: Computer Science

This is the last discussion. 1) Where do you see technology leading us in terms of...

This is the last discussion.

1) Where do you see technology leading us in terms of the future?

2) Identify a device (anything that has a CPU) that we use every day that is not protected and subject to being hacked?

3) What do you recommend to protect the device?

Please answer this question ASAP. I need it very badly.

In: Computer Science

Jenny had discovered some new friends on the Internet—friends who shared her interest in programming. One...

Jenny had discovered some new friends on the Internet—friends who shared her interest in programming. One of these new friends sent her a link to a new warez (illegally copied software) site.

She downloaded a kit called Blendo from the warez site. Blendo is a tool that helps novice hackers create attack programs that combine a mass e-mailer with a worm, a macro virus, and a network scanner. She clicked her way through the configuration options, clicked a button labeled “custom scripts,” and pasted in a script that one of her new friends had e-mailed to her. This script was built to exploit a brand-new vulnerability (announced only a few hours before).

Although she didn’t know it, the anonymous high-schooler had created new malware that was soon to bring large segments of the Internet to a standstill.

She exported the attack script, attached it to an e-mail, and sent it to an anonymous remailer service to be forwarded to as many e-mail accounts as possible. She had naively set up a mailback option to an anonymous e-mail account so she could track the progress of her creation. Thirty minutes later, she checked that anonymous e-mail account and saw that she had more than 800,000 new messages; the only reason there were not even more messages was that her mailbox was full.

Required:

Evaluate the ethical issues as described in the scenario.

(1000 to 1200 words)

In: Computer Science

Code using JAVA: must include "Main Method" for IDE testing! /** * Definition for a binary...

Code using JAVA:

must include "Main Method" for IDE testing!

/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
TreeNode* sortedArrayToBST(vector<int>& nums) {
  
}
};

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.

For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.

Example:

Given the sorted array: [-10,-3,0,5,9],

One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST:

      0
     / \
   -3   9
   /   /
 -10  5

In: Computer Science

The title of the course is OS. All answers should be based on that. Please do...

The title of the course is OS. All answers should be based on that. Please do not copy and paste answers on chegg or on google for me. All answers should be based on your understanding on the course. Please try as much to answer the questions based on what is asked and not setting your own questions and answering them. Let it be if you want copy and paste answers.

**********************************************************************************************************************************************************************************************************************

(2)

(a). Designers are constantly undertaking research into
possible improvement that can make to various types
of memory that computers use. Often times, the
designers grapple with issues in their design of
computer memories.

(i). Critically compare and contrast cache memory
and magnetic disk storage in a computer system
that you frequently use. You may draw a
suitable diagram and/or a table of comparisons to illustrate your answer, if you desire.

(ii).Discuss three possible issues that cache memory
designers, in your opinion, must address in their
bid to come out with effective and efficient
cache memory to satisfy the demands of
computer users; and explain how they can solve
each of the issues you have discussed.

(b).A business student has approached you for assistance
in doing an ICT assignment that he has been
struggling with, regarding modes of execution of
instructions in a computer system.

(i). Clearly explain, in your own words, the
difference between User mode and Kernel
mode of execution of instructions in a
computer system; draw diagram to illustrate
your answer.

(ii). Describe the circumstances for which System
Calls may be invoked; and explain how the
operating system responds to such invocation.

In: Computer Science

You are the data design specialist on the data warehouse project team for a retail company....

You are the data design specialist on the data warehouse project team for a retail company. Design a STAR schema to track the sales units and sales dollars with three-dimension tables. Explain how you will decide to select and build four two-way aggregates

In: Computer Science

Python programming 1. Use 0 and 1 only to complete the function that outputs how many...

Python programming

1. Use 0 and 1 only to complete the function that outputs how many N-long sequence are in total.

Condition
1) Starts with zero and ends with zero
2) Zero does not exist twice in a row.
3) 1 does not exist three times in a row.
4) N is a natural number.

- A sequence that satisfies the conditions.
ex) 010, 0110, 01010

- A sequence that does not meet the conditions.

ex) 0100, 01110, 01100110

Need two answer. One is with recursion function and the other is Dynamic programming

the function start with

def Recursion(N):

the parameter is just N

thank you

In: Computer Science

Code using JAVA: must include "Main Method" for IDE testing! /** * Definition for a binary...

Code using JAVA:

must include "Main Method" for IDE testing!

/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
* this.left = left;
* this.right = right;
* }
* }
*/
class Solution {
public TreeNode searchBST(TreeNode root, int val) {
  
}
}

Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node's value equals the given value. Return the subtree rooted with that node. If such node doesn't exist, you should return NULL.

For example,

Given the tree:
        4
       / \
      2   7
     / \
    1   3

And the value to search: 2

You should return this subtree:

      2     
     / \   
    1   3

In the example above, if we want to search the value 5, since there is no node with value 5, we should return NULL.

Note that an empty tree is represented by NULL, therefore you would see the expected output (serialized tree format) as [], not null.

In: Computer Science

Convert the expression into postfix notation 19 + 2 ∗ 5  + (1 - 6/(1 ∗ 2))

Convert the expression into postfix notation
19 + 2 ∗ 5  + (1 - 6/(1 ∗ 2))

In: Computer Science

Appraise how various cryptographic techniques are used in the “Pay to Public Key Hash (P2PKH)” in...

Appraise how various cryptographic techniques are used in the “Pay to Public Key Hash (P2PKH)” in the Bitcoin blockchain.

In: Computer Science

In the Bitcoin blockchain, a node may attempt to perform verification of the existence of a...

In the Bitcoin blockchain, a node may attempt to perform verification of the existence of a particular transaction by querying its nearby nodes/peers. Examine the attacks that may be encountered by the node.

In: Computer Science

The ultimate goal of HCI design is about usability. Describe what usability is and identify 5...

  1. The ultimate goal of HCI design is about usability. Describe what usability is and identify 5 factors to measure usability?
  2. What is cognitive aide and what is the theory behind this? Give three examples to describe how cognitive aides are used in user interface design?
  3. Design of an HCI element typically follows Norman’s seven stages of action. With an example. Briefly explain Norman’s seven stages action.
  4. Metaphors are powerful designs if done properly. Explain the idea of a metaphor and give two examples of using metaphors in user interface design. What are the 3 advantages and 3 disadvantages of using metaphors?
  5. Heuristic evaluation and cognitive walk through are commonly used for HCI design. Briefly explain how to conduct a heuristic evaluation and how to conduct cognitive walk through?

In: Computer Science

Write a Java program 1-)write a program that simulates a vending machine, takes input from the...

Write a Java program

1-)write a program that simulates a vending machine, takes input from the user (money), and returns the change to the user.

The change means

Quarter =   25 cent

Dime = 10 cent

Nickels = 5 cent

Pinneies = 1 cent

2-) What is the output produced by the following code?

  • int result = 11;
  • result /= 2;
  • System.out.println("resu lt is " + result);

In: Computer Science

Why is it important to have a Network Security? Discuss the use of network security components....

Why is it important to have a Network Security?

Discuss the use of network security components.

Why is it important to use Firewall for Computer Networks?

In: Computer Science

Assignment6A: This used to be entertainment. If you haven’t played the classic game Pong, then you...

Assignment6A: This used to be entertainment. If you haven’t played the classic game Pong, then you are now required to do so. Though it doesn’t capture the poor quality of the original, you can find an emulator at Pong-2.com. Play it (using the keyboard).   Do you see how the ball bounces off of the walls and the paddles? You’re going to learn how to do this by creating class Ball.

A Ball has an X and Y position. Equally important, a ball has an x velocity and a y velocity. Every time the ball moves (in one unit of time), it changes its X and Y position by its x and y velocity. However, before moving it, you need to check to see if it’s touching a wall. If so, you need to reverse either its x or y velocity depending on whether or not its touching a wall. What is the ball’s location if its touching a wall? For simplicity, we’re going to assume that the ball is on a 10x10 field and that the x and y velocities can only be -1, 0, or +1.

Your task is to 1) write class Ball that has the variables/attributes above, 2) has a constructor that takes in the starting X and Y position as well as the starting X and Y velocity, 3) has a method called “move” that takes no parameters and updates the position of the ball and 4) has a print statement called “print” that takes no parameters and prints out the ball’s current position.

You must call the class “Ball” and put it in a file called Ball(.java, .cs, .cpp, .h). To test your ball, you should create a file called Assignment6A(.java, .cs, .cpp) that creates a ball based off of user input and calls the “move” and “print” methods of the ball the number of times the user wants. It should behave like the sample output below.

Sample Output #1:

x:

7

y:

4

x velocity:

1

y velocity:

1

Number of moves:

20

X:7 Y:4

X:8 Y:5

X:9 Y:6

X:8 Y:7

X:7 Y:8

X:6 Y:9

X:5 Y:8

X:4 Y:7

X:3 Y:6

X:2 Y:5

X:1 Y:4

X:0 Y:3

X:1 Y:2

X:2 Y:1

X:3 Y:0

X:4 Y:1

X:5 Y:2

X:6 Y:3

X:7 Y:4

X:8 Y:5

X:9 Y:6

Sample Output #2:

x:

5

y:

2

x velocity:

0

y velocity:

-1

Number of moves:

20

X:5 Y:2

X:5 Y:1

X:5 Y:0

X:5 Y:1

X:5 Y:2

X:5 Y:3

X:5 Y:4

X:5 Y:5

X:5 Y:6

X:5 Y:7

X:5 Y:8

X:5 Y:9

X:5 Y:8

X:5 Y:7

X:5 Y:6

X:5 Y:5

X:5 Y:4

X:5 Y:3

X:5 Y:2

X:5 Y:1

X:5 Y:0

In: Computer Science