Question 12 . In the slides and videos, I went over recursive definitions for full binary trees, the number of nodes of a full binary tree, and the height of a full binary tree. Recall that full binary trees allow nodes with 0 children and nodes with 2 children, and that is all. In a full binary tree, if a node has 0 children, it is called external. If it has 2 children, it is called internal. (a) Write a recursive definition for the number of external nodes in a full binary tree. Start by determining the number of external nodes in a base case full binary tree. Then consider joining two full binary trees and think about how many external nodes there are in the resulting tree with respect to the number of external nodes in the smaller trees. (b) Write a recursive definition for the number of internal nodes in a full binary tree. Start by determining the number of internal nodes in a base case full binary tree. Then consider joining two full binary trees and think about how many internal nodes there are in the resulting tree with respect to the number of internal nodes in the smaller trees. (c) Look at several examples of full binary trees. You can either draw these yourself or look at the examples in the textbook/slides. For each one, count up the number of internal nodes and the number of external nodes until you notice a pattem and can fill in the following conjecture: For all full binary trees T,e(T)= (Fill in with something in terms of i(T).) (d) Use structural induction and the definitions you wrote in (a) and (b) to prove the conjecture in (c).

Answers

Answer 1

(a) Recursive definition for the number of external nodes in a full binary tree: e(T) = 1 if T has only one node, otherwise e(T) = e(T1) + e(T2) for the join of T1 and T2.

(b) Recursive definition for the number of internal nodes in a full binary tree: i(T) = 0 if T has only one node, otherwise i(T) = i(T1) + i(T2) + 1 for the join of T1 and T2.

(c) Conjecture: For all full binary trees T, e(T) = i(T) + 1.

(d) Proof by structural induction: Base case: 1 = 0 + 1. Inductive step: e(T) = i(T) + 1.

(a) Recursive definition for the number of external nodes in a full binary tree:

- Base case: A full binary tree with only one node is an external node.

- Recursive step: If T1 and T2 are two full binary trees, then the number of external nodes in their join T is e(T1) + e(T2).

(b) Recursive definition for the number of internal nodes in a full binary tree:

- Base case: A full binary tree with only one node is an internal node.

- Recursive step: If T1 and T2 are two full binary trees, then the number of internal nodes in their join T is i(T1) + i(T2) + 1.

(c) Conjecture: For all full binary trees T, e(T) = i(T) + 1.

(d) Proof by structural induction:

- Base case: For a full binary tree with only one node, the number of external nodes (e) is 1 and the number of internal nodes (i) is 0. The conjecture holds true: 1 = 0 + 1.

- Inductive step: Assume that for any full binary trees T1 and T2, the conjecture holds true: e(T1) = i(T1) + 1 and e(T2) = i(T2) + 1. Now, consider the join of T1 and T2, denoted as T.

From the recursive definitions in (a) and (b), we have:

e(T) = e(T1) + e(T2) = (i(T1) + 1) + (i(T2) + 1) = (i(T1) + i(T2) + 1) + 1 = i(T) + 1.

This shows that the conjecture holds for the join of T1 and T2.

By the principle of structural induction, the conjecture holds for all full binary trees.

Learn more about Recursive definition

https://brainly.com/question/28105916

#SPJ11


Related Questions

explain why a project manager should be cautious adding resources to reduce project duration.

Answers

Project managers should carefully consider the potential risks and challenges before making such a decision.

Project management can be a complex process, and as such, it is important that the project manager is careful when making certain decisions regarding the project, especially when it comes to reducing project duration by adding resources. In most cases, the decision to add resources can be made in a bid to reduce the time spent on the project. However, this decision should not be taken lightly, as there are certain risks and challenges that come with adding resources to reduce project duration.Firstly, adding resources can often lead to increased project costs. This is because when additional resources are added to the project, they will need to be compensated for their work. As a result, the cost of the project will increase, which can lead to budget overruns. Therefore, before making the decision to add resources to the project, the project manager should carefully consider the potential impact on the project budget.Secondly, adding resources can also lead to communication issues. When new team members are added to the project, it may be difficult to ensure that everyone is on the same page. This can lead to misunderstandings, errors, and delays. Therefore, the project manager should take steps to ensure that all team members are communicating effectively and working towards the same goals.Finally, adding resources can also lead to a decrease in the quality of the work. This is because when additional resources are added, they may not be as familiar with the project and its objectives. As a result, the quality of their work may not be as high as that of the original team members. Therefore, the project manager should be cautious when adding resources to ensure that the quality of the work remains high.In conclusion, the decision to add resources to reduce project duration should not be taken lightly. Project managers should carefully consider the potential risks and challenges before making such a decision.

