SlideShare a Scribd company logo
1 of 26
project2/.classpath
project2/.project
project2
linklist
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
project2/bin/project2/emplist.classpackage project2;
publicsynchronizedclass emplist {
public void emplist();
publicstatic void main(String[]) throws java.io.IOException;
}
project2/bin/project2/method1.classpackage project2;
publicsynchronizedclass method1 {
java.util.LinkedList newList;
public void method1();
void reverse(java.util.LinkedList);
void downsize(java.util.LinkedList, int);
}
project2/employees.txt
Ahmed
Bill
Diana
Harry
Juliet
Nina
Romeo
Sam
Tom
Zack
project2/src/project2/emplist.javaproject2/src/project2/emplist.j
avapackage project2;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.ListIterator;
publicclass emplist {
publicstaticvoid main(String[] args)throwsIOException{
// TODO Auto-generated method stub
LinkedList<String> linkedlist =newLinkedList<String>();
method1 obj =new method1();
System.out.println("ttt********************************
************************");
System.out.println("ttt********* This Program was written
by ziyad **********");
System.out.println("ttt********************************
************************");
try(BufferedReader br =newBufferedReader(newFileReader(
"employees.txt"))){
String sCurrentLine;
while((sCurrentLine = br.readLine())!=null){
// System.out.println(sCurrentLine);
linkedlist.add(sCurrentLine);
// System.out.println(linkedlist);
}
String firstElement = linkedlist.get(0);
String lastElement = linkedlist.getLast();
System.out.println("tDisplaying List contentusing traditional fo
r loop");
for(int i =0; i < linkedlist.size(); i++){
System.out.println("Name of Emp is "+ linkedlist.get(i));
}
System.out.println("The first element of the List: "+ firstElemen
t);
System.out.println("The last element of the List: "+ lastElement
);
System.out.println("The size of the list after removing the last e
lement Zack is: 9");
System.out.println("tDisplaying using by using enhances for lo
op: ");
for(int a =0; a < linkedlist.size(); a++){
System.out.println(linkedlist.get(a));
}
ListIterator iter = linkedlist.listIterator();
while(iter.hasNext()){
int i = iter.nextIndex();
iter.next();
// System.out.println(iter.next() + " is at index" + i);
if(i ==0){
System.out.println("The current emplyee after advancing the ite
r five timers is: "
+ iter.previous());
Object element = iter.next();
iter.add("kelly");
// iter.set( "Kelly");
int k =0;
// while( k < linkedlist.size())
{
System.out.println("tDisplaying list after inserting Kelly after t
he fifth positionn"+ linkedlist +" ");
k++;
}
}elseif(i ==6){
System.out.println("tDisplaying list after setting the current ele
ment to Nancy"+ iter.previous());
Object element1 = iter.next();
iter.set("Nancy");
// iter.set( "");
int j =0;
// while( k < linkedlist.size())
{
System.out
.println("tDisplaying list after replacing the Kelly n"
+ linkedlist +" ");
j++;
}
break;
}
}
System.out
.println("tDisplaying the list after calling the reverse method: "
);
obj.reverse(linkedlist);
System.out
.println("tDisplaying the list after calling the reverse method o
ne more time: n"
+ linkedlist);
System.out
.println("tDisplaying the list after calling the downsize method
with n=2 ");
obj.downsize(linkedlist,2);
}
}
}
project2/src/project2/method1.javaproject2/src/project2/method
1.javapackage project2;
import java.util.LinkedList;
publicclass method1 {
LinkedList<String> newList =newLinkedList<String>();
void reverse(LinkedList<String> strings){
newList.addAll(strings);
LinkedList<String> string1 = strings;
System.out.println(string1);
System.out.println("tDisplaying the list after calling the revers
e method ");
int k = strings.size();
System.out.print("[");
for(int i =0; k >1; i++){
System.out.print(string1.get(k -2)+", ");
k--;
}
System.out.println("]");
}
void downsize(LinkedList<String> employeeNames,int n){
int k = employeeNames.size();
for(int i =0; i < k; i++){
if(i == k){
System.out.println(n
+"tEmplyee has been downsize whose name is: "
+ employeeNames.get(i));
System.out.println("tUpdated list is: ");
employeeNames.remove(i);
}
}
System.out.println(employeeNames);
}
}
Page 1 of 3
Programming Project 4 (Due 11-17-2016 at 2:00 PM)
Write a JAVA program to solve the following problem. Your
program should properly
compile and run. Your code MUST follow the documentation
style used in your textbook.
You need to upload into Moodle the following:
s expected to be
composed of multiple
source code files. Thus to organize these files, all of them have
to be part of a
single package. Your package name MUST match the directory
containing your
code file. Finally, you need to export your package as a .JAR
file then upload this
single file into Moodle. If you are not familiar with how to
export your code into
a .JAR file, please check the following link.
http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.jdt.
doc.user%2Ftasks
%2Ftasks-33.htm
Very Important Note: Do NOT upload any other files into
Moodle; just ONE file
with the extension “.jar” that is it.
Problem Statement:
In this project, you are asked to write a Java application similar
to the one you wrote in Project 2
that handles a list of employees employed by a certain company.
Your code in project 2 had used
the built-in functionalities of the LinkedList class defined in the
Java Collection Classes. In this
project, you will still use a LinkedList as the main data
structure that stores your data but you
will provide your own implementation of a class called
RecLinkedLink. In doing so, all the
required methods to be defined in your RecLinkedList needs to
be implemented using recursive
algorithms. In other words, method such as size(), replace(),
add(), remove, etc. MUST use
recursion to achieve it functions. (check chapter 5 for details).
As done before, we will assume that each employee is only
represented by her/his first name.
The names of all employees in this small company are stored in
a given data file called
empNames.txt which is posted on Moodle next to this project
statement. Your program must do
the following task:
1. Define your own recursive implementation of LinkList in a
separate file called
“RecLinkedList.java”.
2. Create an object of RecLinkedList to be used in storing and
handling employees’ data.
3. Open the given file and read employee data into the
RecLinkedList object. In doing so,
your code needs to maintain the order of employee data in the
input file.
4. Verify the content of the employee data (just read) by
displaying them on the monitor
using a traditional for loop along with appropriate output
messages.
Page 2 of 3
5. Invoke various methods of the RecLinkedList class to
retrieve then display the first
element and the last element of the list. Display appropriate
messages on the monitor.
6. Invoke various methods of the RecLinkedList class to remove
the last element then
display the size of the list after the removal operation. Display
appropriate messages on
the monitor.
7. Display the current list contents using the enhanced for loop
along with appropriate
output messages.
8. Create a ListIterator object, iter, to be used in accessing the
RecLinkedList contents.
9. Advance the iterator for five positions then display the
current list item (using iterator
method and NOT list method).
10. Insert a new employee called “Kelly” at the current iterator
position then display the
current list contents using the compact form to be used from
this point on for any list
content display. Hint, use the implicit toString().
11. Execute the iter.previous() method followed by using the
iter.set() method to set the
current element to Nancy. Then, display the current list
contents.
12. Execute the iter.previous() method followed by the remove()
method then display the
current list contents.
13. In a separate file, create a helper class called HelpLists.
This class need to have the
code for two methods described below:
a. public void reverse(RecLinkedList<String> strings). This
method receives a
RecLinkedList object as its parameter then linearly access all
the elements in the
object while pushing them in a STACK object. You need to use
the STACK data
structure that you just created to retrieve the data from the stack
and display
them in reserve order on the monitor.
b. public void FIFO(RecLinkedList<String> strings). This
method receives a
RecLinkedList object as its parameter then linearly access all
the elements in the
object while inserting them in a QUEUE object. You need to use
the QUEUE
data structure that you just created to retrieve the data from the
queue and
display them in order on the monitor.
14. In your main class, create an object of type HelpLists class
then use it in the following.
15. Invoke the reverse method to reverse the order then display
the reversed list contents.
16. Invoke the FIFO() method in order to create a queue and use
it to ensure that the order
of the data in RecLinkedList will be displayed without change.
A Sample output of your code need to look like the following
snapshot.
Page 3 of 3
(End of Project)
Koffman-index.indd 660 10/30/2015 7:27:45 PM
DATA STRUCTURES
Abstraction and Design
Using Java
THIRD EDITION
ELLIOT B. KOFFMAN
Temple University
PAUL A. T. WOLFGANG
Temple University
Koffman-ffirs.indd 1 11/3/2015 9:04:31 PM
VICE PRESIDENT & DIRECTOR Laurie Rosatone
SENIOR DIRECTOR Don Fowley
EXECUTIVE EDITOR Brian Gambrel
DEVELOPMENT EDITOR Jennifer Lartz
ASSISTANT Jessy Moor
PROJECT MANAGER Gladys Soto
PROJECT SPECIALIST Nichole Urban
PROJECT ASSISTANT Anna Melhorn
MARKETING MANAGER Dan Sayre
ASSISTANT MARKETING MANAGER Puja Katarawala
ASSOCIATE DIRECTOR Kevin Holm
SENIOR CONTENT SPECIALIST Nicole Repasky
PRODUCTION EDITOR Rajeshkumar Nallusamy
PHOTO RESEARCHER Amanda Bustard
COVER PHOTO CREDIT © Robert Davies/Shutterstock
This book was set in 10/12 pt SabonLTStd-Roman by SPiGlobal
and printed and bound by Lightning Source Inc.
Founded in 1807, John Wiley & Sons, Inc. has been a valued
source of knowledge and understanding for more than 200
years, helping people
around the world meet their needs and fulfill their aspirations.
Our company is built on a foundation of principles that include
responsibility
to the communities we serve and where we live and work. In
2008, we launched a Corporate Citizenship Initiative, a global
effort to address
the environmental, social, economic, and ethical challenges we
face in our business. Among the issues we are addressing are
carbon impact,
paper specifications and procurement, ethical conduct within
our business and among our vendors, and community and
charitable support.
For more information, please visit our website:
www.wiley.com/go/citizenship.
Copyright © 2016, 2010 John Wiley & Sons, Inc. All rights
reserved. No part of this publication may be reproduced, stored
in a retrieval
system, or transmitted in any form or by any means, electronic,
mechanical, photocopying, recording, scanning or otherwise,
except as permit-
ted under Sections 107 or 108 of the 1976 United States
Copyright Act, without either the prior written permission of
the Publisher, or authori-
zation through payment of the appropriate per‐copy fee to the
Copyright Clearance Center, Inc., 222 Rosewood Drive,
Danvers, MA 01923
(Web site: www.copyright.com). Requests to the Publisher for
permission should be addressed to the Permissions Department,
John Wiley &
Sons, Inc., 111 River Street, Hoboken, NJ 07030‐5774, (201)
748‐6011, fax (201) 748‐6008, or online at:
www.wiley.com/go/permissions.
Evaluation copies are provided to qualified academics and
professionals for review purposes only, for use in their courses
during the next
academic year. These copies are licensed and may not be sold or
transferred to a third party. Upon completion of the review
period, please
return the evaluation copy to Wiley. Return instructions and a
free of charge return shipping label are available at:
www.wiley.com/go/
returnlabel. If you have chosen to adopt this textbook for use in
your course, please accept this book as your complimentary
desk copy.
Outside of the United States, please contact your local sales
representative.
ISBN: 978-1-119-23914-7 (PBK)
ISBN: 978-1-119-22307-8 (EVALC)
Library of Congress Cataloging-in-Publication Data
Koffman, Elliot B.
[Objects, abstraction, data structures and design using Java]
Data structures : abstraction and design using Java / Elliot B.
Koffman, Temple University, Paul A.T. Wolfgang, Temple
University. —
Third edition.
pages cm
Original edition published under title: Objects, abstraction,
data structures and design using Java.
Includes index.
ISBN 978-1-119-23914-7 (pbk.) 1. Data structures (Computer
science) 2. Java (Computer program language) 3. Object-
oriented
programming (Computer science) 4. Application program
interfaces (Computer software) I. Wolfgang, Paul A. T. II. Title.
QA76.9.D35K58 2016
005.7'3—dc23
2015036861
Printing identification and country of origin will either be
included on this page and/or the end of the book. In addition, if
the ISBN on this
page and the back cover do not match, the ISBN on the back
cover should be considered the correct ISBN.
Printed in the United States of America
10 9 8 7 6 5 4 3 2 1
Koffman-ffirs.indd 2 11/4/2015 3:00:52 PM
http://www.wiley.com/go/citizenship
http://www.copyright.com
http://www.wiley.com/go/permissions
http://www.wiley.com/goreturnlabel
Preface
Our goal in writing this book was to combine a strong emphasis
on problem solving and
software design with the study of data structures. To this end,
we discuss applications of each
data structure to motivate its study. After providing the
specification (interface) and the
implementation (a Java class), we then cover case studies that
use the data structure to solve
a significant problem. Examples include maintaining an ordered
list, evaluating arithmetic
expressions using a stack, finding the shortest path through a
maze, and Huffman coding
using a binary tree and a priority queue. In the implementation
of each data structure and in
the solutions of the case studies, we reinforce the message
“Think, then code” by performing
a thorough analysis of the problem and then carefully designing
a solution (using pseudo‐
code and UML class diagrams) before the implementation. We
also provide a performance
analysis when appropriate. Readers gain an understanding of
why different data structures
are needed, the applications they are suited for, and the
advantages and disadvantages of their
possible implementations.
Intended Audience
This book was written for anyone with a curiosity or need to
know about data structures,
those essential elements of good programs and reliable
software. We hope that the text will
be useful to readers with either professional or educational
interests.
It is intended as a textbook for the second programming course
in a computing curriculum
involving the study of data structures, especially one that
emphasizes Object‐Oriented Design
(OOD). The text could also be used in a more‐advanced course
in algorithms and data struc-
tures. Besides coverage of the basic data structures and
algorithms (lists, stacks, queues, trees,
recursion, sorting), there are chapters on sets and maps,
balanced binary search trees, graphs,
and an online appendix on event‐oriented programming.
Although we expect that most read-
ers will have completed a first programming course in Java,
there is an extensive review
chapter (included as an appendix) for those who may have taken
a first programming course
in a different language, or for those who need a refresher in
Java.
Emphasis on the Java Collections Framework
The book focuses on the interfaces and classes in the Java
Collections Framework. We begin
the study of a new data structure by specifying an abstract data
type as an interface, which
we adapt from the Java API. Readers are encouraged throughout
the text to use the Java
Collections Framework as a resource for their programming.
Our expectation is that readers who complete this book will be
familiar with the data struc-
tures available in the Java Collections Framework and will be
able to use them in their future
programming. However, we also expect that they will want to
know how the data structures
are implemented, so we provide thorough discussions of classes
that implement these data
structures. Each class follows the approach taken by the Java
designers where appropriate.
However, when their industrial‐strength solutions appear to be
too complicated for beginners
to understand, we have provided simpler implementations but
have tried to be faithful to
their approach.
Koffman-preface.indd 3 10/20/2015 3:02:35 PM
iv Preface
Think, then Code
To help you “Think, then code” we discuss problem solving and
introduce appropriate soft-
ware design tools throughout the textbook. For example,
Chapter 1 focuses on OOD and
Class Hierarchies. It introduces the Uniform Modeling
Language (also covered in Appendix B)
to document an OOD. It introduces the use of interfaces to
specify abstract data types and to
facilitate contract programming and describes how to document
classes using Javadoc‐style
comments. There is also coverage of exceptions and exception
handling. Chapter 2 intro-
duces the Java Collections Framework and focuses on the List
interface, and it shows how to
use big‐O notation to analyze program efficiency. In Chapter 3,
we cover different testing
strategies in some detail including a discussion of test‐driven
design and the use of the JUnit
program to facilitate testing.
Features of the Third Edition
We had two major goals for the third edition. The first was to
bring the coverage of Java up to
Java 8 by introducing new features of Java where appropriate.
For example, we use the Java 7
diamond operator when creating new Collection objects. We use
the Java 8 StringJoiner in
place of the older StringBuilder for joining strings.
A rather significant change was to introduce Java 8 lambda
expressions and functional inter-
faces as a way to facilitate functional programming in Java in a
new Section 6.4. Using these
features significantly improved the code.
The second major goal was to provide additional emphasis on
testing and debugging. To
facilitate this, we moved our discussion of testing and
debugging from an appendix to
Chapter 3 and expanded our coverage of testing including more
discussion of JUnit. We also
added a new section that introduced test‐driven development.
A third goal was to ease the transition to Java for Python
programmers. When introducing
Java data structures (for example, arrays, lists, sets, and maps),
we compared them to equiva-
lent Python data structures.
Other changes to the text included reorganizing the chapter on
lists and moving the discussion
of algorithm analysis to the beginning of the chapter so that
big‐O notation could be used to
compare the efficiency of different List implementations. We
also combined the chapters on
stacks and queues and increased our emphasis on using Deque
as an alternative to the legacy
Stack class. We also added a discussion of Timsort, which is
used in Java 8, to the chapter on
sorting algorithms. Finally, some large case studies and an
appendix were moved to online
supplements.
Case Studies
We illustrate OOD principles in the design and implementation
of new data structures and in
the solution of approximately 20 case studies. Case studies
follow a five‐step process (prob-
lem specification, analysis, design, implementation, and
testing). As is done in industry, we
sometimes perform these steps in an iterative fashion rather
than in strict sequence. Several
case studies have extensive discussions of testing and include
methods that automate the test-
ing process. Some case studies are revisited in later chapters,
and solutions involving different
data structures are compared. We also provide additional case
studies on the Web site for the
textbook (www.wiley.com/college/koffman), including one that
illustrates a solution to the
same problem using several different data structures.
Koffman-preface.indd 4 10/20/2015 3:02:35 PM
http://www.wiley.com/college/koffman
Preface v
Prerequisites
Our expectation is that the reader will be familiar with the Java
primitive data types including
int, boolean, char, and double; control structures including if,
case, while, for, and try‐catch;
the String class; the one‐dimensional array; input/output using
either JOptionPane dialog win-
dows or text streams (class Scanner or BufferedReader) and
console input/output. For those
readers who lack some of the concepts or who need some
review, we provide complete coverage
of these topics in Appendix A. Although labeled an Appendix,
the review chapter provides full
coverage of the background topics and has all the pedagogical
features (discussed below) of the
other chapters. We expect most readers will have some
experience with Java programming, but
someone who knows another programming language should be
able to undertake the book
after careful study of the review chapter. We do not require
prior knowledge of inheritance,
wrapper classes, or ArrayLists as we cover them in the book
(Chapters 1 and 2).
Pedagogy
The book contains the following pedagogical features to assist
inexperienced programmers
in learning the material.
• Learning objectives at the beginning of each chapter tell
readers what skills they should
develop.
• Introductions for each chapter help set the stage for what the
chapter will cover and tie
the chapter contents to other material that they have learned.
• Case Studies emphasize problem solving and provide complete
and detailed solutions to
real‐world problems using the data structures studied in the
chapter.
• Chapter Summaries review the contents of the chapter.
• Boxed Features emphasize and call attention to material
designed to help readers become
better programmers.
Pitfall boxes help readers identify common problems and how to
avoid
them.
Design Concept boxes illuminate programming design decisions
and
trade‐offs.
Programming Style boxes discuss program features that
illustrate good
programming style and provide tips for writing clear and
effective code.
Syntax boxes are a quick reference for the Java structures being
introduced.
• Self‐Check and Programming Exercises at the end of each
section provide immediate
feedback and practice for readers as they work through the
chapter.
• Quick‐Check, Review Exercises, and Programming Projects at
the end of each chapter
review chapter concepts and give readers a variety of
skill‐building activities, including
longer projects that integrate chapter concepts as they exercise
the use of data structures.
Theoretical Rigor
In Chapter 2, we discuss algorithm efficiency and big‐O
notation as a measure of algorithm
efficiency. We have tried to strike a balance between pure
“hand waving” and extreme rigor
when determining the efficiency of algorithms. Rather than
provide several paragraphs of
Koffman-preface.indd 5 10/20/2015 3:02:42 PM
vi Preface
formulas, we have provided simplified derivations of algorithm
efficiency using big‐O nota-
tion. We feel this will give readers an appreciation of the
performance of various algorithms
and methods and the process one follows to determine algorithm
efficiency without bogging
them down in unnecessary detail.
Overview of the book
Chapter 1 introduces Object Oriented Programming,
inheritance, and class hierarchies
including interfaces and abstract classes. We also introduce
UML class diagrams and Javadoc‐
style documentation. The Exception class hierarchy is studied as
an example of a Java class
hierarchy.
Chapter 2 introduces the Java Collections Framework as the
foundation for the traditional
data structures. These are covered in separate chapters: lists
(Chapter 2), stacks, queues and
deques (Chapter 4), Trees (Chapters 6 and 9), Sets and Maps
(Chapter 7), and Graphs
(Chapter 10). Each new data structure is introduced as an
abstract data type (ADT). We pro-
vide a specification of each ADT in the form of a Java interface.
Next, we implement the data
structure as a class that implements the interface. Finally, we
study applications of the data
structure by solving sample problems and case studies.
Chapter 3 covers different aspects of testing (e.g. top‐down,
bottom‐up, white‐box, black‐
box). It includes a section on developing a JUnit test harness
and also a section on Test‐
Driven Development. It also discuses using a debugger to help
find and correct errors.
Chapter 4 discusses stacks, queues, and deques. Several
applications of these data structures
are provided.
Chapter 5 covers recursion so that readers are prepared for the
study of trees, a recursive data
structure. This chapter could be studied earlier. There is an
optional section on list processing
applications of recursion that may be skipped if the chapter is
covered earlier.
Chapter 6 discusses binary trees, including binary search trees,
heaps, priority queues, and
Huffman trees. It also shows how Java 8 lambda expressions
and functional interfaces sup-
port functional programming.
Chapter 7 covers the Set and Map interfaces. It also discusses
hashing and hash tables and
shows how a hash table can be used in an implementation of
these interfaces. Building an
index for a file and Huffman Tree encoding and decoding are
two case studies covered in this
chapter.
Chapter 8 covers various sorting algorithms including
mergesort, heapsort, quicksort and
Timsort.
Chapter 9 covers self‐balancing search trees, focusing on
algorithms for manipulating them.
Included are AVL and Red‐Black trees, 2‐3 trees, 2‐3‐4 trees,
B‐trees, and skip‐lists.
Chapter 10 covers graphs. We provide several well‐known
algorithms for graphs, including
Dijkstra’s shortest path algorithm and Prim’s minimal spanning
tree algorithm. In most pro-
grams, the last few chapters would be covered in a second
course in algorithms and data
structures.
Supplements and Companion Web Sites
The following supplementary materials are available on the
Instructor’s Companion Web Site
for this textbook at www.wiley.com/college/koffman. Items
marked for students are accessi-
ble on the Student Companion Web Site at the same address.
Koffman-preface.indd 6 10/20/2015 3:02:42 PM
http://www.wiley.com/college/koffman
Preface vii
• Additional homework problems with solutions
• Additional case studies, including one that illustrates a
solution to the same problem
using several different data structures
• Source code for all classes in the book (for students and
instructors)
• PowerPoint slides
• Electronic test bank for instructors
•
Solution
s to end‐of‐section odd‐numbered self‐check and programming
exercises (for students)
•
project2.classpathproject2.project  project2 .docx

More Related Content

Similar to project2.classpathproject2.project project2 .docx

Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxchetanpatilcp783
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsAhsanul Karim
 
ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com donaldzs157
 
ECET 370 HELPS Education Counseling--ecet370helps.com
ECET 370 HELPS  Education Counseling--ecet370helps.comECET 370 HELPS  Education Counseling--ecet370helps.com
ECET 370 HELPS Education Counseling--ecet370helps.comclaric64
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answersAkash Gawali
 
ECET 370 HELPS Redefined Education--ecet370helps.com
ECET 370 HELPS Redefined Education--ecet370helps.comECET 370 HELPS Redefined Education--ecet370helps.com
ECET 370 HELPS Redefined Education--ecet370helps.comGVlaxmi7
 
ECET 370 Achievement Education -- www.ecet370.com
ECET 370 Achievement Education -- www.ecet370.comECET 370 Achievement Education -- www.ecet370.com
ECET 370 Achievement Education -- www.ecet370.comshanaabe90
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfacesmadhavi patil
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android ApplicationMark Lester Navarro
 
Android Database Tutorial
Android Database TutorialAndroid Database Tutorial
Android Database TutorialPerfect APK
 
adjava_23_bcs_vision_academy_sachinsir.pdf
adjava_23_bcs_vision_academy_sachinsir.pdfadjava_23_bcs_vision_academy_sachinsir.pdf
adjava_23_bcs_vision_academy_sachinsir.pdfakankshasorate1
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshowilias ahmed
 
I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdffantoosh1
 

Similar to project2.classpathproject2.project project2 .docx (20)

Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Collections
CollectionsCollections
Collections
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com
 
ECET 370 HELPS Education Counseling--ecet370helps.com
ECET 370 HELPS  Education Counseling--ecet370helps.comECET 370 HELPS  Education Counseling--ecet370helps.com
ECET 370 HELPS Education Counseling--ecet370helps.com
 
Java Collections Tutorials
Java Collections TutorialsJava Collections Tutorials
Java Collections Tutorials
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers
 
ECET 370 HELPS Redefined Education--ecet370helps.com
ECET 370 HELPS Redefined Education--ecet370helps.comECET 370 HELPS Redefined Education--ecet370helps.com
ECET 370 HELPS Redefined Education--ecet370helps.com
 
ECET 370 Achievement Education -- www.ecet370.com
ECET 370 Achievement Education -- www.ecet370.comECET 370 Achievement Education -- www.ecet370.com
ECET 370 Achievement Education -- www.ecet370.com
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android Application
 
Android Database Tutorial
Android Database TutorialAndroid Database Tutorial
Android Database Tutorial
 
adjava_23_bcs_vision_academy_sachinsir.pdf
adjava_23_bcs_vision_academy_sachinsir.pdfadjava_23_bcs_vision_academy_sachinsir.pdf
adjava_23_bcs_vision_academy_sachinsir.pdf
 
LectureNotes-06-DSA
LectureNotes-06-DSALectureNotes-06-DSA
LectureNotes-06-DSA
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
 
Eclipse Tricks
Eclipse TricksEclipse Tricks
Eclipse Tricks
 
Spsl vi unit final
Spsl vi unit finalSpsl vi unit final
Spsl vi unit final
 
Spsl v unit - final
Spsl v unit - finalSpsl v unit - final
Spsl v unit - final
 
I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdf
 

More from briancrawford30935

You have collected the following documents (unstructured) and pl.docx
You have collected the following documents (unstructured) and pl.docxYou have collected the following documents (unstructured) and pl.docx
You have collected the following documents (unstructured) and pl.docxbriancrawford30935
 
You have been working as a technology associate the information .docx
You have been working as a technology associate the information .docxYou have been working as a technology associate the information .docx
You have been working as a technology associate the information .docxbriancrawford30935
 
You have chosen to join WHO. They are particularly interested in.docx
You have chosen to join WHO. They are particularly interested in.docxYou have chosen to join WHO. They are particularly interested in.docx
You have chosen to join WHO. They are particularly interested in.docxbriancrawford30935
 
You have been tasked to present at a town hall meeting in your local.docx
You have been tasked to present at a town hall meeting in your local.docxYou have been tasked to present at a town hall meeting in your local.docx
You have been tasked to present at a town hall meeting in your local.docxbriancrawford30935
 
You have been tasked as the health care administrator of a major hos.docx
You have been tasked as the health care administrator of a major hos.docxYou have been tasked as the health care administrator of a major hos.docx
You have been tasked as the health care administrator of a major hos.docxbriancrawford30935
 
You have been tasked to devise a program to address the needs of.docx
You have been tasked to devise a program to address the needs of.docxYou have been tasked to devise a program to address the needs of.docx
You have been tasked to devise a program to address the needs of.docxbriancrawford30935
 
You have been successful in your application for the position be.docx
You have been successful in your application for the position be.docxYou have been successful in your application for the position be.docx
You have been successful in your application for the position be.docxbriancrawford30935
 
You have been hired as a project management consultant by compan.docx
You have been hired as a project management consultant by compan.docxYou have been hired as a project management consultant by compan.docx
You have been hired as a project management consultant by compan.docxbriancrawford30935
 
You have been hired to manage a particular aspect of the new ad.docx
You have been hired to manage a particular aspect of the new ad.docxYou have been hired to manage a particular aspect of the new ad.docx
You have been hired to manage a particular aspect of the new ad.docxbriancrawford30935
 
You have been hired by Red Didgeridoo Technologies. They know th.docx
You have been hired by Red Didgeridoo Technologies. They know th.docxYou have been hired by Red Didgeridoo Technologies. They know th.docx
You have been hired by Red Didgeridoo Technologies. They know th.docxbriancrawford30935
 
You have been hired by TMI to design an application using shell scri.docx
You have been hired by TMI to design an application using shell scri.docxYou have been hired by TMI to design an application using shell scri.docx
You have been hired by TMI to design an application using shell scri.docxbriancrawford30935
 
You have been hired as the CSO (Chief Security Officer) for an org.docx
You have been hired as the CSO (Chief Security Officer) for an org.docxYou have been hired as the CSO (Chief Security Officer) for an org.docx
You have been hired as the CSO (Chief Security Officer) for an org.docxbriancrawford30935
 
You have been hired to evaluate the volcanic hazards associated .docx
You have been hired to evaluate the volcanic hazards associated .docxYou have been hired to evaluate the volcanic hazards associated .docx
You have been hired to evaluate the volcanic hazards associated .docxbriancrawford30935
 
You have been hired as an assistant to the public health officer for.docx
You have been hired as an assistant to the public health officer for.docxYou have been hired as an assistant to the public health officer for.docx
You have been hired as an assistant to the public health officer for.docxbriancrawford30935
 
You have been engaged to develop a special calculator program. T.docx
You have been engaged to develop a special calculator program. T.docxYou have been engaged to develop a special calculator program. T.docx
You have been engaged to develop a special calculator program. T.docxbriancrawford30935
 
You have now delivered the project to your customer ahead of schedul.docx
You have now delivered the project to your customer ahead of schedul.docxYou have now delivered the project to your customer ahead of schedul.docx
You have now delivered the project to your customer ahead of schedul.docxbriancrawford30935
 
You have now delivered the project to your customer. The project was.docx
You have now delivered the project to your customer. The project was.docxYou have now delivered the project to your customer. The project was.docx
You have now delivered the project to your customer. The project was.docxbriancrawford30935
 
You have now experienced the work of various scholars, artists and m.docx
You have now experienced the work of various scholars, artists and m.docxYou have now experienced the work of various scholars, artists and m.docx
You have now experienced the work of various scholars, artists and m.docxbriancrawford30935
 
You have learned that Mr. Moore does not drink alcohol in the mornin.docx
You have learned that Mr. Moore does not drink alcohol in the mornin.docxYou have learned that Mr. Moore does not drink alcohol in the mornin.docx
You have learned that Mr. Moore does not drink alcohol in the mornin.docxbriancrawford30935
 
You have been hired by a large hospitality firm (e.g., Marriot.docx
You have been hired by a large hospitality firm (e.g., Marriot.docxYou have been hired by a large hospitality firm (e.g., Marriot.docx
You have been hired by a large hospitality firm (e.g., Marriot.docxbriancrawford30935
 

More from briancrawford30935 (20)

You have collected the following documents (unstructured) and pl.docx
You have collected the following documents (unstructured) and pl.docxYou have collected the following documents (unstructured) and pl.docx
You have collected the following documents (unstructured) and pl.docx
 
You have been working as a technology associate the information .docx
You have been working as a technology associate the information .docxYou have been working as a technology associate the information .docx
You have been working as a technology associate the information .docx
 
You have chosen to join WHO. They are particularly interested in.docx
You have chosen to join WHO. They are particularly interested in.docxYou have chosen to join WHO. They are particularly interested in.docx
You have chosen to join WHO. They are particularly interested in.docx
 
You have been tasked to present at a town hall meeting in your local.docx
You have been tasked to present at a town hall meeting in your local.docxYou have been tasked to present at a town hall meeting in your local.docx
You have been tasked to present at a town hall meeting in your local.docx
 
You have been tasked as the health care administrator of a major hos.docx
You have been tasked as the health care administrator of a major hos.docxYou have been tasked as the health care administrator of a major hos.docx
You have been tasked as the health care administrator of a major hos.docx
 
You have been tasked to devise a program to address the needs of.docx
You have been tasked to devise a program to address the needs of.docxYou have been tasked to devise a program to address the needs of.docx
You have been tasked to devise a program to address the needs of.docx
 
You have been successful in your application for the position be.docx
You have been successful in your application for the position be.docxYou have been successful in your application for the position be.docx
You have been successful in your application for the position be.docx
 
You have been hired as a project management consultant by compan.docx
You have been hired as a project management consultant by compan.docxYou have been hired as a project management consultant by compan.docx
You have been hired as a project management consultant by compan.docx
 
You have been hired to manage a particular aspect of the new ad.docx
You have been hired to manage a particular aspect of the new ad.docxYou have been hired to manage a particular aspect of the new ad.docx
You have been hired to manage a particular aspect of the new ad.docx
 
You have been hired by Red Didgeridoo Technologies. They know th.docx
You have been hired by Red Didgeridoo Technologies. They know th.docxYou have been hired by Red Didgeridoo Technologies. They know th.docx
You have been hired by Red Didgeridoo Technologies. They know th.docx
 
You have been hired by TMI to design an application using shell scri.docx
You have been hired by TMI to design an application using shell scri.docxYou have been hired by TMI to design an application using shell scri.docx
You have been hired by TMI to design an application using shell scri.docx
 
You have been hired as the CSO (Chief Security Officer) for an org.docx
You have been hired as the CSO (Chief Security Officer) for an org.docxYou have been hired as the CSO (Chief Security Officer) for an org.docx
You have been hired as the CSO (Chief Security Officer) for an org.docx
 
You have been hired to evaluate the volcanic hazards associated .docx
You have been hired to evaluate the volcanic hazards associated .docxYou have been hired to evaluate the volcanic hazards associated .docx
You have been hired to evaluate the volcanic hazards associated .docx
 
You have been hired as an assistant to the public health officer for.docx
You have been hired as an assistant to the public health officer for.docxYou have been hired as an assistant to the public health officer for.docx
You have been hired as an assistant to the public health officer for.docx
 
You have been engaged to develop a special calculator program. T.docx
You have been engaged to develop a special calculator program. T.docxYou have been engaged to develop a special calculator program. T.docx
You have been engaged to develop a special calculator program. T.docx
 
You have now delivered the project to your customer ahead of schedul.docx
You have now delivered the project to your customer ahead of schedul.docxYou have now delivered the project to your customer ahead of schedul.docx
You have now delivered the project to your customer ahead of schedul.docx
 
You have now delivered the project to your customer. The project was.docx
You have now delivered the project to your customer. The project was.docxYou have now delivered the project to your customer. The project was.docx
You have now delivered the project to your customer. The project was.docx
 
You have now experienced the work of various scholars, artists and m.docx
You have now experienced the work of various scholars, artists and m.docxYou have now experienced the work of various scholars, artists and m.docx
You have now experienced the work of various scholars, artists and m.docx
 
You have learned that Mr. Moore does not drink alcohol in the mornin.docx
You have learned that Mr. Moore does not drink alcohol in the mornin.docxYou have learned that Mr. Moore does not drink alcohol in the mornin.docx
You have learned that Mr. Moore does not drink alcohol in the mornin.docx
 
You have been hired by a large hospitality firm (e.g., Marriot.docx
You have been hired by a large hospitality firm (e.g., Marriot.docxYou have been hired by a large hospitality firm (e.g., Marriot.docx
You have been hired by a large hospitality firm (e.g., Marriot.docx
 

Recently uploaded

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 

project2.classpathproject2.project project2 .docx

  • 1. project2/.classpath project2/.project project2 linklist org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature project2/bin/project2/emplist.classpackage project2; publicsynchronizedclass emplist { public void emplist(); publicstatic void main(String[]) throws java.io.IOException; } project2/bin/project2/method1.classpackage project2; publicsynchronizedclass method1 { java.util.LinkedList newList; public void method1();
  • 2. void reverse(java.util.LinkedList); void downsize(java.util.LinkedList, int); } project2/employees.txt Ahmed Bill Diana Harry Juliet Nina Romeo Sam Tom Zack project2/src/project2/emplist.javaproject2/src/project2/emplist.j avapackage project2; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.LinkedList; import java.util.ListIterator; publicclass emplist {
  • 3. publicstaticvoid main(String[] args)throwsIOException{ // TODO Auto-generated method stub LinkedList<String> linkedlist =newLinkedList<String>(); method1 obj =new method1(); System.out.println("ttt******************************** ************************"); System.out.println("ttt********* This Program was written by ziyad **********"); System.out.println("ttt******************************** ************************"); try(BufferedReader br =newBufferedReader(newFileReader( "employees.txt"))){ String sCurrentLine; while((sCurrentLine = br.readLine())!=null){ // System.out.println(sCurrentLine); linkedlist.add(sCurrentLine); // System.out.println(linkedlist); } String firstElement = linkedlist.get(0); String lastElement = linkedlist.getLast(); System.out.println("tDisplaying List contentusing traditional fo r loop"); for(int i =0; i < linkedlist.size(); i++){ System.out.println("Name of Emp is "+ linkedlist.get(i)); } System.out.println("The first element of the List: "+ firstElemen t); System.out.println("The last element of the List: "+ lastElement ); System.out.println("The size of the list after removing the last e lement Zack is: 9");
  • 4. System.out.println("tDisplaying using by using enhances for lo op: "); for(int a =0; a < linkedlist.size(); a++){ System.out.println(linkedlist.get(a)); } ListIterator iter = linkedlist.listIterator(); while(iter.hasNext()){ int i = iter.nextIndex(); iter.next(); // System.out.println(iter.next() + " is at index" + i); if(i ==0){ System.out.println("The current emplyee after advancing the ite r five timers is: " + iter.previous()); Object element = iter.next(); iter.add("kelly"); // iter.set( "Kelly"); int k =0; // while( k < linkedlist.size()) { System.out.println("tDisplaying list after inserting Kelly after t he fifth positionn"+ linkedlist +" "); k++; } }elseif(i ==6){ System.out.println("tDisplaying list after setting the current ele ment to Nancy"+ iter.previous()); Object element1 = iter.next(); iter.set("Nancy"); // iter.set( ""); int j =0; // while( k < linkedlist.size()) { System.out .println("tDisplaying list after replacing the Kelly n"
  • 5. + linkedlist +" "); j++; } break; } } System.out .println("tDisplaying the list after calling the reverse method: " ); obj.reverse(linkedlist); System.out .println("tDisplaying the list after calling the reverse method o ne more time: n" + linkedlist); System.out .println("tDisplaying the list after calling the downsize method with n=2 "); obj.downsize(linkedlist,2); } } } project2/src/project2/method1.javaproject2/src/project2/method 1.javapackage project2; import java.util.LinkedList; publicclass method1 { LinkedList<String> newList =newLinkedList<String>();
  • 6. void reverse(LinkedList<String> strings){ newList.addAll(strings); LinkedList<String> string1 = strings; System.out.println(string1); System.out.println("tDisplaying the list after calling the revers e method "); int k = strings.size(); System.out.print("["); for(int i =0; k >1; i++){ System.out.print(string1.get(k -2)+", "); k--; } System.out.println("]"); } void downsize(LinkedList<String> employeeNames,int n){ int k = employeeNames.size(); for(int i =0; i < k; i++){ if(i == k){ System.out.println(n +"tEmplyee has been downsize whose name is: " + employeeNames.get(i)); System.out.println("tUpdated list is: "); employeeNames.remove(i); } } System.out.println(employeeNames); } }
  • 7. Page 1 of 3 Programming Project 4 (Due 11-17-2016 at 2:00 PM) Write a JAVA program to solve the following problem. Your program should properly compile and run. Your code MUST follow the documentation style used in your textbook. You need to upload into Moodle the following: s expected to be composed of multiple source code files. Thus to organize these files, all of them have to be part of a single package. Your package name MUST match the directory containing your code file. Finally, you need to export your package as a .JAR file then upload this single file into Moodle. If you are not familiar with how to export your code into a .JAR file, please check the following link. http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.jdt. doc.user%2Ftasks %2Ftasks-33.htm Very Important Note: Do NOT upload any other files into Moodle; just ONE file with the extension “.jar” that is it. Problem Statement: In this project, you are asked to write a Java application similar to the one you wrote in Project 2
  • 8. that handles a list of employees employed by a certain company. Your code in project 2 had used the built-in functionalities of the LinkedList class defined in the Java Collection Classes. In this project, you will still use a LinkedList as the main data structure that stores your data but you will provide your own implementation of a class called RecLinkedLink. In doing so, all the required methods to be defined in your RecLinkedList needs to be implemented using recursive algorithms. In other words, method such as size(), replace(), add(), remove, etc. MUST use recursion to achieve it functions. (check chapter 5 for details). As done before, we will assume that each employee is only represented by her/his first name. The names of all employees in this small company are stored in a given data file called empNames.txt which is posted on Moodle next to this project statement. Your program must do the following task: 1. Define your own recursive implementation of LinkList in a separate file called “RecLinkedList.java”. 2. Create an object of RecLinkedList to be used in storing and handling employees’ data. 3. Open the given file and read employee data into the RecLinkedList object. In doing so, your code needs to maintain the order of employee data in the input file. 4. Verify the content of the employee data (just read) by displaying them on the monitor
  • 9. using a traditional for loop along with appropriate output messages. Page 2 of 3 5. Invoke various methods of the RecLinkedList class to retrieve then display the first element and the last element of the list. Display appropriate messages on the monitor. 6. Invoke various methods of the RecLinkedList class to remove the last element then display the size of the list after the removal operation. Display appropriate messages on the monitor. 7. Display the current list contents using the enhanced for loop along with appropriate output messages. 8. Create a ListIterator object, iter, to be used in accessing the RecLinkedList contents. 9. Advance the iterator for five positions then display the current list item (using iterator method and NOT list method). 10. Insert a new employee called “Kelly” at the current iterator position then display the current list contents using the compact form to be used from this point on for any list content display. Hint, use the implicit toString(). 11. Execute the iter.previous() method followed by using the
  • 10. iter.set() method to set the current element to Nancy. Then, display the current list contents. 12. Execute the iter.previous() method followed by the remove() method then display the current list contents. 13. In a separate file, create a helper class called HelpLists. This class need to have the code for two methods described below: a. public void reverse(RecLinkedList<String> strings). This method receives a RecLinkedList object as its parameter then linearly access all the elements in the object while pushing them in a STACK object. You need to use the STACK data structure that you just created to retrieve the data from the stack and display them in reserve order on the monitor. b. public void FIFO(RecLinkedList<String> strings). This method receives a RecLinkedList object as its parameter then linearly access all the elements in the object while inserting them in a QUEUE object. You need to use the QUEUE data structure that you just created to retrieve the data from the queue and display them in order on the monitor. 14. In your main class, create an object of type HelpLists class then use it in the following. 15. Invoke the reverse method to reverse the order then display the reversed list contents.
  • 11. 16. Invoke the FIFO() method in order to create a queue and use it to ensure that the order of the data in RecLinkedList will be displayed without change. A Sample output of your code need to look like the following snapshot. Page 3 of 3 (End of Project) Koffman-index.indd 660 10/30/2015 7:27:45 PM DATA STRUCTURES Abstraction and Design Using Java THIRD EDITION ELLIOT B. KOFFMAN Temple University
  • 12. PAUL A. T. WOLFGANG Temple University Koffman-ffirs.indd 1 11/3/2015 9:04:31 PM VICE PRESIDENT & DIRECTOR Laurie Rosatone SENIOR DIRECTOR Don Fowley EXECUTIVE EDITOR Brian Gambrel DEVELOPMENT EDITOR Jennifer Lartz ASSISTANT Jessy Moor PROJECT MANAGER Gladys Soto PROJECT SPECIALIST Nichole Urban PROJECT ASSISTANT Anna Melhorn MARKETING MANAGER Dan Sayre ASSISTANT MARKETING MANAGER Puja Katarawala ASSOCIATE DIRECTOR Kevin Holm SENIOR CONTENT SPECIALIST Nicole Repasky PRODUCTION EDITOR Rajeshkumar Nallusamy PHOTO RESEARCHER Amanda Bustard COVER PHOTO CREDIT © Robert Davies/Shutterstock This book was set in 10/12 pt SabonLTStd-Roman by SPiGlobal and printed and bound by Lightning Source Inc. Founded in 1807, John Wiley & Sons, Inc. has been a valued source of knowledge and understanding for more than 200 years, helping people around the world meet their needs and fulfill their aspirations. Our company is built on a foundation of principles that include responsibility to the communities we serve and where we live and work. In 2008, we launched a Corporate Citizenship Initiative, a global effort to address the environmental, social, economic, and ethical challenges we
  • 13. face in our business. Among the issues we are addressing are carbon impact, paper specifications and procurement, ethical conduct within our business and among our vendors, and community and charitable support. For more information, please visit our website: www.wiley.com/go/citizenship. Copyright © 2016, 2010 John Wiley & Sons, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permit- ted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authori- zation through payment of the appropriate per‐copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923 (Web site: www.copyright.com). Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030‐5774, (201) 748‐6011, fax (201) 748‐6008, or online at: www.wiley.com/go/permissions. Evaluation copies are provided to qualified academics and professionals for review purposes only, for use in their courses during the next academic year. These copies are licensed and may not be sold or transferred to a third party. Upon completion of the review period, please return the evaluation copy to Wiley. Return instructions and a free of charge return shipping label are available at: www.wiley.com/go/
  • 14. returnlabel. If you have chosen to adopt this textbook for use in your course, please accept this book as your complimentary desk copy. Outside of the United States, please contact your local sales representative. ISBN: 978-1-119-23914-7 (PBK) ISBN: 978-1-119-22307-8 (EVALC) Library of Congress Cataloging-in-Publication Data Koffman, Elliot B. [Objects, abstraction, data structures and design using Java] Data structures : abstraction and design using Java / Elliot B. Koffman, Temple University, Paul A.T. Wolfgang, Temple University. — Third edition. pages cm Original edition published under title: Objects, abstraction, data structures and design using Java. Includes index. ISBN 978-1-119-23914-7 (pbk.) 1. Data structures (Computer science) 2. Java (Computer program language) 3. Object- oriented programming (Computer science) 4. Application program interfaces (Computer software) I. Wolfgang, Paul A. T. II. Title. QA76.9.D35K58 2016 005.7'3—dc23 2015036861 Printing identification and country of origin will either be included on this page and/or the end of the book. In addition, if the ISBN on this page and the back cover do not match, the ISBN on the back cover should be considered the correct ISBN.
  • 15. Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 Koffman-ffirs.indd 2 11/4/2015 3:00:52 PM http://www.wiley.com/go/citizenship http://www.copyright.com http://www.wiley.com/go/permissions http://www.wiley.com/goreturnlabel Preface Our goal in writing this book was to combine a strong emphasis on problem solving and software design with the study of data structures. To this end, we discuss applications of each data structure to motivate its study. After providing the specification (interface) and the implementation (a Java class), we then cover case studies that use the data structure to solve a significant problem. Examples include maintaining an ordered list, evaluating arithmetic expressions using a stack, finding the shortest path through a maze, and Huffman coding using a binary tree and a priority queue. In the implementation of each data structure and in the solutions of the case studies, we reinforce the message “Think, then code” by performing a thorough analysis of the problem and then carefully designing a solution (using pseudo‐ code and UML class diagrams) before the implementation. We also provide a performance analysis when appropriate. Readers gain an understanding of why different data structures
  • 16. are needed, the applications they are suited for, and the advantages and disadvantages of their possible implementations. Intended Audience This book was written for anyone with a curiosity or need to know about data structures, those essential elements of good programs and reliable software. We hope that the text will be useful to readers with either professional or educational interests. It is intended as a textbook for the second programming course in a computing curriculum involving the study of data structures, especially one that emphasizes Object‐Oriented Design (OOD). The text could also be used in a more‐advanced course in algorithms and data struc- tures. Besides coverage of the basic data structures and algorithms (lists, stacks, queues, trees, recursion, sorting), there are chapters on sets and maps, balanced binary search trees, graphs, and an online appendix on event‐oriented programming. Although we expect that most read- ers will have completed a first programming course in Java, there is an extensive review chapter (included as an appendix) for those who may have taken a first programming course in a different language, or for those who need a refresher in Java. Emphasis on the Java Collections Framework The book focuses on the interfaces and classes in the Java Collections Framework. We begin the study of a new data structure by specifying an abstract data type as an interface, which
  • 17. we adapt from the Java API. Readers are encouraged throughout the text to use the Java Collections Framework as a resource for their programming. Our expectation is that readers who complete this book will be familiar with the data struc- tures available in the Java Collections Framework and will be able to use them in their future programming. However, we also expect that they will want to know how the data structures are implemented, so we provide thorough discussions of classes that implement these data structures. Each class follows the approach taken by the Java designers where appropriate. However, when their industrial‐strength solutions appear to be too complicated for beginners to understand, we have provided simpler implementations but have tried to be faithful to their approach. Koffman-preface.indd 3 10/20/2015 3:02:35 PM iv Preface Think, then Code To help you “Think, then code” we discuss problem solving and introduce appropriate soft- ware design tools throughout the textbook. For example, Chapter 1 focuses on OOD and Class Hierarchies. It introduces the Uniform Modeling Language (also covered in Appendix B) to document an OOD. It introduces the use of interfaces to specify abstract data types and to facilitate contract programming and describes how to document
  • 18. classes using Javadoc‐style comments. There is also coverage of exceptions and exception handling. Chapter 2 intro- duces the Java Collections Framework and focuses on the List interface, and it shows how to use big‐O notation to analyze program efficiency. In Chapter 3, we cover different testing strategies in some detail including a discussion of test‐driven design and the use of the JUnit program to facilitate testing. Features of the Third Edition We had two major goals for the third edition. The first was to bring the coverage of Java up to Java 8 by introducing new features of Java where appropriate. For example, we use the Java 7 diamond operator when creating new Collection objects. We use the Java 8 StringJoiner in place of the older StringBuilder for joining strings. A rather significant change was to introduce Java 8 lambda expressions and functional inter- faces as a way to facilitate functional programming in Java in a new Section 6.4. Using these features significantly improved the code. The second major goal was to provide additional emphasis on testing and debugging. To facilitate this, we moved our discussion of testing and debugging from an appendix to Chapter 3 and expanded our coverage of testing including more discussion of JUnit. We also added a new section that introduced test‐driven development. A third goal was to ease the transition to Java for Python programmers. When introducing
  • 19. Java data structures (for example, arrays, lists, sets, and maps), we compared them to equiva- lent Python data structures. Other changes to the text included reorganizing the chapter on lists and moving the discussion of algorithm analysis to the beginning of the chapter so that big‐O notation could be used to compare the efficiency of different List implementations. We also combined the chapters on stacks and queues and increased our emphasis on using Deque as an alternative to the legacy Stack class. We also added a discussion of Timsort, which is used in Java 8, to the chapter on sorting algorithms. Finally, some large case studies and an appendix were moved to online supplements. Case Studies We illustrate OOD principles in the design and implementation of new data structures and in the solution of approximately 20 case studies. Case studies follow a five‐step process (prob- lem specification, analysis, design, implementation, and testing). As is done in industry, we sometimes perform these steps in an iterative fashion rather than in strict sequence. Several case studies have extensive discussions of testing and include methods that automate the test- ing process. Some case studies are revisited in later chapters, and solutions involving different data structures are compared. We also provide additional case studies on the Web site for the textbook (www.wiley.com/college/koffman), including one that illustrates a solution to the same problem using several different data structures.
  • 20. Koffman-preface.indd 4 10/20/2015 3:02:35 PM http://www.wiley.com/college/koffman Preface v Prerequisites Our expectation is that the reader will be familiar with the Java primitive data types including int, boolean, char, and double; control structures including if, case, while, for, and try‐catch; the String class; the one‐dimensional array; input/output using either JOptionPane dialog win- dows or text streams (class Scanner or BufferedReader) and console input/output. For those readers who lack some of the concepts or who need some review, we provide complete coverage of these topics in Appendix A. Although labeled an Appendix, the review chapter provides full coverage of the background topics and has all the pedagogical features (discussed below) of the other chapters. We expect most readers will have some experience with Java programming, but someone who knows another programming language should be able to undertake the book after careful study of the review chapter. We do not require prior knowledge of inheritance, wrapper classes, or ArrayLists as we cover them in the book (Chapters 1 and 2). Pedagogy The book contains the following pedagogical features to assist inexperienced programmers in learning the material.
  • 21. • Learning objectives at the beginning of each chapter tell readers what skills they should develop. • Introductions for each chapter help set the stage for what the chapter will cover and tie the chapter contents to other material that they have learned. • Case Studies emphasize problem solving and provide complete and detailed solutions to real‐world problems using the data structures studied in the chapter. • Chapter Summaries review the contents of the chapter. • Boxed Features emphasize and call attention to material designed to help readers become better programmers. Pitfall boxes help readers identify common problems and how to avoid them. Design Concept boxes illuminate programming design decisions and trade‐offs. Programming Style boxes discuss program features that illustrate good programming style and provide tips for writing clear and effective code. Syntax boxes are a quick reference for the Java structures being introduced.
  • 22. • Self‐Check and Programming Exercises at the end of each section provide immediate feedback and practice for readers as they work through the chapter. • Quick‐Check, Review Exercises, and Programming Projects at the end of each chapter review chapter concepts and give readers a variety of skill‐building activities, including longer projects that integrate chapter concepts as they exercise the use of data structures. Theoretical Rigor In Chapter 2, we discuss algorithm efficiency and big‐O notation as a measure of algorithm efficiency. We have tried to strike a balance between pure “hand waving” and extreme rigor when determining the efficiency of algorithms. Rather than provide several paragraphs of Koffman-preface.indd 5 10/20/2015 3:02:42 PM vi Preface formulas, we have provided simplified derivations of algorithm efficiency using big‐O nota- tion. We feel this will give readers an appreciation of the performance of various algorithms and methods and the process one follows to determine algorithm efficiency without bogging them down in unnecessary detail. Overview of the book Chapter 1 introduces Object Oriented Programming,
  • 23. inheritance, and class hierarchies including interfaces and abstract classes. We also introduce UML class diagrams and Javadoc‐ style documentation. The Exception class hierarchy is studied as an example of a Java class hierarchy. Chapter 2 introduces the Java Collections Framework as the foundation for the traditional data structures. These are covered in separate chapters: lists (Chapter 2), stacks, queues and deques (Chapter 4), Trees (Chapters 6 and 9), Sets and Maps (Chapter 7), and Graphs (Chapter 10). Each new data structure is introduced as an abstract data type (ADT). We pro- vide a specification of each ADT in the form of a Java interface. Next, we implement the data structure as a class that implements the interface. Finally, we study applications of the data structure by solving sample problems and case studies. Chapter 3 covers different aspects of testing (e.g. top‐down, bottom‐up, white‐box, black‐ box). It includes a section on developing a JUnit test harness and also a section on Test‐ Driven Development. It also discuses using a debugger to help find and correct errors. Chapter 4 discusses stacks, queues, and deques. Several applications of these data structures are provided. Chapter 5 covers recursion so that readers are prepared for the study of trees, a recursive data structure. This chapter could be studied earlier. There is an optional section on list processing
  • 24. applications of recursion that may be skipped if the chapter is covered earlier. Chapter 6 discusses binary trees, including binary search trees, heaps, priority queues, and Huffman trees. It also shows how Java 8 lambda expressions and functional interfaces sup- port functional programming. Chapter 7 covers the Set and Map interfaces. It also discusses hashing and hash tables and shows how a hash table can be used in an implementation of these interfaces. Building an index for a file and Huffman Tree encoding and decoding are two case studies covered in this chapter. Chapter 8 covers various sorting algorithms including mergesort, heapsort, quicksort and Timsort. Chapter 9 covers self‐balancing search trees, focusing on algorithms for manipulating them. Included are AVL and Red‐Black trees, 2‐3 trees, 2‐3‐4 trees, B‐trees, and skip‐lists. Chapter 10 covers graphs. We provide several well‐known algorithms for graphs, including Dijkstra’s shortest path algorithm and Prim’s minimal spanning tree algorithm. In most pro- grams, the last few chapters would be covered in a second course in algorithms and data structures. Supplements and Companion Web Sites The following supplementary materials are available on the
  • 25. Instructor’s Companion Web Site for this textbook at www.wiley.com/college/koffman. Items marked for students are accessi- ble on the Student Companion Web Site at the same address. Koffman-preface.indd 6 10/20/2015 3:02:42 PM http://www.wiley.com/college/koffman Preface vii • Additional homework problems with solutions • Additional case studies, including one that illustrates a solution to the same problem using several different data structures • Source code for all classes in the book (for students and instructors) • PowerPoint slides • Electronic test bank for instructors • Solution s to end‐of‐section odd‐numbered self‐check and programming exercises (for students) •