14CS2
Leon Reznik
Week 9
Find a Position in a Linked List
•public static IntNode listPosition (IntNode head, int position)
•{
• IntNode cursor;
• int i;
• if (position <=0)
•throw new IllegalArgumentException (“position is invalid”);
• cursor = head;
• for (i=1; (i < position) && (cursor != null); i++)
• cursor = cursor.link;
• return cursor;
•}