Explicit and recursive equation only

1 answer
Question:

Explicit and recursive equation only

[tex]Explicit and recursive equation only[/tex]


Answers

Printing a singly linked-list in reverse in O(N) time

Step 1. Create an empty stack.

Step 2. Traverse each element of linked-list and push it in stack. O(N)

Step 3. Pop stack and print the element untill stack gets empty. O(N)

O(N) + O(N) = O(N)

This algorithm will take O(N) extra space for maintaining the stack.  

    class Node {

       int data;

       Node next;

}

Stack<Integer> st = new Stack<Integer>();

current = head; // head is starting point of linked-list

while(current != NULL)

{

st.push(current.data);

current = current.next;

}

while( ! st.empty())

{

System.out.println( st.pop() + " ");

}

Explanation:

Similar Solved Works

10 answers

U F(C)KN B! TCH YOU DELETED ALL MY QUESTIONSGrayson03 deleted your questionReasonDeleting all user's homework

U F(C)KN B! TCH YOU DELETED ALL MY QUESTIONS Grayson03 deleted your question Reason Deleting all user's homework...
3 answers

The number of members each state is eligible to send to the united states house of representatives

The number of members each state is eligible to send to the united states house of representatives...
3 answers

A habitat is the role of a population in its community, including its environment and its relationship with other species? True or False

A habitat is the role of a population in its community, including its environment and its relationship with other species? True or False...
4 answers

(20 points) consider the complex valued function f( which is called inversion. calculate a few examples and then describe

(20 points) consider the complex valued function f( which is called inversion. calculate a few examples and then describe the effect of this function. you are encouraged to calculate the function for more values of z on your own. if z-e", where te [0, 2t then the points of the unit circle are mapped...
3 answers

Mike hiked to a lake in 4.5 hours at an average rate of 325 miles per hour. Pedro hiked the same distance at a rate of 3 45 miles

Mike hiked to a lake in 4.5 hours at an average rate of 3 2 5 miles per hour. Pedro hiked the same distance at a rate of 3 4 5 miles per hour. How long did it take Pedro to reach the lake? Round to the hundredths place. It took Pedro hours to reach the lake...
10 answers

Match​ (by number) each financial intermediary with its​description:   financial intermediary

Match​ (by number) each financial intermediary with its​description:   financial intermediary commercial bank nothing savings and loan credit union nothing mutual fund 1. these financial institutions are very small cooperative lending institutions organized around a particular​ group: un...
3 answers

Solve for W.2=LW

Solve for W. 2=LW...
3 answers

Calculate the number of moles that were required to neutralize the vinegar

Calculate the number of moles that were required to neutralize the vinegar...
3 answers

How does a dark skin tone differ from light and medium?

How does a dark skin tone differ from light and medium?...
10 answers

What is the largest river in slovenia?

What is the largest river in slovenia?...
3 answers

Diferencias y similitudes entre el sistema educativo francés y el de España.

Diferencias y similitudes entre el sistema educativo francés y el de España....
9 answers

How do you say dog in spanish

How do you say dog in spanish...
6 answers

Hello, anyone want to talk

Hello, anyone want to talk...
3 answers

Simplifyx+2/x+1 - x-2/x+2​

Simplifyx+2/x+1 - x-2/x+2​...
3 answers

Us consumes 1/3 of what addictive substance

Us consumes 1/3 of what addictive substance...
3 answers

Solve this linear system 1/2x+2/3y=11/4x-1/3y=5/2 please put the steps please

Solve this linear system 1/2x+2/3y=1 1/4x-1/3y=5/2 please put the steps please...
1 answer

Place a check mark next to each rhetorical device or type of figurative language that is being used.

Place a check mark next to each rhetorical device or type of figurative language that is being used. Review the information if necessary. “And to those Americans who—whose support I have yet to earn, I may not have won your vote tonight, but I hear your voices. I need your help. And I will be y...
6 answers

13 gallons of water are used to completely fill 3 fish tanks. If each tank holds the same amount of water, how many gallons will each tank

13 gallons of water are used to completely fill 3 fish tanks. If each tank holds the same amount of water, how many gallons will each tank hold? Express your answer as a mixed number....
3 answers

A college received 90% of its order of laptop keyboards from a vendor.Some of the keyboards were defective.

A college received 90% of its order of laptop keyboards from a vendor. Some of the keyboards were defective. The equation below represents this situation, where x represents the total number of keyboards ordered and y represents the number of keyboards that were non-defective. y = 0.9x - 1/18(0.9x)...
3 answers

List the fourteen new countries created after world war one.

List the fourteen new countries created after world war one....

-- 0.012417--