ulrail.gif

Lab 7

  ur-2c.gif urrail.gif
blrail-nonavbar.gif

Home | Resources | Assignments | Exams
Lectures | Course Staff | Submit

br-2a.gif   br-2c.gif brrail.gif
spacer.gif

spacer.gif

CS101 Lab 7: Insertion Sort with Linked Lists

This Lab

Write a program called InsertionSort.java that reads a sequence of strings from a file, that inserts each string into an initially empty linked list in ascending alphabetical order, and that prints the contents of the list after the last string has been inserted.

Note: given two String objects, s1 and s2, you can compare them lexicographically using s1.compareTo(s2). The challenge in this lab is to understand how to insert a new element into a list at the right place. When done, consider the running time of this sorting algorithm. Submit your program with a comment at the start of the file indicating the running time.

SUBMISSION

Submit InsertionSort.java as usual.

spacer.gif
spacer.gif footer-middle.gif spacer.gif