Lab 01@dsa
Lab 01@dsa
DATA STRUCTURES
Lab01 – Arrays/Linkedlist
Saif Hassan
READ IT FIRST
Prior to start solving the problems in this assignments, please give full concentration on
following points.
1. WORKING – This is individual lab. If you are stuck in a problem contact your teacher, but,
in mean time start doing next question (don’t waste time).
4. HOW TO SUBMIT – rename all .java/.cpp files as task number and make .zip file, name it
as 000-00-0000_lab01_Section.zip, and submit .java/.cpp file ONLY.
2. It is not bad if you keep your code indented inside the loops, if and else blocks as well.
Exercises
Arrays
Task01 (NLP)
Create a file named NLArray.java and design following functions:
- String [] wordTokenize (String fileName) à Read any text file and return list
of words from that file. (Ignore . , : and all these types operators)
- String[] extractEmail (String fileName) à Read any text file and return all
emails from and file
Note: Read about Natural Language Processing (NLP), Word Tokenizing, Stop Words,
Information Extraction/Retrieval for Knowledge.
- void cropCenterPart (int arr[][]) à This function should extract center part
and print from arr, center part includes everything except Boundaries (Boundaries include
1st row, 1st col, last row, last col).
N is 4 so matrix is 4x4 and in 4 consecutive values are same so it should return True.
Page 2 of 4
Lab01 – Arrays/Linkedlist Data Structures Instructor: Saif Hassan
This trick will allow your code to be a little simpler, not requiring a special case for add or remove
operations. Your constructor method will be:
public LinkedList(){
// a list interface
public interface List {
public boolean isEmpty();
// returns true if the list is empty, false otherwise
Page 3 of 4
Lab01 – Arrays/Linkedlist Data Structures Instructor: Saif Hassan
In addition to the interface, your LinkedList class needs to implement a toString() method that
prints the list in the format
• Submit the file LinkedList.java and additional files if applicable. Your Node class should be
an inner class within the LinkedList class. Make sure your class implements the interface
as specified, i.e. your class should begin with public class LinkedList implements
List.
• When commenting your code use Javadoc style comments at the beginning of each method.
• Put comments at the top of the file (Java File) with your name, S_ID, S_Name, date and course,
and a short (one or two line) description of what the program does. Make sure your code runs on
machine.
Submit your source code files via the classroom by the due date (remember the course syllabus for the
late policy).
Page 4 of 4