Is recursion ever required to solve a problem? What other approach can you use to solve a problem that is repetitive in nature?

Answers

Answer 1

Answer:

No you can not tell that recursion is ever required to solve a problem.

Recursion is required when in the problem, the solution of the input depends on the solution of the subsets of the input.

Iteration is also another form of repetitive approach we follow to solve that kind of problems.

But the difference between recursion and iteration is :

In recursion we call the function repeatedly to return the result to next level.In iteration certain bunch of instructions in a loop are executed until certain conditions met.

Explanation:

For example in the Fibonacci sequence problem, to find [tex]f_{n}[/tex], we need to compute [tex]f_{n-1}[/tex] and [tex]f_{n-2}[/tex] before that.

In case of recursion we just call the method Fibonacci(n) repeatedly only changing the parameter Fibonacci(n-1), that calculates the value and return it.

                           Fibonacci(n)

                           1. if(n==0 or n==1)

                           2.       return 1.

                           3.else

                           4.      return( Fibonacci(n-1)+Fibonacci(n-1) )

But in case of iteration we run a loop for i=2 to n, within which we add the value of current [tex]f_{i-1}[/tex] and [tex]f_{i-2}[/tex] to find the value of [tex]f_{i}[/tex]

                           Fibonacci(n)

                           1. if(n<=2)

                           2.    result = 1

                           3.     else

                           4. result1 =1 and result2=1.

                           5.      {  result = result1 +result2.

                           6.         result1= result2.

                           7.         result2 = result.

                           8.      }

                           9.  output result.


Related Questions

A batch file is a text file that used to enter a command or series of commands normally typed at the command prompt True False

Answers

Answer:

True

Explanation:

A batch file is a text file which either contains a single command or a series of commands normally typed at the command prompt for a computer operating system. It is known as a batch file because it bundles a set of commands into a single file which could have been presented to the operating system interactively using the keyboard one at a time. A batch file is generally created when a user needs to execute several commands together at a time. We can initiate the sequence of batch commands within the batch file simply by providing the name of the batch file on a command line tool.

Which of the following are valid calls to Math.max? 1. Math.max(1,4) 2. Math.max(2.3, 5) 3. Math.max(1, 3, 5, 7) 4. Math.max(-1.5, -2.8f) A. 1, 2 and 4 B. 2, 3 and 4 C. 1, 2 and 3 D. 3 and 4

Answers

Answer:

1, 2 and 4

Explanation:

the Math.max() is the function in java which is used to compare the two values and it gives the maximum of two values.

it take only two argument and the data type can be int, float etc.

Math.max(1,4): it takes two int values and give the output 4. it is valid call.

Math.max(2.3, 5): it takes two values and give the output 5.0. it is valid call.

Math.max(1, 3, 5, 7): it takes 4 values which is wrong because function takes only two variables. it is not valid call.

Math.max(-1.5, -2.8f): it takes two values and give the output -1.5. it is valid call.

Final answer:

All provided calls to the Math.max function in Java are valid. The function can handle two or more numbers of various types by implicitly converting them to the appropriate type for comparison.

Explanation:

The Math.max function in Java is used to find the highest value among its arguments. The method accepts either two int, long, float, or double arguments or a variable number of arguments of one of those types. Therefore, all the calls to Math.max provided in the question are valid:

Math.max(1,4) - Compares two integers.Math.max(2.3, 5) - Compares a double and an implicitly converted integer to double.Math.max(1, 3, 5, 7) - Uses varargs to compare multiple integers.Math.max(-1.5, -2.8f) - Compares a double and a float (the float is converted to double).

Based on this information, the correct answer is C. 1, 2, and 3 are valid calls to Math.max.

Write assignment statements that perform thefollowing operations with the variables a, b, and c.
a) Adds 2 to a and stores theresult in b.
b) Multiples b times 4 andstores the result in a.
c) Divides a by 3.14 and storesthe result in b.
d) Subtracts 8 from b andstores the result in a.

Answers

Answer:

An assignment statement's overall syntax is-

                   variable = expression ;

