CSC-113-Tutorial 12 - boolean insertAfterElement(int...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
KSU / CCIS / CS DEPARTMENT CSC-113, SPRING 2010 TUTORIAL 12 Linked-List Exercise-1 : Assume you have the following list: Head Draw a picture of the list after the following code is executed: Node curr = head; while (curr.getNext()!= NULL) curr = curr.getNext(); curr.setNext(head); head = head.getNext(); curr = curr.getNext(); curr.setNext(NULL); Exercise -2 Write a method
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: boolean insertAfterElement(int value1, int value2) which inserts value1 after the first element greater than vlaue2 . Consider special cases: 1) list empty 2) no element in the list is greater than value2 . Example: insertAfterElement(77, 10) means to insert 77 after the first element greater than 10. Head Head 2 3 12 6 2 3 6 12 77 100 200 300...
View Full Document

This note was uploaded on 11/28/2011 for the course COMPUTER S 113 taught by Professor Dr.safwanqasem during the Spring '11 term at King Saud University.

Ask a homework question - tutors are online