subject

(a) Write an iterative algorithm in Java-like pseudocode for printing a singly linked list in reverse in O(N) time. You can use as much 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.
(b) 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.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 17:40
Write a program that begins by reading in a series of positive integers on a single line of input and then computes and prints the product of those integers. integers are accepted and multiplied until the user enters an integer less than 1. this final number is not part of the product. then, the program prints the product. if the first entered number is negative or 0, the program must print β€œbad input.” and terminate immediately
Answers: 2
question
Computers and Technology, 24.06.2019 19:50
How to unblock on chrome book? ?
Answers: 1
question
Computers and Technology, 24.06.2019 22:30
Distinguish between a skill resume and a chronological resume and explain when it is best to use each format
Answers: 1
question
Computers and Technology, 25.06.2019 05:20
6. write a user-defined matlab function for the following math function: r() = 4cos(4sin ) the input to the function is  (in radians) and the output is r. write the function such that  can be a vector. a) use the function to calculate r(/6) and r(5/6). b) use the function to plot (polar plot) r() for 0 ≀  ≀ 2. hint: use β€œ polar” and/or for β€œpolar plot in matlab." include the title β€œ'r(\theta)=4cos(4sin(\theta))”
Answers: 1
You know the right answer?
(a) Write an iterative algorithm in Java-like pseudocode for printing a singly linked list in revers...
Questions
question
Mathematics, 19.05.2021 18:10
Questions on the website: 13722362