0% found this document useful (0 votes)
106 views

Assignment 1 For Java

This document provides instructions for an assignment on data structures and algorithms. It consists of two parts: 1) Implementing a List interface using arrays and linked lists, and 2) Analyzing the time complexity of the List methods for both implementations. For part 1, students must complete the array and linked list implementations by defining remaining methods like isFull() and resize() for the array version, and maintaining head and tail references for the linked list version. For part 2, students must analyze the time complexity of each List method for both implementations and report the results in a table. The submission should include 3 Java files and 1 Word document.

Uploaded by

Muhammad Zaheer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views

Assignment 1 For Java

This document provides instructions for an assignment on data structures and algorithms. It consists of two parts: 1) Implementing a List interface using arrays and linked lists, and 2) Analyzing the time complexity of the List methods for both implementations. For part 1, students must complete the array and linked list implementations by defining remaining methods like isFull() and resize() for the array version, and maintaining head and tail references for the linked list version. For part 2, students must analyze the time complexity of each List method for both implementations and report the results in a table. The submission should include 3 Java files and 1 Word document.

Uploaded by

Muhammad Zaheer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Data Structures and Algorithms

SABA ANWAR

Assignment-1
Assignment Date March 01, 2017

Submission Deadline March 13, 2017 (11:45pm online)

Submission Type Group

Instructions Only submit java file


Properly format your codes, mention roll-number at start of each file
in comments
Only submit at canvas, no submission through any other mean
Plagiarized assignments would be graded to 0.

Part 1: List Implementation


You are provided an interface with predefined methods.

COMSATS Institute of Information Technology, Lahore Page 1


Data Structures and Algorithms
SABA ANWAR
You need to provide two implementations of this interface. Starter code for both of these
implementation is also provided with 3 methods already implemented. Go through the code carefully
and then implement remaining methods.
1. With array
Additional methods need to be defined:
isFull()
resize(): which will resize the array either to increase the capacity or decrease the capacity
to increase: if array is full then increase the size by 50%
to decrease: if 75% of existing array becomes empty then decrease the capacity to 50% of
existing or to initial capacity.
in any case capacity should not be lower than user defined initial capacity. For example:
if initial capacity is 10 (through default constructor) then capacity would never become less than
10.
if initial capacity is 50 (through parameterized constructor) then capacity would never become
less than 50.
You have to maintain initial capacity in a separate variable.
2. With double linked list
Maintain both head and tail references.
As mentioned in List methods are handling Object class, which can be sort of object, so you do
not need to define a specific Node class for this purpose. Node class has already been defined in
LinkedList class.

Note that this a nested class and in all methods of linked list where you need a node, you have
to define an object of this class and original object will passed to its constructor as a data part of
node with next and previous reference as null.
Things to be considered:

Do not print anything in both classes, just return appropriate values or throw exceptions where
needed.
Strictly no change in List and already defined things of both classes.
Properly comment your code.
You can define additional methods if needed, but make them private.

COMSATS Institute of Information Technology, Lahore Page 2


Data Structures and Algorithms
SABA ANWAR

Part 2: Time Complexity Analysis


Provide an estimate of T(n) and Big-O of all methods from List interface for:

Array implementation
Linked List implementation
Make a table to report your result, where first column would list names of methods, and next two
columns would describe T(n) and Big-O for array implementation and remaining two would do the same
for linked list implementation.
Good luck
Submission:
Submit 3 java files from part-1 and 1 word document for part-2,
One txt file with name Task Distribution. Clearly divide the tasks and mention in this file which member
has done what.

COMSATS Institute of Information Technology, Lahore Page 3

You might also like