answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Shalnov [3]
2 years ago
4

Write an iterative algorithm in Java-like pseudocode for printing a singly linked list in reverse in O(N) time. You can use as m

uch extra space as you need. The original list pointers CAN NOT BE MODIFIED. State in big-O notation how much extra space is used by this algorithm.NOTE: The reason you are not allowed to implement the algorithms recursively, is due to the additional space requirements of recursive calls. Around N recursive calls has an additional space complexity of O(N) as each recursive call is placed on a call-stack that requires memory to keep track of.Write another iterative algorithm in Java-like pseudocode for printing a singly linked list in reverse using O(1) extra space. The original list pointers CAN NOT BE MODIFIED. This algorithm can have any runtime (it will be worse than the algorithm in part a). State the runtime of your algorithm in big-O notation.NOTE: The reason you are not allowed to implement the algorithms recursively, is due to the additional space requirements of recursive calls. Around N recursive calls has an additional space complexity of O(N) as each recursive call is placed on a call-stack that requires memory to keep track of.
Computers and Technology
1 answer:
aleksklad [387]2 years ago
8 0

Answer:

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:

You might be interested in
When considering server consolidation, plan on running ___________ vCPUs per core.a. 1 to 2b. 3 to 4c. 4 to 6d. 6 to 8
GREYUIT [131]

Answer:

c. 4 to 6

Explanation:

According to the VMware, a virtual machine software company widely known for producing the virtualization software, which is capable of making computer hardware components to be compartmentalized into various virtual layers, recommended the best practices of virtual CPU per core to be running 4 to 6.

Hence, in this case, the correct answer is option C

4 0
2 years ago
What answer best explains why improper netiquette is considered dangerous? Individuals who violate user policies are often charg
adell [148]

Answer:

Students become vulnerable to cyberbullying and harassment.

Explanation:

3 0
2 years ago
Read 2 more answers
Which of the following is an object such as a field which can be inserted into a document
ivanzaharov [21]

Answer:

SORRY but U have to make a new question.

Explanation:

bc u put which is the following is ..... u did not put the following

cant help on this one.

8 0
2 years ago
Which of the following provides a suite of integrated software modules for finance and accounting, human resources, manufacturin
zzz [600]

Answer:

B) ERP systems

Explanation:

ERP which means Enterprise Resource Planning is a software that uses a centralized database, it helps to hasten business processes thereby reducing the use of manual labour. Some of the integrated software modules which it provides are:

*Finance, Accounting.

*Human resource.

*Manufacturing and production.

*Sales and marketing.

The ERP system does not really need the total involvement of a human because it has a database where information stored is used in the daily execution of tasks, it can also be used to measure the productivity and profitability of the business.

6 0
2 years ago
What is the statement describing? Agile team continuously adapt to new circumstances and enhance the methods of value delivery
Vera_Pavlovna [14]

Answer:

Continuous Integration

Explanation:

In continuous integration process, A program or piece of code is edited, tested and validated by team of software developers or contributors to complete and deploy the single project. This practice will improve the quality and reliability of the code.

Improvement, delivery and deployment are the three different phases, to complete the process of continuous integration.The individuals who contribute in a code or program  in terms of improvement, delivery and deployment make a team that leads to continuous integration.

So, Agile team Continuously adapt Continuous Integration to new circumstances and enhance the methods of value delivery.

8 0
2 years ago
Other questions:
  • Corey set up his presentation for delivery to his team. The information he had to convey was critical to their job performance.
    6·3 answers
  • What is the area of a parallelogram whose vertices are A(−1, 12) , B(13, 12) , C(2, −5) , and D(−12, −5) ? Enter your answer in
    9·2 answers
  • Software code is tested, debugged, fixed, verified, and then:
    11·1 answer
  • Suppose Dave drops a watermelon off a high bridge and lets it fall until it hits the water. If we neglect air resistance, then t
    12·1 answer
  • Picture an expensive item you’d LOVE to own. What would make you happier: Buying it NOW using credit/taking out a loan? Buying i
    9·1 answer
  • A program is loaded into _________ while it is being processed on the computer and when the program is not running it is stored
    15·2 answers
  • System design is the determination of the overall system architecture-consisting of a set of physical processing components, ___
    6·2 answers
  • Discussion Question 10: A bank in California has 13 branches spread throughout northern California , each with its own minicompu
    13·1 answer
  • Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lowe
    8·1 answer
  • A Linux systems admin reported a suspicious .py file that ran on a daily schedule after business hours. The file includes shellc
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!