Where the variable must be declared; the variable may be a simple name, or an indexed location in an array, or an object's field (instance variable) or a class static field; and the expression must result in a value that is compatible with the variable type. In other words, it must be feasible to cast the expression to the variable type.

Examples: int i =4;

a) b=(a+2);

(a+2) is the expression for adding 2 to a, whereas b equal to the result of (a+2).

b) a=b*4;

(b*4) is the expression for multiples b times 4,whereas a equal to the result of (b*4)

c) b=(a/3.14)

(a/3.14) is the expression for divides a by 3.14,whereas b equal to the result of (a/3.14)

d )a=(b-8)

(b-8) is the expression for Subtracts 8 from b,whereas a equal to the result of (b-8)

what is the largest possible number of internal nodes in a redblack tree with black height k? what is the smallest possiblenumber?

Answers

Answer:

A Red Black Tree is a type of self-balancing(BST) in this tree ,each node is red or black colored. The red black tree meets all the properties of the binary search tree, but some additional properties have been added to a Red Black Tree.

A Red-Black tree's height is O(Logn) where (n is the tree's amount of nodes).

In a red-black tree with black height k

The maximum number of internal nodes is [tex]2^{2k}[/tex] [tex]-1[/tex].

The smallest possible number is [tex]2^{k}[/tex] [tex]-1[/tex].

Final answer:

The largest possible number of internal nodes in a red-black tree with black height k is 2^(k+1) - 1, which assumes a completely filled tree. The smallest number of internal nodes is 2^k - 1, which represents a perfect black-height-balanced binary tree with no additional red nodes.

Explanation:

The largest possible number of internal nodes in a red-black tree with black height k is when each black node has the maximum number of children, which would be when both children are red. In this case, the maximum number of internal nodes is when we have a completely filled tree with alternating levels of red and black nodes, leading to a total of 2^(k+1) - 1 internal nodes, which includes both red and black nodes.

In contrast, the smallest possible number of internal nodes occurs when each black node has the minimum number of children, which is when it has two black child nodes or is a leaf node itself. In this scenario, the minimum number of internal nodes for a red-black tree with black height k is equal to the number of black nodes, which is 2^k - 1. This is because the tree would essentially be a perfect black-height-balanced binary tree without any additional red nodes.

What symbol is used for an assignment statement in a flowchart?
Answer
a) processing
b) I/O
c) parallelogram
d) diamond

Answers

Answer:

processing

Explanation:

The flow chart is a diagram that shows the activity of the program, peoples or things.

Flowchart symbol and meaning in the options:

1. Processing: it is a rectangular shape block which is used for variable declaration or assignment.

2. I/0: it is a parallelogram in shape which is used for input or output.

3. Parallelogram: it is used for input or output.

4. diamond: it is used for decisions or conditions.

Therefore, the correct option is a. Processing is the one that is used for the assignment statement.

Final answer:

In a flowchart, the symbol used for an assignment statement is a parallelogram, which is different from symbols used for processes (rectangles) or decisions (diamonds).

Explanation:

The symbol used for an assignment statement in a flowchart is a (c) parallelogram. This shape is typically used to represent input or output operations, which includes assigning values to variables. In a flowchart, various symbols are utilized to represent different types of actions or steps in a process.

For example, a rectangle is often used for process or operation symbols, and a diamond shape is used to denote decision points. However, when it comes to depicting the action of assigning a value to a variable, which is a fundamental step in many algorithms and programs, the parallelogram serves this purpose.

Why does a satellite requires two bridges?

Answers

Two bridges are being used in the satellite to avoid the delay in the communication of packets/Frames between the sites.

Explanation:

To avoid the delay in the communication of packets/Frames between the sites two bridges are being used. Two Ethernet connections can be connected using the bridge. NIC’s are not there in the repeaters whereas the bridge has two of them which make the bridge different than the repeater. On one of the side in the bridge process of addressing to the node is being done and other ends take care of communicating the packets.  

What is the advantage of breaking your application’s code into several small procedures?

Answers

Answer: For better code management and modularity

Explanation:

An application consist several lines of code so when we break an entire code into several small procedures it becomes easy to maintain and look for errors while debugging. This process also is part of good code writing and hence easy to manage our code during testing and debugging phases of application development.

