Learn basic concept of c , c++ and python programming in regularcodes.com
How to find nth element from the end of linked list using Stack data structure?
In this post We are discussing about how to find nth last node of single linked list. Let given an example
Example :Suppose following data are exist in linked list [144, 325, 343, 44, 23, 36, 66, 125, 343, 612].
View and Edit Linked list Click Here.
Find -nth Last Node Is : 125 Find -nth Last Node Is : 23 Find -nth Node Not Exist Find -nth Node Node Is : 343
Code Executrion Process: Below in show. And more execution process Click Here
Code implementation: Below in C programn and Time complexity of this problem O(n).
Case 1: Empty Linked list Output Empty linked List case 2: When linked list are not empty Output Linked list data is : 144 325 343 44 23 36 66 125 343 612 Find -nth Last Node Is : 125 Find -nth Last Node Is : 23 Find -nth Node Not Exist Free linked list Node element