employer cover photo
employer logo
employer logo

National Instruments

Is this your company?

National Instruments interview question

Given a linked list, write a function that will print the list in reverse.

Interview Answers

Anonymous

7 Apr 2011

Do this in linear O(n) time without recursion and without creating a copy of the list. [Hint] You can modify the list, as long as you put it back the way it started.

Anonymous

9 Jan 2013

Traverse the list from start to end updating the link addresses such that the second node points to first, third node points to second and so on. when we reach the last node we will have reverse list. Now repeat the whole process but this time printing the elements of the nodes. We will get the original list back and items printed are in reverse order as well. I am proud of myself !! :)