In order to be considered as an e-commerce web site the site must sell some tangible good. (true or false)

Answers

Answer:

False

Explanation:

The site can also exclusively buy items from people. Websites are not limited to selling items for they can also buy from users.

The following statement is false.

You can use______ in order to allow the user to browse and find a file at run time.
a. the OpenFileDialog common dialog control
b. the StreamReader object
c. the OpenDialog control
d. a hard-coded path name

Answers

Answer:  the OpenFileDialog common dialog control

Explanation:

To browse and select a file on a computer during run time we use OpenFileDialog control. For this we have an OpenFileDialog class and we can create an instance of this class.

The OpenFileDialog common dialog control is used to browse and find a file at run time

Whatis meant by Translation Lookaside Buffer?

Answers

Answer:

A translation lookaside buffer (TLB) is a memory stash that decreases the time it takes to access a user memory location. TLB includes the most lately used page table entries.

TLB is used to overcome the issue of sizes at the time of paging. PTE is used for framing the memory ,but it uses two references one for finding  the frame number and the other for the address specified by frame number.

PTE-page table entry

Describe in one or more complete sentences how someone starting a computer repair business in a town night gain a competitive advantage in that town?

Answers

Answer:

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

Someone starting a computer repair business can gain a competitive edge in the town by offering both software and hardware repair. Some business offer either one or the other. While other big companies only offer repair for products that they own (Intel, AMD, dell, etc). Another way of getting an edge on competition is to offer computer related products such as graphic cards and motherboards. Most computer repair businesses do not do this.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

The way someone starting a computer repair business in a town night gain a competitive advantage is by selling related products.

What is competitive advantage?

Competitive advantage simply means the factors that allow a company have edge over its rivals.

In this case, the way someone starting a computer repair business in a town night gain a competitive advantage is by selling related products and quality products.

Learn more about competitive advantage on:

https://brainly.com/question/14030554

In _______ view, you're unable to make changes to your report.

Answers

Answer:

In print view, you're unable to make changes to your report.

The answer is - Read Only

What according to you a good software design?

Answers

Answer:  As software design is the part of Software development cycle (SDLC) it requires many factors to be become good and helpful such as:-

As it is a designing process it requires a update in the pattern and design so it should be able to deal with every change or update in the software that is being made.Software design should be able to support any modification in the design whenever it is required.By supporting the modification and updates in the design it makes it easy to save the time as well . So, it is also required that is should be a time saving process.

How canwe measure the refresh rate of the CRT, Stereo Devices and LCD? Ifrefresh rate measurement of anyone is not possible then explainwhy?

Answers

Answer:

Refresh rate means how many times the image on the screen is redrawn in a second.It is measured in hertz.

We can measure refresh rate of all of the devices listed in the question.

CRT Refresh rate measurement:-

The refresh rate can be measured by dividing the scanning rate by count of horizontal lines multiplied by 1.05.

Stereo Devices Refresh Rate measurement:-

When LCD's are used for stereo 3 D displays, the refresh rate is divided by 2, because we have two eyes and each one needs a distinct picture. For this reason,it is suggested to use a display of at least 120 Hz refresh rate, because on divided by 2 this rate is 60 Hz.For example 70 Hz non-stereo is 140 Hz stereo, and 80 Hz non-stereo is 160 Hz stereo.

LCD Refresh rate measurement:-

Refresh rate of a LCD is the number of times per second in which the data it is being redrawn by the display.

The _______ controls the action of the algorithm. a. user b. plain text c. cipher text d. key

Answers

The _______ controls the action of the algorithm.

d. key

What Is the measurement value?

Answers

Answer:

The measurement value is the value given by a measuring instrument and the true value is the actual value of the property being measured.

Explanation:

A database is a collection of ________ data.

A. reported
B. queried
C. object
D. related

Answers

Answer:

D. related

Explanation:

A database is a collection of related data.

. Write a statement that throws an IllgalArgumentException with the error message Argument cannot be negative.

Answers

Answer:

public class PostAccount

{

  public void withdraw(float savings)

