Microsoft Interview Question: Ways to print a singly-linked... | Glassdoor

Interview Question

Software Developer Interview(Student Candidate) Redmond, WA

Ways to print a singly-linked list in reverse order

 . Advantages/disadvantages.

Interview Answer

2 Answers


Recursively (faster runtime, more memory, can cause stack overflow), with a stack (more memory but faster runtime), and iteratively (very bad runtime but least amount of memory).

Interview Candidate on Nov 29, 2015

Time Complexity : O(n)

Space Complexity: O(1)

Assumption : Can temporarily modify LL

Reverse LL in O (n) time
Print the LL in O(n) time
Reverse LL in O(n) time to get back to original state

gator on Apr 23, 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.