Find a way to have only a few fibonacci numbers in memory

Assignment Help Programming Languages
Reference no: EM131145342

Write a function called HugeInteger *fib(int n); Description: This is your Fibonacci function; this is where the magic happens.

Implement an iterative solution that runs in O(n) time and returns a pointer to a HugeInteger struct that contains F(n). Be sure to prevent memory leaks before returning from this function.

Space Consideration: When computing F(n) for large n, it's important to keep as few Fibonacci numbers in memory as necessary at any given time.

For example, in building up to F(10000), you won't want to hold Fibonacci numbers F(0) through F(9999) in memory all at once.

Find a way to have only a few Fibonacci numbers in memory at any given time over the course of a single call to fib().

Special Notes: You may assume that n is a non-negative integer.

If any dynamic memory allocation functions fail within this function, return NULL, but be careful to avoid memory leaks when you do so. Returns: A pointer to a HugeInteger representing F(n), or NULL if dynamic memory allocation fails.

There is also this to use: typedef struct HugeInteger { // a dynamically allocated array to hold the digits of a huge integer int *digits; // the number of digits in the huge integer (approx. equal to array length) int length; } HugeInteger;

Reference no: EM131145342

Questions Cloud

How is the long-run nominal exchange rate affected : How does this action change the long-run real exchange rate between the home and foreign currencies? How is the long-run nominal exchange rate affected?
What would you do in such a situation : Because the industry is so new, there are no organizations joined together to look after the collective interests of the industry. What would you do in such a situation? What would you suggest others in your industry do
Do police vigorously profile traffickers : Do the police follow human trafficking cases with admiration to organized offense in the past 12 months? Does pursuing a case as ordered crime give law enforcement particular powers of investigation or onlooker protection? Do police vigorously profil..
Being a homeless person and the broader issue of poverty : According to sociologist C. Wright Mills, people often believe that their private lives can only be explained in terms of their personal successes and failures. Individuals fail to see the links between their own lives and the larger society aroun..
Find a way to have only a few fibonacci numbers in memory : Implement an iterative solution that runs in O(n) time and returns a pointer to a HugeInteger struct that contains F(n). Be sure to prevent memory leaks before returning from this function.
Identify the key problems or issues in the case : Identify the key problems or issues in the case, and describe the legal, ethical, and regulatory issues at stake.Explain the effects that customer demand and the unintended use of a product or software can have on SCM and e-commerce practices
Creates brand loyalty and thus-brand equity : Critical Thinking Brand equity means that a brand enjoys customer loyalty, perceived quality, and brand-name awareness. To what brands are you personally loyal? What is it about the product that creates brand loyalty and, thus, brand equity?
Banks are in the business of providing credit : POINT: No. Banks are in the business of providing credit. When economic conditions deteriorate, there will be loan defaults and some banks will not be able to survive. COUNTER-POINT: Yes. If banks focus on providing loans to creditworthy borrowers, m..
Describe important characteristic of female fashion consumer : Cuddeford-Jones (2014) describes some important characteristics of female fashion consumers over 50 and argues that this age group may be an attractive segment for marketers.

Reviews

Write a Review

Programming Languages Questions & Answers

  Necessary vhdl code

Assignment 1:Project Assignment: You are required to design an energy meter based on CPLD (Complex Programmable Logic Device) that will smartly disconnect the supply when sufficient amount of energy units are consumed. The device needs to be programm..

  Create software to perform advanced geometric calculations

You are hired by the engineering company to create software which performs advanced geometric calculations. Your new boss asked you to create the application

  Program that will help user with metric conversions

Write a program that will help the user with metric conversions. Your program should allow the user to specify the names of the units as strings (e.g., centimeters, liters, grams, for the metric system and inches).

  Creating main function that opens the input file

Create a main function that opens the input file, reads each line, and based on first character in input line, calls the [A]dd function or [M]ultiply function.

  Write pseudocode to accept candy name

Write a pseudocode for the following: A programm to accept a candy name (for exmple, "chocolate-covered blueberries'), price per pound, and number of pounds sold.

  Describe how to create users for sales organization unit

Describe how you would create users for sales organization unit and how you can set up user groups in this particular situation (global, universal, domain local).

  Write a script to declares and sets variable

Write a script that declares and sets a variable thats equal to the total outstanding balance due. If that balance due is greater than $10,000.00.

  Discuss few web service tools

We have discussed a few web service Following are the Unit testing tools. In your opinion, are they really useful?

  Analyze problem develop a solution

Analyze each problem, develop a solution and implement your solution. Copy and paste your program and a sample output below each problem.

  Design application that gets customer account data

Design an application that gets customer account data that includes an account number, customer name, and balance due.

  Explain what a sequential access file is.

What are the advantages and disadvantages of using sequential access data files?

  Program to create three identical list

Write a program to create three identical list, list1, list2, and list3, of 5000 elements. The program then sorts list1using quick sort, list 2 using insertion sort.

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