  {

     if (savings >=0 )

     {

        IllegalArgumentException exception

              = new IllegalArgumentException("Savings cannot be negative");

        throw exception;

     }

     balance = savings - withdraw;

  }

 }

Explanation:

IllgalArgumentException is a type of NumberFormatException  of runtime exception. Here in the program we have created an object of IllgalArgumentException class and after that we have thrown the error to show the condition if it does not satisfy the if condition.

if (quotaAmt > 100 || sales > 100 && productCode == "C")
bonusAmt = 50;

When the above code is executed, which operator is evaluated first?

a.
||

b.
==

c.
=

d.
&&

Answers

Answer:

==

Explanation:

Operator precedence, it tells about the flow of operator execution o which operator execute first and which execute last.

'==' > '&&' > '||' > '='

According to precedence table,

the equal equal operator '==' comes first. so, it execute first and then NOT operator, then OR operator and finally equal operator.

Why must you be careful not to touch the gold contacts at the bottom of each adapter?

Answers

Answer: You must be careful to not touch the gold contacts at the bottom of the adapter because it might damage the device

Explanation: It is advised not touch the gold contacts of the adapter because that might damage the adapter by the oils present on the fingertips of a person which leads to corrosion at times and also there are chances of damage of the electronic component by the electrostatic discharge and that leads to the failure of the device .

Final answer:

To maintain electrical conductivity and prevent damage, avoid touching the gold contacts on adapters. Safety precautions and cleanliness are vital to protect the contacts from harmful materials. Preserving the integrity of the electrical connection is key to the proper functioning of the adapter.

Explanation:

It is crucial to be careful not to touch the gold contacts at the bottom of each adapter to prevent interference with electrical conductivity and avoid damaging the contacts. Gold is an excellent conductor of electricity, and touching the contacts with bare hands can introduce oils and dirt that may hinder the electrical connection.

Safety precautions such as wearing protective gear and ensuring clean hands are essential to prevent harmful materials from affecting the contacts and maintain the adapter's functionality.

An analog signal maintains a constant signal level for a period of time, then abruptly changes to a different constant level.

a) True b) False

Answers

Answer:

b) False

Explanation:

An analog signal does not maintain a constant signal level for a period of time, then abruptly changes to a different constant level.

Write the prototype for a function named showValues. It should accept an array of integers and an integer for the array size as arguments. The function should not return a value.

Answers

Answer:

void showValues(int [maximum volume],int);

Answer:

void showValues(int * array, int array_size){

int i;

for(i = 0; i < array_size; i++){

printf("%d\n", array[i]);

}

}

Explanation:

I am going to write the prototype of a function as a c code.

array is the array as an argument, and array_size is the argument for the size of the array.

void showValues(int * array, int array_size){

int i;

for(i = 0; i < array_size; i++){

printf("%d\n", array[i]);

}

}

Write a recursive function that returns true if the digits of a positive integer are in increasing order; otherwise, the function returns false. Also, write a program to test your function.

Answers

Answer:

C code implementing the function:

#include<stdio.h>

int isIncreasing(int m);

void main()

{

int y, t;

 

printf("Enter any positive integer: ");  

scanf("%d", &y);

 

t= isIncreasing(y); //call the functoion isIncreasing(int m)  

 

if(t==1) //if isIncreasing(int m) returns 1, then the digits are in //increasing order

 printf("True:  The digits are in increasing order");

else

 printf("False:  The digits are not in increasing order");

}

int isIncreasing(int m)

{

int d1,d2;

if(m/10==0) //if we reach till the left of left most digit, then all before  //digits were in order. else it won't go upto that.

{

 return 1;

}

d1 = m%10; //d1 holds the right most digit of current m.

if(m%10 !=0)

{

 m = m/10; //m is updated to find the rest digits and compare //them.

 d2 = m%10;//d2 holds the digit just left of the right most digit of //m.

 if(d2 <= d1) // if the right most and it's left digits are in order then //we proceed to left.

 {

  isIncreasing(m);

 }

 else   //else we stop there itself, no need to move further.

  return 0;

}

}

output is given as image.

An entrepreneur mayfinance fixed assets by:

a. Inventoryloans

b. Installmentloans

c. Short-termdebt

d. Long-termdebt