Learn more about Project managers :

https://brainly.com/question/31545760

#SPJ11

A measuring cylinder is used to measure the volume of an irregular
solid object.​

Answers

Answer:

Yes it is used for measuring the volume of irregular solid objects for example a peice of stone, rubber etc.

Explanation:

write a program that prompts the user to enter a source file and a target file. the program copies the content in the source file to the target file. make sure that the source file exists. you can have any content in the input file. hints: use get and put. sample run enter a source file name: input.txt enter a target file name: output.txt copy done

Answers

Here's a Python program that prompts the user to enter a source file and a target file, then copies the content from the source file to the target file:

def copy_file():

   source_file = input("Enter the source file name: ")

   target_file = input("Enter the target file name: ")

  try:

       with open(source_file, 'r') as src, open(target_file, 'w') as tgt:

           tgt.write(src.read())

       print("Copy done!")

   except FileNotFoundError:

       print("Source file not found. Please make sure the file exists.")

copy_file()

Enter the source file name: input.txt

Enter the target file name: output.txt

Copy done!

Make sure to replace 'input.txt' and 'output.txt' with the actual file names you want to use.

Learn more about python program here : brainly.com/question/28248633
#SPJ11

Assume there is a food bank who receives a single commodity of food from a donor. The donations are random and can be modeled as a random variable with the following values
D = {0, 1, 2, 3} with probability of (0.1, 0.3, 0.3, 0.3), respectively.
The demand is constant and is 3 units every day.
Each morning, the food bank manager will inspect the inventory at 6:00 am, at 7:00 the beneficiaries arrive at the food bank to receive their food. The food bank manager decides on how much to allocate each day based on the available inventory. Then at noon, the donor will send the food items to the food bank and then the food bank will update its inventory stocks.
Assume that the utility of the beneficiaries is Ua-a0.1 where a is how many units of food items are received by the beneficiaries.

Answers

The food bank manager assesses the inventory at 6:00 am and allocates the available units of food to beneficiaries at 7:00 am, aiming to maximize their utility based on the formula Ua = a - 0.1, where "a" represents the received units of food.

In this scenario, the food bank receives a single commodity of food with varying quantities (0, 1, 2, 3) and corresponding probabilities (0.1, 0.3, 0.3, 0.3). The constant demand is 3 units every day. The food bank manager inspects the inventory at 6:00 am, allocates the available inventory to beneficiaries at 7:00 am, and then receives the donor's shipment at noon to update the inventory.

The utility of the beneficiaries, denoted as Ua, is given by Ua = a - 0.1, where "a" represents the number of units of food items received by the beneficiaries.

Based on this information, the food bank manager needs to assess the available inventory at 6:00 am, determine the allocation for the day, considering the constant demand of 3 units, and aim to maximize the beneficiaries' utility by allocating the appropriate quantity of food items to them.

To know more about shipment, visit:

https://brainly.com/question/29034625

#SPJ11

Which of these are correctly formatted python dictionaries? Check all that apply.

Which of these are correctly formatted python dictionaries? Check all that apply.

Answers

Answer:

A and D sorry if i get it wrong.

Explanation:

Answer:

