|
@@ -1 +1,30 @@
|
1
|
|
-# DataStructures
|
|
1
|
+# Data structures
|
|
2
|
+
|
|
3
|
+Fork this repository and submit your code via pull request.
|
|
4
|
+
|
|
5
|
+##Linked List
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+### Requirements
|
|
9
|
+
|
|
10
|
+Implement a singly linked list:
|
|
11
|
+
|
|
12
|
+- You may not use the `LinkedList` or `ArrayList` class or any other predefined Java collections
|
|
13
|
+- Your linked list must have a node inner class to represent each element
|
|
14
|
+- Your linked list must have add, remove, contains, find, size, get, copy and sort methods
|
|
15
|
+- Method definitions:
|
|
16
|
+ - add -- add an element to the list
|
|
17
|
+ - remove -- remove an element (specified by numeric index) from the list
|
|
18
|
+ - contains -- returns true if the element is in the list, false otherwise
|
|
19
|
+ - find -- returns the element's index if it is in the list, -1 otherwise
|
|
20
|
+ - size -- returns the current size of the list
|
|
21
|
+ - get -- returns the element at the specified index
|
|
22
|
+ - copy -- returns a new linked list containing the same values (look up deep versus shallow copy)
|
|
23
|
+ - sort -- sorts the list using your algorithm of choice. You must perform the sorting yourself (no fair using someone else's library)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+### Optional features
|
|
27
|
+
|
|
28
|
+- implement your linked list as a generic class that can store any type of object
|
|
29
|
+- Add a reverse method
|
|
30
|
+- Add a slice method that returns a copy of a subset of the element of the list (eg slice(2,8) returns a new linked list containing elements #2,3,4,5,6,7 -- but not 8)
|