Answers

Answer:

C - Short-term debt

Explanation:

Asset financing refers to using the company's fixed assets as leverage/collateral to borrow money through a loan. It is always used to address short-term capital requirements and would therefore be best done through short-term debt.

When a function simply receives copies of the values of the arguments and must determine where to store these values before it does anything else, this is known as a ____.
A) pass by value
B) pass by reference
C) stub
D) function declarator

Answers

Answer:

pass by value

Explanation:

Function is a group of statement which perform a task when it calls.

syntax:

type name(argument_1, argument_2,....)

{

 statements;

}

when the value is passed to function and then calling the function. it actually the copy of the value is passed and when the function perform the task and change the value passed it actually make changes i the copy not original value. This is called pass by value.

Provide two examples from everyday life which apply sequential, conditional, and iterative operations.

Answers

Answer:

Explanation:

Great question, in everyday life we have hundreds of tasks that we complete daily which are one of these types of operations or various at the same time, For Example,

In the morning we wake up and make breakfast. The process to make eggs is a specific sequence. First you heat the pan. Then you add the eggs, next you condiment the eggs. Lastly, you place the eggs in a plate. This whole process is a sequential set of tasks.

Later on in the day you go to the car. If the car has gas you take the car to work. Otherwise you take the bus. This is a conditional event that depends of a certain variable to be present.

Yet Both of these events are iterative operations since they are repeated daily.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

Final answer:

Examples of sequential, conditional, and iterative operations in everyday life include following a recipe (sequential), a thermostat regulating temperature (conditional), and a washing machine going through its cycles (iterative).

Explanation:

Sequential, conditional, and iterative operations are fundamental concepts in computer programming and can be seen in everyday tasks. For instance, a recipe follows a sequential process, where one follows steps in a specific order, such as measuring ingredients, mixing them, and baking at a specific temperature for a set time. Conditional operations are seen in thermostats, which turn on heating or cooling systems if the temperature goes above or below certain points. Iteratively, a washing machine repeats cycles of filling, washing, and spinning until the clothes are clean. These examples reflect the application of programming logic in real-world scenarios and are instances where solving problems necessitates identifying knowns and unknowns, and ensuring answers are reasonable.

List two advantages and disadvantages of having internationalstandards for network protocols?

Answers

Answer:

International standard is the process of standardizing the product and providing the product with same physical quantities and with high international level.

Two advantages and disadvantages of having international standards for network protocols are:

The main advantage of having the international standard for network protocol is that communication become easier as, all the computers are connected together. Easy to maintain and installation by using the same standard. Once a standard adopt worldwide, it is difficult to modify it if there is an issues are identified.Every standard has its limitation so that is why there is less focus on developing new technology.

When a company has international standards for network protocols, this means that the company applies the same rules and regulations to all network protocols, regardless of geographical location. There are several advantages and disadvantages of this method:

Advantages:

This allows the company to have a better control over its products, as it is easier to determine whether a network protocol has deviated from standards.

The international standards for network protocols allows for unity, which enables easier and more efficient communication.

Disadvantages:

It is difficult to implement a new international standard worldwide. Similarly, once successfully implemented, this is difficult to modify.

It is difficult to design the right international standard, as this has to be viable in a great variety of different situations and contexts.

Define the primary IT roles along with their associated responsibilities.

Answers

Answer:

some of the IT roles are network maintenance, network administration, researchers, scientist, technical supports, application development.

Their roles are maintaining IT infrastructure, develop applications recruit staffs, management.

 

Explanation:

They should be proficient in establishing IT services and security policies, should be able to recruit staff members, know the project management rules and budget management and customer relationships and establishing establishing.

You can print your report from the _______ tab.

A. Create
B. File
C. Add-ins
D. Arrange

Answers

Answer:

B. File

Explanation:

You can print your report from the file tab.  

The answer is B. File Tab

What is a trap instruction? Explain its use in operating systems.

Answers

Answer:In operating system,trap instruction is synchronous interrupt which arises due to occurrence of exceptional conditions.

