Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
17 changes: 17 additions & 0 deletions Palindrome.java
Original file line number Diff line number Diff line change
@@ -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)));
}

}
17 changes: 17 additions & 0 deletions data_structures/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>data_structures</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
36 changes: 18 additions & 18 deletions data_structures/SinglyLinkedList.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,7 +14,7 @@
*/
class SinglyLinkedList{
/**Head refered to the front of the list */
private LinkForLinkedList head;
private Node head;

/**
* Constructor of SinglyLinkedList
Expand All @@ -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
}
Expand All @@ -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;
}
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}

}
}
7 changes: 7 additions & 0 deletions data_structures/bin/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="Trees/" kind="src" path=""/>
<classpathentry kind="src" path="Trees"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions data_structures/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions data_structures/bin/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>data_structures</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Binary file added data_structures/bin/AVLtree$Node.class
Binary file not shown.
Binary file added data_structures/bin/AVLtree.class
Binary file not shown.
Binary file added data_structures/bin/CircleLinkedList$Node.class
Binary file not shown.
Binary file added data_structures/bin/CircleLinkedList.class
Binary file not shown.
Binary file added data_structures/bin/DoublyLinkedList.class
Binary file not shown.
Binary file added data_structures/bin/Graph.class
Binary file not shown.
Binary file added data_structures/bin/Graphs.class
Binary file not shown.
Binary file added data_structures/bin/Link.class
Binary file not shown.
Binary file added data_structures/bin/Node.class
Binary file not shown.
Binary file added data_structures/bin/PriorityQueue.class
Binary file not shown.
Binary file added data_structures/bin/PriorityQueues.class
Binary file not shown.
Binary file added data_structures/bin/Queue.class
Binary file not shown.
Binary file added data_structures/bin/Queues.class
Binary file not shown.
Binary file added data_structures/bin/SinglyLinkedList.class
Binary file not shown.
Binary file added data_structures/bin/Stack.class
Binary file not shown.
Binary file added data_structures/bin/Stack2.class
Binary file not shown.
Binary file added data_structures/bin/Stacks.class
Binary file not shown.
Binary file added data_structures/bin/Tree.class
Binary file not shown.
Binary file added data_structures/bin/heaps/EmptyHeapException.class
Binary file not shown.
Binary file added data_structures/bin/heaps/Heap.class
Binary file not shown.
Binary file added data_structures/bin/heaps/HeapElement.class
Binary file not shown.
Binary file added data_structures/bin/heaps/MaxHeap.class
Binary file not shown.
Binary file added data_structures/bin/heaps/MinHeap.class
Binary file not shown.