interview questions and answers

Technical Interview Questions | DataStructure Interview Questions

Home interview questions Programming interview questions DataStructure 
Saturday, 11 February 2012
Main Menu
Home
Online Test
Contest
Search
FAQs
Contact Us
Login
Most Popular Category
JAVA

Microsoft Technologies
ASP, C#, DotNet, ...

Programming
C++, PHP, VB, ...

SAP

Testing

Web Technologies

Polls
Does personal networking help in job search?
 
IT Placement Papers interview questions Programming interview questions DataStructure

This category contains DataStructure Interview Questions and Answers


Return Nth the node from the end of the linked list in one pass.

PDF Print E-mail


Node * GetNthNode ( Node* Head , int NthNode )
{
    Node * pNthNode = NULL;
    Node * pTempNode = NULL;
    int nCurrentElement = 0;
   
for ( pTempNode = Head; pTempNode != NULL; pTempNode = pTempNode->pNext )
    {
        nCurrentElement++;           
        if ( nCurrentElement - NthNode == 0 )
        {
            pNthNode = Head;
        }
        else
        if ( nCurrentElement - NthNode > 0)
        {
            pNthNode = pNthNode ->pNext;
        }                   
    }
    if (pNthNode )
    {
        return pNthNode;
    }
    else
        return NULL;
}





Be first to comment this article

Only registered users can write comments.
Please login or register.

 
Next >

Technical Interview Questions | DataStructure Interview Questions

Top!
Top!
Copyright © 2008 InterviewDuniya.com All Rights Reserved.
Partner Site: Maheshwari Matrimony