×

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.

**Accepted Result**:

Find [3]-nth Last Node Is : 125 Find [6]-nth Last Node Is : 23 Find [11]-nth Node Not Exist Find [2]-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).

Output

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 [3]-nth Last Node Is : 125 Find [6]-nth Last Node Is : 23 Find [11]-nth Node Not Exist Free linked list Node element

View comments and participate Discussion