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 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))
In: Computer Science
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 particular transaction by querying its nearby nodes/peers. Examine the attacks that may be encountered by the node.
In: Computer Science
In: Computer Science
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?
In: Computer Science
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 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
What is an EA implementation methodology?
Who is responsible for execution of the EA program and EA methodology?
How often should an EA be updated? Why?
In: Computer Science
Solve the following problems - assembly - computer organization and architecture- william stallings
1) What is the difference between the twos complement
representation of a number and
the twos complement of a number?
2) What are the four essential elements of a number in floating-point notation?
3) Give a reason for the use of guard bits.
In: Computer Science
When a contractor buys materials, he or she takes them to the
contractor checkout
desk. The clerk enters the contractor name into the system. The
system displays
the contractor information, including his/her current credit
standing.
The clerk then opens up a new ticket (sale) for the contractor.
Next, the clerk then
scans in each item to be purchased. The system finds the price of
the item and
adds the item to the ticket. At the end of the purchase, the clerk
indicates end of
sale. The system compares the total amount against the contractor’s
current credit
limit, and if it is acceptable, finalizes the sale. The system
creates an electronic
ticket for the items, and the contractor’s credit limit is reduced
by the amount of
the sale. Some contractors like to keep a record of their
purchases, so they request
that the ticket details be printed out. Others aren’t interested in
a printout.
Given the above scenario, do the following:
a. Develop an activity diagram for case 2.
In: Computer Science
Write a program in which, you define and call each of the following functions, note that YOU CANNOT USE ARRAY NOTATION IN ANY FUNCTION AT ALL IN THIS EXERCISE, ONLY USE POINTER NOTATION TO MANIPULATE ARRAYS IN THE FUNCTIONS:
1. function read_array, that takes an array of 6 doubles and prompts the user to fill it through the keyboard.
2. function reverse_array, that takes an array of 6 doubles and reverses its contents.
3. function swap_arrays, that takes two arrays of type double and swaps their contents.
4. function print_array, that prints an array of 6 doubles.
5. call all these functions properly in your main program.
In: Computer Science
Java programming
Question1 You will create a full program called LetterGrade that will have the user enter in 2 test scores as double values. It will compute the average and then using else..if statements it will display the letter grade based on my grading scale listed in the course outline.
In: Computer Science
write a java program for a restaurant menu. including price , add taxes and include tip
In: Computer Science