A. dict = {Name': Matthew' , Age': 14, 'School': 'ABC School' } ;

D. dict = { Season': 'fall': 'weather': 'cool' } ;

what function can automatically return the value in cell

Answers

Answer:

AutoSum

Explanation:

click AutoSum on the Home tab

Decomposition is
O a list of steps to complete a task.
O a set of steps that follow one another in order.
O breaking a problem into smaller parts
O a design flaw in the program.

Answers

Answer:

breaking a problem into smaller parts

Explanation:

In language of computer science, decomposition is the process in which complex problems are divided into simpler parts. These simpler parts helps in the solving of the complex problems. They are made easier and comprehensible for the user to understand. Each simple part is further analyzed separately and the solution of the complex issues are derived.  The process becomes lengthy but the solution is found.

"If possible, always bring print-outs of your slides for your audience
members." Is this good advice?
A. If you can, this is always recommended, unless you are assured
everyone will have a tablet and you can share the files online.
B. No, this is not good advice since handouts rarely help the
audience in any manner. The only thing that matters is what the
speaker says.
C. Not really, since it is a lot of work, requiring a lot of paper, and
most people will not need the handouts.
D. Not really, because audience members will never need to review
slide information.

Answers

Answer:

Answer is A I just take the quiz.

Unless you are certain that everyone will have a tablet and can share the files online, it is always suggested to carry the print-out files of the slides.

Why it is important to bring the print-out files of the slides?

When the slides have a lot of component part, it's a good thought to overlap the copies of the presentation. A presentation is a misfortune medium for communicating ecumenical information.

If the audience has print-out files of the slides, they will be more focused on the themes that want to express rather than recalling every detail.

Unless a person knowing for sure that everyone will have a tablet and will be able to share the files online, it is always a good idea to have the print-out files of the slides with you.

Therefore, option A is correct.

Learn more about the audience, refer to:

https://brainly.com/question/1802560

#SPJ2

Why systems are vulnerable? Select one: a. The software problem/error b. Threat by flood or earthquake c. All of above (a, b & c) d. Misplace the portable devices

Answers

Systems are vulnerable to a wide range of factors, which can be broadly classified into three categories: software issues, natural disasters, and human factors.

In addition, malicious attacks and cyber-attacks can also make systems vulnerable. In this regard, it is essential to have a proactive approach to mitigate risks and secure systems. Let's discuss these factors in more detail below.Software issues: Software problems can arise due to bugs, coding errors, and other factors. These issues can lead to system failures, crashes, and downtime, making systems vulnerable to attacks. As a result, it is important to test and validate software applications to ensure that they are secure and reliable.

Natural disasters: Natural disasters, such as floods, earthquakes, hurricanes, and other weather events, can cause severe damage to systems and infrastructure. This damage can lead to system failures, data loss, and downtime. In addition, natural disasters can also impact power supply, communication networks, and other essential services, further making systems vulnerable. Human factors: Human factors, such as human error, lack of training, and negligence, can also make systems vulnerable.

For example, employees may accidentally delete or modify critical data, leading to data loss and security breaches. In addition, insider threats, such as theft, fraud, and sabotage, can also pose a significant risk to systems. In conclusion, systems are vulnerable to a wide range of factors, including software issues, natural disasters, and human factors. As a result, it is essential to have a proactive approach to mitigate risks and secure systems. This approach includes regular testing, disaster recovery planning, employee training, and the implementation of security measures such as firewalls, antivirus software, and encryption.

Learn more about software :

https://brainly.com/question/1022352

#SPJ11

p (prime) = 11 and g (generator) = 5 alice’s random secret number is 3 bob’s random secret number is 7. Find the shared secret key to encrypt a message using Diffie Key exchange algorithm.

Answers

The shared secret key is 8

To find the shared secret key using the Diffie-Hellman Key Exchange algorithm, Alice and Bob must each perform the following steps:

1. Alice selects a random number, a, and calculates A = g^a mod p
2. Bob selects a random number, b, and calculates B = g^b mod p
3. Alice sends A to Bob, and Bob sends B to Alice
4. Alice calculates the shared secret key as K = B^a mod p
5. Bob calculates the shared secret key as K = A^b mod p

Using the given values:

- p = 11 (prime)
- g = 5 (generator)
- Alice's random secret number is a = 3
- Bob's random secret number is b = 7

Alice calculates A = g^a mod p = 5^3 mod 11 = 8
Bob calculates B = g^b mod p = 5^7 mod 11 = 2

Alice sends A = 8 to Bob, and Bob sends B = 2 to Alice.

Alice calculates the shared secret key as K = B^a mod p = 2^3 mod 11 = 8
Bob calculates the shared secret key as K = A^b mod p = 8^7 mod 11 = 8

Therefore, the shared secret key is 8, which can be used to encrypt a message using a symmetric encryption algorithm.

Learn more about Diffie-Hellman Key Exchange algorithm: https://brainly.com/question/30033612

#SPJ11

To stored three characters a computer occupies. Bytes memory space

Answers

Answer:

The computer represents all characters and numbers internally in the same fashion. In practice, memory is measured in KiloBytes (KB) or MegaBytes (MB).

Explanation:

The computer represents all characters and numbers internally in the same fashion. In practice, memory is measured in KiloBytes (KB) or MegaBytes (MB).

Add criteria to this query to return only the records where the value in the DeptCode field is ENG or CIS. Run the query to view the results.

Answers

To add criteria to the query and filter the records based on the value in the DeptCode field, the following SQL query can be used:

SELECT *

FROM YourTableName

WHERE DeptCode IN ('ENG', 'CIS');

Replace "YourTableName" with the actual name of the table. This query uses the IN operator to specify multiple values for the DeptCode field. In this case, it filters the records to include only those where the DeptCode is either 'ENG' or 'CIS'.

It is required to replace "YourTableName" with the actual name of the table. Also, make sure to use the appropriate database management system and execute the query accordingly.

Learn more about SQL queries, here:

https://brainly.com/question/31663284

#SPJ4

Unlike radio frequency identification (RFID) tags, bar codes: Question 30 options: require a reader that tunes into a specific frequency to determine the location of products. cannot be read using a handheld or pen-type scanner that reads and records data instantly. require direct line-of-sight scanning. increase data entry errors by 75 percent.

Answers

Answer:

require direct line-of-sight scanning.

Explanation:

Unlike radio frequency identification (RFID) tags, bar codes require direct line-of-sight scanning. Meaning you need a device that can scan the bar code and the scanner needs to be directly pointing at the barcode without anything in the way. This is because bar codes work by embedding the information in a design of lines that need to be scanned to retrieve the information. If anything gets in the way it interrupts the scanning process and the data is not correctly transmitted. RFID tags on the other hand do not need a direct line of sight since the information is transferred through radiofrequency. This allows the data to be transferred without a line of sight and at a distance of up to 300ft.

The ________ function will change a character argument from lowercase to uppercase. isupper toupper tolarge fromlower none of these

Answers

The toupper function will change a character argument from lowercase to uppercase.

What is toupper function?

The toupper() function exists utilized to convert the lowercase alphabet to uppercase. i.e. If the character passed exists in a lowercase alphabet then the toupper() function converts a lowercase alphabet to an uppercase alphabet. It exists represented in the ctype. h header file. The toupper() function in C++ converts a provided character to uppercase. It exists defined in the ctype header file.

The toupper() function transforms the lowercase letter c to the corresponding uppercase letter. Both functions return the transformed character. If the character c does not include a corresponding lowercase or uppercase character, the functions return c unchanged.

Hence, The toupper function will change a character argument from lowercase to uppercase.

To learn more about toupper function refer to:

https://brainly.com/question/9414936

#SPJ4

Analogy
Frugality: Stingy
1. Warmth; generous
2. Resolution; whimsical
3. Reflection; thoughtful
4. Pride; haughty
5. Jauntiness; morose

Answers

The analogy presented is "Frugality: Stingy." Frugality refers to the quality of being economical or sparing in the use of resources, especially money.

It implies a conscious effort to avoid waste and unnecessary expenses. The word "stingy" describes someone who is unwilling to spend money or resources, often being excessively cautious or tight-fisted.

To determine the correct answer, we need to identify a word pair that exhibits a similar relationship to the given analogy. Among the options provided, the most suitable choice is:

Warmth; generous

This option presents a similar relationship to the original analogy. "Warmth" can be associated with being generous, indicating a willingness to share and provide comfort or assistance to others. This aligns with the idea of frugality, as someone who is frugal may still be generous and warm-hearted.

The other options do not exhibit the same relationship as frugality and stingy. "Resolution; whimsical," "Reflection; thoughtful," "Pride; haughty," and "Jauntiness; morose" do not capture the concept of being economical or sparing in the use of resources.

Therefore, option 1, "Warmth; generous," is the correct answer as it reflects a comparable relationship to the analogy "Frugality: Stingy."

For more questions on analogy

https://brainly.com/question/24452889

#SPJ11

what are the basic security services, and which ones can be obtained with cryptography (without resorting to physical or other mechanisms)?

Answers

The basic security services are confidentiality, integrity, availability, authentication, and non-repudiation. Cryptography can provide confidentiality, integrity, authentication, and non-repudiation without resorting to physical or other mechanisms.

Basic security services: The basic security services refer to the fundamental objectives of information security: confidentiality, integrity, availability, authentication, and non-repudiation.

Confidentiality: Cryptography can provide confidentiality by encrypting data, ensuring that only authorized parties can access and understand the information.

Integrity: Cryptography can ensure data integrity by using hash functions and digital signatures. Hash functions verify that data has not been tampered with, while digital signatures verify the authenticity and integrity of the sender.

Authentication: Cryptography can support authentication through mechanisms such as digital certificates, public-key cryptography, and challenge-response protocols, allowing entities to verify the identity of each other.

Non-repudiation: Cryptography enables non-repudiation through the use of digital signatures, ensuring that a sender cannot deny sending a particular message or document. This provides evidence and proof of the origin and integrity of the communication.

Learn more about Cryptography :

https://brainly.com/question/88001

#SPJ11

what does select distinct vendorname from vendors join invoices on vendors.vendorid = invoices.vendorid order by vendorname; do in sql

Answers

The query retrieves a list of unique vendor names from the "vendors" and "invoices" tables, ordered alphabetically.

SELECT DISTINCT vendorname FROM vendors JOIN invoices ON vendors.vendorid = invoices.vendorid ORDER BY vendorname; This SQL query performs the following steps:


1. Joins the "vendors" and "invoices" tables on the common column "vendorid".
2. Selects only the unique "vendorname" values using the DISTINCT keyword. This ensures that each vendor name appears only once in the results.
3. Orders the resulting list of unique vendor names alphabetically using the ORDER BY clause.
In summary, the query retrieves a list of unique vendor names from the "vendors" and "invoices" tables, ordered alphabetically.

To know more about SQL query visit:

https://brainly.com/question/30890045

#SPJ11

Which tab automatically becomes available after inserting a text box? Drawing Tools Insert Text Box Tools Shape Tools

Answers

Answer:

insert text box

Explanation:

Explanation:

format tab

Explanation: when you draw a text box a new tab called the format tab appears. it contains tools to design and format and modify the text box.

1. What was the duration of time for each of your runs for the 2 examples?
2. Which code was faster (while loop or for loop)? How could you tell? OR
If your results were inconclusive (meaning your couldn't really see any
difference), why do you believe this was so?
3. What would account for the variability of the duration?

Answers

Using the knowledge in computational language in C++ it is possible to write a code that code was faster while loop or for loop.

Writting the code:

#include <ctime>

int main()

{

  const int N=100;

  while(clock()<N)

  {

 }

  return 0;

}

main:

sub rsp, 8

.L2:

call clock          <<------

cmp rax, 99         <<------

jle .L2             <<------

xor eax, eax

add rsp, 8

ret

#include <ctime>

int main()

{

  const int N=100;

  for(;clock()<N;)

  {

  }

  return 0;

}

What are C++ exceptions?

An exception is a problem that arises during the execution of a program. A C++ exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another.

See more about C++ at brainly.com/question/18502436

#SPJ1

1. What was the duration of time for each of your runs for the 2 examples?2. Which code was faster (while

briefly explain methods of maintaining data intergrity​

Answers

Answer:

Data integrity is the overall accuracy, completeness, and consistency of data. ... By implementing the appropriate data validation and error checking, you can ensure that sensitive data is never miscategorized or stored incorrectly, thus exposing you to potential risk. Download Debunking Data Quality Myths now.

Explanation:

How many calories should i eat a day calculator to lose weight.

Answers

Limit yourself to 4000 a day , it helps.

To what extent can u justify that computer is not the only ICT tool?​

Answers

ICT tool  integration in education is essential because technology enables teaching and learning to occur outside of the classroom.

Describe an ICT tool.

Digital infrastructures like computers, laptops, desktops, data projectors, software, printers, scanners, and interactive teaching boxes are examples of information communication technology equipment. In computer science, the focus is largely on programming and how computers function. Computing focuses more on the hardware and developing the software, whereas ICT is more about the people in the business and customising commercially available programmes to their needs. Learning how to drive a car is an effective analogy.

Why are computers seen as ICT tools?

Tools for information and communication technology are known as ICT tools. Computers, laptops, printers, scanners, software, data projectors, and interactive teaching aids are examples of digital infrastructures that fall under the category of ICT tools.

To know more about ICT tool visit:-

https://brainly.com/question/21298416

#SPJ1

Bluetooth can be used to create a _____, to communicate among computerized devices.
Personal area network
Wide area network
Local area network
Metropolitan area network

Answers

Bluetooth technology is widely used to establish a Personal Area Network (PAN) which enables communication among computerized devices. A PAN is a network that connects devices within a short range, typically within a few meters.

Bluetooth technology allows multiple devices, such as smartphones, laptops, tablets, and other portable devices, to communicate with each other wirelessly. This technology can be used for various purposes, including transferring data, sharing media files, and connecting peripherals. A PAN is a type of Local Area Network (LAN), which is a network that connects devices in a limited geographical area, such as a home or office. Bluetooth technology is designed to work within a small geographical area and is ideal for connecting devices within a single room. Compared to other wireless technologies, such as Wi-Fi, Bluetooth has a lower range and data transfer rate but consumes less power and is more secure. In summary, Bluetooth technology can be used to create a Personal Area Network (PAN), which is a type of Local Area Network (LAN). This technology enables communication among computerized devices within a short range and is ideal for connecting portable devices and peripherals.

Learn more about Local Area Network  here-

https://brainly.com/question/15227700

#SPJ11

You have a large Power over Ethernet flat screen that you are installing in a conference room that requires 70 watts of power. Which of the following IEEE standards does your PoE switch need to provide power for the flat screen?
PoE+
PoE++ Type 4
PoE++ Type 3
PoE

Answers

The IEEE standard that your PoE switch needs to provide power for the flat screen is PoE++ Type 4.

The Power over Ethernet (PoE) is a networking technology that allows Ethernet cables to carry electrical power. Power over Ethernet is defined in the IEEE 802.3 standard. The IEEE 802.3 standard has four different types of PoE technology. PoE+ provides up to 30 watts of power to a device, while PoE++ Type 3 provides up to 60 watts of power. PoE++ Type 4 provides up to 100 watts of power. This implies that a PoE++ Type 4 switch is needed to supply power to the flat screen that requires 70 watts of power. Therefore, the answer is PoE++ Type 4.

To learn more about IEEE; https://brainly.com/question/15040805

#SPJ11

Why do companies collect information about consumers? A. Because they want to meet new friends on social networks B. Because they take consumers' best interests to heart C. Because they want to effectively advertise to consumers D. Because they are looking for good employees to hire​

Answers

Answer:

C. Because they want to effectively advertise to consumers.

Explanation:

Companies collect info for more accurate advertisements, which are designed to make people interact with them more commonly.

All of the following are true about in-database processing technology EXCEPT Group of answer choices it pushes the algorithms to where the data is. it makes the response to queries much faster than conventional databases. it is often used for apps like credit card fraud detection and investment risk management. it is the same as in-memory storage technology.

Answers

All of the aforementioned are true about in-database processing technology except: D. it is the same as in-memory storage technology.

What is an in-database processing technology?

An in-database processing technology can be defined as a type of database technology that is designed and developed to allow the processing of data to be performed within the database, especially by building an analytic logic into the database itself.

This ultimately implies that, an in-database processing technology is completely different from in-memory storage technology because this used for the storage of data.

Read more on database here: brainly.com/question/13179611

#SPJ1

How does adding inputs to a custom function improve a computer program?
A. It makes the result of every run of the program a surprise.
B. It makes the algorithm's output more predictable and reliable.
C. It allows one module to be easily customized for different
situations.
D. It causes the behavior to repeat forever, or for a set number of
cycles.

Answers

By adding inputs to a custom function,  It allows one module to be easily customized for different situations.

What is the use of custom function?

Custom functions, is known to be used as Java methods, as it helps one to be able to extend the power and functionality of their Liquid Data.

Note that By adding inputs to a custom function,  It allows one module to be easily customized for different situation because it uses one input at a time.

Learn more about computer program from

https://brainly.com/question/1538272

#SPJ1

I need help with my CodeHs code in the Unit 6 ''Happy Birthday!'' Level. The candles don't seem to want to be on the cake, every time I code. I am a beginner so I need help in the computer science field.


Here are the instructions:


Draw a cake on the screen. Ask the user how old they are and then draw that many candles on the cake!


Hints:

Use constants to control the size of your cake so that if one value changes, the cake is still proportional

Make sure your candles are added to the cake from the center rather than adding them from the left or right

There are many different ways to decorate your cake, but using loops will make adding lots of decorations much easier!


Also! Here is my Code! Please adjust the errors so the code can work! :)


var x = getWidth /2;

var y = getHeight /2;


function start (){


var tor = new Rectangle(360,300);

tor. SetPosition(15,100);

tor. SetColor(Randomizer. NextColor());

add(tor);


var text = new Text ("HAPPY BIRTHDAY!","30pt Arial");

text. SetColor(Randomizer. NextColor());

text. SetPosition(15,245);

add(text);


var qv = new Rectangle(370,30);

qv. SetPosition(5,400);

qv. SetColor(Color. Blue);

add(qv);


var N = readInt("How Old Are You? ");

for (var i = 0; i

}

var c = new Circle(20);

c. SetPosition(30,100);

c. SetColor(Color. Purple);

add(c);


var c1 = new Circle(20);

c1. SetPosition(70,100);

c1. SetColor(Color. Purple);

add(c1);


var c2 = new Circle(20);

c2. SetPosition(110,100);

c2. SetColor(Color. Purple);

add(c2);


var c3 = new Circle(20);

c3. SetPosition(150,100);

c3. SetColor(Color. Purple);

add(c3);


var c4 = new Circle(20);

c4. SetPosition(190,100);

c4. SetColor(Color. Purple);

add(c4);


var c5 = new Circle(20);

c5. SetPosition(230,100);

c5. SetColor(Color. Purple);

add(c5);


var c6 = new Circle(20);

c6. SetPosition(270,100);

c6. SetColor(Color. Purple);

add(c6);


var c7 = new Circle(20);

c7. SetPosition(310,100);

c7. SetColor(Color. Purple);

add(c7);


var c8 = new Circle(20);

c8. SetPosition(350,100);

c8. SetColor(Color. Purple);

add(c8);



var qw = new Circle(20);

qw. SetPosition(30,390);

qw. SetColor(Color. Purple);

add(qw);


var qw2 = new Circle(20);

qw2. SetPosition(70,390);

qw2. SetColor(Color. Purple);

add(qw2);


var qw3 = new Circle(20);

qw3. SetPosition(110,390);

qw3. SetColor(Color. Purple);

add(qw3);


var qw4 = new Circle(20);

qw4. SetPosition(150,390);

qw4. SetColor(Color. Purple);

add(qw4);


var qw5 = new Circle(20);

qw5. SetPosition(190,390);

qw5. SetColor(Color. Purple);

add(qw5);


var qw6 = new Circle(20);

qw6. SetPosition(230,390);

qw6. SetColor(Color. Purple);

add(qw6);


var qw7 = new Circle(20);

qw7. SetPosition(270,390);

qw7. SetColor(Color. Purple);

add(qw7);


var qw8 = new Circle(20);

qw8. SetPosition(310,390);

qw8. SetColor(Color. Purple);

add(qw8);


var qw9 = new Circle(20);

qw9. SetPosition(350,390);

qw9. SetColor(Color. Purple);

add(qw9);


for(var i = 1; i < numCandles + 1; i ++) {

var candle = new Rectangle(CANDLE_WIDTH, CANDLE_HEIGHT);

candle. SetColor(Color. RED);


if (i % 2 == 0) {

candle. SetPosition(getWidth()/2-CANDLE_WIDTH*i, cake. GetY()-CANDLE_HEIGHT);

} else {

candle. SetPosition(getWidth()/2+CANDLE_WIDTH*i, cake. GetY()-CANDLE_HEIGHT);

}

add(candle);

}

}

Answers

The   corrected versionof the code is given as follows

var x= getWidth() /   2;

var y= getHeight()   / 2;

function start() {

 var tor = new Rectangle(360, 300);

 tor.setPosition(15, 100);

 tor.setColor(Randomizer.nextColor());

 add(tor);

 var text = new Text("HAPPY BIRTHDAY!", "30pt Arial");

 text.setColor(Randomizer.nextColor());

 text.setPosition(15, 245);

 add(text);

 var qv = new Rectangle(370, 30);

 qv.setPosition(5, 400);

 qv.setColor(Color.BLUE);

 add(qv);

 var N =readInt("How   Old Are You? ");

 for(var i = 0; i   < N; i++) {

    var c =new   Circle(20);

   c.setPosition(30 + i * 40, 100);

   c.setColor(Color.PURPLE);

   add(c);

   var qw = new Circle(20);

   qw.setPosition(30 + i * 40, 390);

   qw.setColor(Color.PURPLE);

   add(qw);

 }

 var numCandles = N;

 var CANDLE_WIDTH = 20;

 var CANDLE_HEIGHT = 80;

 var cake  = newRectangle  (200, 20);

 cake.setPosition(getWidth()  / 2 - 100,getHeight() / 2 +   100);

 cake.setColor(Color.YELLOW);

 add(cake);

 for (var i = 1; i  < numCandles+ 1; i++)   {

   var candle =new Rectangle(CANDLE_WIDTH,   CANDLE_HEIGHT);

   candle.setColor(Color.RED);

   if (i % 2  == 0){

     candle.setPosition(

       getWidth() / 2 - CANDLE_WIDTH * i,

       cake.getY() - CANDLE_HEIGHT

     );

   } else {

     candle.setPosition(

       getWidth() / 2 + CANDLE_WIDTH * i,

       cake.getY() - CANDLE_HEIGHT

     );

   }

   add(candle);

 }

}

start();

What was changed?

The changes made were

Added parentheses to the function calls getWidth() and getHeight().Corrected the capitalization of the function and method names: setPosition, setColor, add, nextColor, readInt.Fixed the indentation for better readability.Initialized the variables numCandles, CANDLE_WIDTH, and CANDLE_HEIGHT before using them in the loop.Added the missing variable cake declaration.Fixed the position calculation for the candles inside the loop.

Learn more about code:
https://brainly.com/question/26134656
#SPJ4

A Naval-base security system using eye scanners erroneously refuses to admit 3 in 100 authorized soldiers from a facility containing an artillery battery. The device erroneously admits 1 in 500 unauthorized persons. Assume that 99% of those who seek access are authorized. What is the probability that person is denied access conditional on being authorized? (three decimal places)
0.002
0.030
0.006
0.990


Answers

The probability that a person is denied access, given that they are authorized, can be calculated using Bayes' theorem. We need to find the probability of being denied access and being authorized, and divide it by the probability of being authorized.

First, we calculate the probability of being denied access and being authorized. This is equal to the probability of being denied access, given that they are authorized, multiplied by the probability of being authorized.
The probability of being denied access, given that they are authorized, can be calculated as (3/100) * (1/99) = 0.000303.
The probability of being authorized is given as 99%.
Now we can calculate the conditional probability of being denied access, given that they are authorized, by dividing the probability of being denied access and being authorized by the probability of being authorized.
Therefore, the probability that a person is denied access conditional on being authorized is 0.000303 / 0.99 = 0.003.
The probability that a person is denied access conditional on being authorized is 0.003.

To know more about Bayes theorem, Visit:

https://brainly.com/question/29598596

#SPJ11

A tornado destroyed many
CORRECT ANSWER GETS BRAINLIEST PLEASE HELP !
structures in a small Texas
town. Which type of engineer should be called in to collect
evidence in order to prevent this level of damage in the future?
A.chemical engineer
B.biomedical engineer
C.materials engineer
D.forensic engineer

Answers

Answer:

D is your answer because I'm an expert

Answer:

D. forensic engineer

Explanation:

Because I know the answer I got it right

Other Questions
T/F : when you're aware of a possible disqualification issue, bring it to the attention of the opposing attorney. Neurons that deliver sensory information from sensory receptors to the spinal cord are called __________. first-order neurons second-order neurons third-order neurons lower motor neurons Can i please get some help please?I need help with B ILL MARK U BRAINLIEST!!One out of four girls favorite color is red, and three out of four girls favorite color is pink. If there were 500 girls , how many of them favorite color would be red? graph h(t)=-2(t+5)^2+3, find h(-8) Which of the following best describes the relationship shown in the equation below? A. It cannot be determined if this is or is not a functional relationship. B. This is a functional relationship. C. This is not a functional relationship. Suppose you have $1750 in your savings account at the end of a certain period of time. You invested $1500 at a 3.72% simple annual interest rate. How long, in years, was your money invested? The amount of energy at trophic levels one and four in an ecosystem is indicated by the numbers.Only 10% of the energy is passed on to the next trophic level.What is the total amount of energy in levels two and three? what is the complete ionic equation for the reaction between Na2SO4 and CaCl2 Which value of w makes 6W + 7 = 12 true A new health drink has 160% of the recommended daily allowance (RDA) for a certain vitamin. The RDA for this vitamin is 50 MG. How many milligrams of the vitamins are in the drink? Please help me I need help fast! strong winds developing high heat outputs in active fire heads. a probable change in wind speed and direction. high winds aloft with the potential to surface. wind may spring back up in a different direction. the direction of fire spread solve pls brainliest The formula A=(x+y+z)/(3) gives the average A of three values x,y, and z Solve for x. -What is the value of x when the average of the three values is 36 and the other two values are 33 and 51? x 5/8x3/5help please 2x+5x=? hihihihihiihihihihihihihihihi Approximate when the function is positive, negative, increasing, or decreasing. In 1950 the population of Farmville was 10,520, and in 2000 it was 25,370. What is the closest approximation of the population growth in Farmville This system of government where power lies with the legislative body and the chief executive (leader) is part ofthe legislature.confederal systemparliamentaryunitaryfederal What is the solution to the equation 1/3(12x-6)=4x-9A:x=-3/4B:x=-11/8C:x=-7/8D:Any real value can be a solution E:There is no solution