Explanation:Trap instructions are the synchronous interrupt or exception . It may arise due to reasons like invalid memory access ,term division by zero etc. Trap instruction is a software invoked interrupt and it is type of a call which transfers the control synchronously. It is also a way of switching into the Kernel mode in which the operating system take some steps before returning the control to the main process  .

Other Questions
Find the interest rate on a loan charging $855 simple interest on a principal of $3750 after 6 years. ETL & ELT are thesame.? True? False A snowboarder is at the top of a 90 foot tall slope making an angle of 40 degrees with the horizontal direction. If the snowboarder weighs 170 pounds and the coefficient of friction between the snow and snowboarder is 0.2, what is the snowboarders acceleration down the hill? Characid fishes are found naturally only in South America and Africa. Fossils of these fish are not found on any other continents. What is the most likely explanation of this distribution pattern? A These fishes arose in either Africa or South America and migrated across the South Atlantic Ocean to the other continent. B Characid fishes arose in the South Atlantic Ocean and migrated to Africa and South America. C Convergent evolution is responsible for the distribution of characid fishes. D Characid fishes arose prior to the separation of the African and South American continents. Solve the compound inequality. n-1226 At the end of 2016, Sunland Company has accounts receivable of $653,700 and an allowance for doubtful accounts of $24,200. On January 24, 2017, it is learned that the companys receivable from Madonna Inc. is not collectible and therefore management authorizes a write-off of $4,245. (a) Prepare the journal entry to record the write-off. (Credit account titles are automatically indented when amount is entered. Do not indent manually.) Account Titles and Explanation Debit Credit Enter an account title Enter a debit amount Enter a credit amount Enter an account title Enter a debit amount Enter a credit amount (b) What is the cash realizable value of the accounts receivable before the write-off and after the write-off? Before Write-Off After Write-Off Cash realizable value $Enter a dollar amount $Enter a dollar amount A medical researcher designs a drug to treat high blood pressure. She believes that people of different genders may respond differently to the new drug. What type of sample should be utilized to control for the possibility of different reactions based on gender A. self-selecting sampleB. stratified random sample C. random sample D. systematic sample Which pregnancy complication cannot be treated with regular prenatal care ? Headaches excessive weight gainhigh blood pressuregenetic abnormalities answe fastttt and there is only one asnwer ABC is congruent to ADC by the SSS criterion. What is the value of x? Which graph is the solution to lxl > 10? swimsuit buyer reduced a group of designer swimwear from $75.00 to $50.00 for a special sale. If 40 swimsuits sold at the reduced price and the remaining 25 swimsuits were returned to the original price after the sale, calculate the total markdowns, markdown cancellations, and net markdown achieved. The following initial rate data apply to the reaction F2(g) + 2Cl2O(g) 2ClO2(g) + Cl2(g).Which of the following is the rate law (rate equation) for this reaction?rate = k[F2][Cl2O]rate = k[F2]2[Cl2O]2rate = k[F2][Cl2O]2rate = k[F2]2[Cl2O]4rate = k[F2]2[Cl2O] Which social policy issue did the New Deal address?OA. Declining achievement in public schoolsOB. Unequal opportunity despite overall prosperityOC. Widespread poverty due to the Great DepressionOD. A costly and unfair health care system Find the slope of the vertical line that passes through (2,-4) Each of the 27 turtles in the pet store needs to be fed. There is one bag of turtle food that weighs 84 ounces. If each turtle gets the same amount of food, how many ounces of turtle food will each turtle get? What is the magnitude of the position vector whose terminal point is (6, -4)? Define the following 4 terms in the text box below:(sperm, fertilization, testoterone, semen) A 16-year-old client newly diagnosed with type 1 diabetes has a very low body weight despite eating regular meals. The client is upset because friends frequently state, You look anorexic. Which statement by the nurse would be the best response to help this client understand the cause of weight loss due to this condition? Which of the following is a key property of the absolute value parent function? A. It is in quadrants III and IV B. It is U shaped C. Its vertex is at the origin. D. It has a slope of 1 on the left side Which of the following is NOT a sign of an impaired road user? A. Inconsistent speed when driving on the road B. Driving much faster or slower than the speed limit C. Drifting out of lanes and driving aggressively D. Using signal lights when they are supposed to