diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 27875fa6e082..000000000000 Binary files a/.DS_Store and /dev/null differ diff --git a/Palindrome.java b/Palindrome.java new file mode 100644 index 000000000000..b36900375310 --- /dev/null +++ b/Palindrome.java @@ -0,0 +1,17 @@ +public class Palidrome { + + //helper method + public String reverseString(String x){ + String output = ""; + for(int i=x.length()-1; i>=0; i--){ + output += x.charAt(i); //addition of chars create String + } + return output; + } + + //palidrome method + public Boolean isPalindrome(String x){ + return (x.equalsIgnoreCase(reverseString(x))); + } + + } diff --git a/data_structures/.project b/data_structures/.project new file mode 100644 index 000000000000..224621d79a1e --- /dev/null +++ b/data_structures/.project @@ -0,0 +1,17 @@ + + + data_structures + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/data_structures/SinglyLinkedList.java b/data_structures/SinglyLinkedList.java index 4523739b3a98..14356901577b 100644 --- a/data_structures/SinglyLinkedList.java +++ b/data_structures/SinglyLinkedList.java @@ -1,9 +1,9 @@ /** * This class implements a SinglyLinked List. This is done - * using SinglyLinkedList class and a LinkForLinkedList Class. + * using SinglyLinkedList class and a Node Class. * - * A linked list is implar to an array, it hold values. - * However, links in a linked list do not have indexes. With + * A linked list or Node is implar to an array, it hold values. + * However, nodes in a linked list do not have indexes. With * a linked list you do not need to predetermine it's size as * it gorws and shrinks as it is edited. This is an example of * a singly linked list. Elements can only be added/removed @@ -14,7 +14,7 @@ */ class SinglyLinkedList{ /**Head refered to the front of the list */ - private LinkForLinkedList head; + private Node head; /** * Constructor of SinglyLinkedList @@ -29,7 +29,7 @@ public SinglyLinkedList(){ * @param x Element to be added */ public void insertHead(int x){ - LinkForLinkedList newLink = new LinkForLinkedList(x); //Create a new link with a value attached to it + Node newLink = new Node(x); //Create a new link with a value attached to it newLink.next = head; //Set the new link to point to the current head head = newLink; //Now set the new link to be the head } @@ -39,8 +39,8 @@ public void insertHead(int x){ * * @return The element deleted */ - public LinkForLinkedList deleteHead(){ - LinkForLinkedList temp = head; + public Node deleteHead(){ + Node temp = head; head = head.next; //Make the second element in the list the new head, the Java garbage collector will later remove the old head return temp; } @@ -58,9 +58,9 @@ public boolean isEmpty(){ * Prints contents of the list */ public void display(){ - LinkForLinkedList current = head; + Node current = head; while(current!=null){ - current.displayLink(); + System.out.print(current.getValue() +" "); current = current.next; } System.out.println(); @@ -96,26 +96,26 @@ public static void main(String args[]){ * @author Unknown * */ -class LinkForLinkedList{ +class Node{ /** The value of the node */ public int value; /** Point to the next node */ - public LinkForLinkedList next; //This is what the link will point to + public Node next; //This is what the link will point to /** * Constructor * * @param valuein Value to be put in the node */ - public LinkForLinkedList(int valuein){ - value = valuein; + public Node(int newValue){ + value = newValue; } - + /** - * Prints out the value of the node + * Returns the value of the node */ - public void displayLink(){ - System.out.print(value+" "); + public int getValue(){ + return value; } -} \ No newline at end of file +} diff --git a/data_structures/bin/.classpath b/data_structures/bin/.classpath new file mode 100644 index 000000000000..47b5b52899fb --- /dev/null +++ b/data_structures/bin/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/data_structures/bin/.gitignore b/data_structures/bin/.gitignore new file mode 100644 index 000000000000..ae3c1726048c --- /dev/null +++ b/data_structures/bin/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/data_structures/bin/.project b/data_structures/bin/.project new file mode 100644 index 000000000000..224621d79a1e --- /dev/null +++ b/data_structures/bin/.project @@ -0,0 +1,17 @@ + + + data_structures + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/data_structures/bin/AVLtree$Node.class b/data_structures/bin/AVLtree$Node.class new file mode 100644 index 000000000000..e3acc0f0b584 Binary files /dev/null and b/data_structures/bin/AVLtree$Node.class differ diff --git a/data_structures/bin/AVLtree.class b/data_structures/bin/AVLtree.class new file mode 100644 index 000000000000..03cb4cf9f330 Binary files /dev/null and b/data_structures/bin/AVLtree.class differ diff --git a/data_structures/bin/CircleLinkedList$Node.class b/data_structures/bin/CircleLinkedList$Node.class new file mode 100644 index 000000000000..20b6cc66468a Binary files /dev/null and b/data_structures/bin/CircleLinkedList$Node.class differ diff --git a/data_structures/bin/CircleLinkedList.class b/data_structures/bin/CircleLinkedList.class new file mode 100644 index 000000000000..fcc71dcc7ab8 Binary files /dev/null and b/data_structures/bin/CircleLinkedList.class differ diff --git a/data_structures/bin/DoublyLinkedList.class b/data_structures/bin/DoublyLinkedList.class new file mode 100644 index 000000000000..762c5cca6e5f Binary files /dev/null and b/data_structures/bin/DoublyLinkedList.class differ diff --git a/data_structures/bin/Graph.class b/data_structures/bin/Graph.class new file mode 100644 index 000000000000..5ce8e4d02d78 Binary files /dev/null and b/data_structures/bin/Graph.class differ diff --git a/data_structures/bin/Graphs.class b/data_structures/bin/Graphs.class new file mode 100644 index 000000000000..62b058e3bdef Binary files /dev/null and b/data_structures/bin/Graphs.class differ diff --git a/data_structures/bin/Link.class b/data_structures/bin/Link.class new file mode 100644 index 000000000000..dd1ed55037d8 Binary files /dev/null and b/data_structures/bin/Link.class differ diff --git a/data_structures/bin/Node.class b/data_structures/bin/Node.class new file mode 100644 index 000000000000..3343700a302d Binary files /dev/null and b/data_structures/bin/Node.class differ diff --git a/data_structures/bin/PriorityQueue.class b/data_structures/bin/PriorityQueue.class new file mode 100644 index 000000000000..adbc203cf140 Binary files /dev/null and b/data_structures/bin/PriorityQueue.class differ diff --git a/data_structures/bin/PriorityQueues.class b/data_structures/bin/PriorityQueues.class new file mode 100644 index 000000000000..6e833f02fbb2 Binary files /dev/null and b/data_structures/bin/PriorityQueues.class differ diff --git a/data_structures/bin/Queue.class b/data_structures/bin/Queue.class new file mode 100644 index 000000000000..22ff823ec48d Binary files /dev/null and b/data_structures/bin/Queue.class differ diff --git a/data_structures/bin/Queues.class b/data_structures/bin/Queues.class new file mode 100644 index 000000000000..ff6634f47720 Binary files /dev/null and b/data_structures/bin/Queues.class differ diff --git a/data_structures/bin/SinglyLinkedList.class b/data_structures/bin/SinglyLinkedList.class new file mode 100644 index 000000000000..0445224e66de Binary files /dev/null and b/data_structures/bin/SinglyLinkedList.class differ diff --git a/data_structures/bin/Stack.class b/data_structures/bin/Stack.class new file mode 100644 index 000000000000..a2e0db3cd3e5 Binary files /dev/null and b/data_structures/bin/Stack.class differ diff --git a/data_structures/bin/Stack2.class b/data_structures/bin/Stack2.class new file mode 100644 index 000000000000..f713f50b2b40 Binary files /dev/null and b/data_structures/bin/Stack2.class differ diff --git a/data_structures/bin/Stacks.class b/data_structures/bin/Stacks.class new file mode 100644 index 000000000000..b173ec58864b Binary files /dev/null and b/data_structures/bin/Stacks.class differ diff --git a/data_structures/bin/Tree.class b/data_structures/bin/Tree.class new file mode 100644 index 000000000000..54d94d16af47 Binary files /dev/null and b/data_structures/bin/Tree.class differ diff --git a/data_structures/bin/heaps/EmptyHeapException.class b/data_structures/bin/heaps/EmptyHeapException.class new file mode 100644 index 000000000000..5fbe5efb037f Binary files /dev/null and b/data_structures/bin/heaps/EmptyHeapException.class differ diff --git a/data_structures/bin/heaps/Heap.class b/data_structures/bin/heaps/Heap.class new file mode 100644 index 000000000000..0038b198751b Binary files /dev/null and b/data_structures/bin/heaps/Heap.class differ diff --git a/data_structures/bin/heaps/HeapElement.class b/data_structures/bin/heaps/HeapElement.class new file mode 100644 index 000000000000..1d5981a27748 Binary files /dev/null and b/data_structures/bin/heaps/HeapElement.class differ diff --git a/data_structures/bin/heaps/MaxHeap.class b/data_structures/bin/heaps/MaxHeap.class new file mode 100644 index 000000000000..9016a03a837f Binary files /dev/null and b/data_structures/bin/heaps/MaxHeap.class differ diff --git a/data_structures/bin/heaps/MinHeap.class b/data_structures/bin/heaps/MinHeap.class new file mode 100644 index 000000000000..531c4e5032cf Binary files /dev/null and b/data_structures/bin/heaps/MinHeap.class differ