Write a program that prints out pascals triangle

Assignment Help Computer Engineering
Reference no: EM131846078

Assignment

• Write a recursive function to compute the factorial of a number.

• Write a recursive function to reverse a list.

• Modify the recursive tree program using one or all of the following ideas:

- Modify the thickness of the branches so that as the branchLen gets smaller, the line gets thinner.

- Modify the color of the branches so that as the branchLen gets very short it is colored like a leaf.

- Modify the angle used in turning the turtle so that at each branch point the angle is selected at random in some range. For example choose the angle between 15 and 45 degrees. Play around to see what looks good.

- Modify the branchLen recursively so that instead of always subtracting the same amount you subtract a random amount in some range. If you implement all of the above ideas you will have a very realistic looking tree.

• Find or invent an algorithm for drawing a fractal mountain. Hint: One approach to this uses triangles again.

• Write a recursive function to compute the Fibonacci sequence. How does the performance of the recursive function compare to that of an iterative version?

• Implement a solution to the Tower of Hanoi using three stacks to keep track of the disks.

• Using the turtle graphics module, write a recursive program to display a Hilbert curve.

• Using the turtle graphics module, write a recursive program to display a Koch snowflake.

• Write a program to solve the following problem: You have two jugs: a 4-gallon jug and a 3-gallon jug. Neither of the jugs have markings on them. There is a pump that can be used to fill the jugs with water. How can you get exactly two gallons of water in the 4-gallon jug?

• Generalize the problem above so that the parameters to your solution include the sizes of each jug and the final amount of water to be left in the larger jug.

• Write a program that solves the following problem: Three missionaries and three cannibals come to a river and find a boat that holds two people. Everyone must get across the river to continue on the journey. However, if the cannibals ever outnumber the missionaries on either bank, the missionaries will be eaten. Find a series of crossings that will get everyone safely to the other side of the river.

• Modify the Tower of Hanoi program using turtle graphics to animate the movement of the disks.

• Pascal's triangle is a number triangle with numbers arranged in staggered rows such that anr = n! / [r! (n - r)!] This equation is the equation for a binomial coefficient. You can build Pascal's triangle by adding the two numbers that are diagonally above a number in the triangle. An example of Pascal's triangle is shown below.

1319_Pascals-Triangle.jpg

Write a program that prints out Pascal's triangle. Your program should accept a parameter that tells how many rows of the triangle to print.

Reference no: EM131846078

Questions Cloud

Determine which provides the lowest transportation cost : Set up this problem as a linear programming (LP) problem and find the optimal solution using Excel's Solver.
Can you tell me what each of the numbers mean : STT100 Research Assignment. We recently implemented a new phone system that captures data on all incoming calls. Can you tell me what each of the numbers mean
Discuss about the economic empowerment : In addition, even though there has been some progress for women in India, others attribute the use of gender selection to women's lack of social, political.
Draw a sierpinski triangle using paper and pencil : Draw a call stack for the Tower of Hanoi problem. Using the recursive rules as described, draw a sierpinski triangle using paper and pencil.
Write a program that prints out pascals triangle : Write a program that prints out Pascal's triangle. Your program should accept a parameter that tells how many rows of the triangle to print.
In what phase of the life cycle is the record-label industry : Your group works for Warner Music Group, a large music record label whose sales are declining largely due to digital piracy.
What are some of the risks of an open innovation approach : The chapter compares and contrasts closed versus open innovation. It also describes Procter & Gamble's Connect+Develop open innovation system.
Calculate the labor productivity change : Calculate the following: labor productivity change, resign productivity change, capital invested productivity change, energy productivity change.
Identify a recent innovation by your firm : Identify a recent innovation by your firm. What is your firm's strategy to cross the chasm(s) to achieve mass market adoption of its innovation?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd