
Explanation of Solution
Von Koch snowflake using Recursive method:
- A method calls itself is a recursive method.
- In recursive function base case will stop recursion and return value instead of calling function.
- In each recursive call each side is divided into three sides. Each side has length of one by third of previous one.
- Three new sides are drawn by turn line to left by “600”, turn right by “1200” and turn left by “600”.
Refer program in Figure 5.6 of textbook and include the following code in the given program to draw the cross.
Function to draw cross:
//Recursive function to draw side of cross
void drawSideofCross(double sidde, int levell)
{
//If level is 0
if (levell == 0)
{
//Calculate value of x cordinate
pt.x = int(cos(angle*PI/180)*sidde) + currPt.x;
//Calculate value of y cordinate
pt.y = int(sin(angle*PI/180)*sidde) + currPt.y;
pen->LineTo(pt);
//Set x cordinate of of current point
currPt.x = pt.x;
//Set y cordinate of of current point
currPt.y = pt.y;
}
//If level is not 0
else
{
/*Call recursive function drawSideofCross() with prameters (sidde/3) and (levell-1)*/
drawSideofCross(sidde/3,levell-1);
//Rotate 90 degree to left
left (90);
/*Call recursive function drawSideofCross() with parameters (sidde/3) and (levell-1)*/
drawSideofCross(sidde/3,levell-1);
//Rotate 90 degree to right
right(90);
/*Call recursive function drawSideofCross() with parameters (sidde/3) and (levell-1)*/
drawSideofCross(sidde/3,levell-1);
//Rotate 90 degree to right
right(90);
/*Call recursive function drawSideofCross() with parameters (sidde/3) and (levell-1)*/
drawSideofCross(sidde/3,levell-1);
//Rotate 90 degree to left
left (90);
/*Call recursive function drawSideofCross() with parameters (sidde/3) and (levell-1)*/
drawSideofCross(sidde/3,levell-1);
}
}
//Function to draw cross
void drawCross()
{
/*Call recursive function drawSideofCross() with parameters (side) and (level)�...

Trending nowThis is a popular solution!

Chapter 5 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
- Generate a random sample of standard lognormal data (rlnorm()) for sample size n = 100. Construct histogram estimates of density for this sample using Sturges’ Rule, Scott’s Normal Reference Rule, and the FD Rule.arrow_forwardCan I get help with this case please, thank youarrow_forwardI need help to solve the following, thank youarrow_forward
- reminder it an exercice not a grading work GETTING STARTED Open the file SC_EX19_EOM2-1_FirstLastNamexlsx, available for download from the SAM website. Save the file as SC_EX19_EOM2-1_FirstLastNamexlsx by changing the “1” to a “2”. If you do not see the .xlsx file extension in the Save As dialog box, do not type it. The program will add the file extension for you automatically. With the file SC_EX19_EOM2-1_FirstLastNamexlsx still open, ensure that your first and last name is displayed in cell B6 of the Documentation sheet. If cell B6 does not display your name, delete the file and download a new copy from the SAM website. Brad Kauffman is the senior director of projects for Rivera Engineering in Miami, Florida. The company performs engineering projects for public utilities and energy companies. Brad has started to create an Excel workbook to track estimated and actual hours and billing amounts for each project. He asks you to format the workbook to make the…arrow_forwardNeed help completing this algorithm here in coding! 2arrow_forwardWhats wrong the pseudocode here??arrow_forward
- Help! how do I fix my python coding question for this? (my code also provided)arrow_forwardNeed help with coding in this in python!arrow_forwardIn the diagram, there is a green arrow pointing from Input C (complete data) to Transformer Encoder S_B, which I don’t understand. The teacher model is trained on full data, but S_B should instead receive missing data—this arrow should not point there. Please verify and recreate the diagram to fix this issue. Additionally, the newly created diagram should meet the same clarity standards as the second diagram (Proposed MSCATN). Finally provide the output image of the diagram in image format .arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- COMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE LEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage



