Skip to content
Open

ff #1

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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
64 changes: 32 additions & 32 deletions JavaDS.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,36 @@ public static void main(String[] args){
QUEUE1.display();


//linkedlist teseter
LinkedList list = new LinkedList();
list.addToTail(5);
list.addToTail(2);
list.addToTail(-2);
System.out.println(list.removeHead()+ " Is the head, and it's been removed");
System.out.println(list.getHead()+" This is the new head");
list.addToTail(3);
list.addToTail(1000);
System.out.println(list.contains(1000));

//tree tester
Tree tree = new Tree();
int[] items = {5, 8, 7, 1, 9, 3, 0, 4, 6, 2};
for (int i : items)
tree.addChild(i);

System.out.println("Is it contain 3: " + tree.contains(3));
tree.display();


//hashtable tester
HashTable hashTable = new HashTable();
// Put some key values.
hashTable.insert("cat","1");
hashTable.insert("cat","2");
hashTable.insert("dog","3");
hashTable.remove("cat");
System.out.println(hashTable.retrieve("dog"));
}

}
// //linkedlist teseter
// LinkedList list = new LinkedList();
// list.addToTail(5);
// list.addToTail(2);
// list.addToTail(-2);
// System.out.println(list.removeHead()+ " Is the head, and it's been removed");
// System.out.println(list.getHead()+" This is the new head");
// list.addToTail(3);
// list.addToTail(1000);
// System.out.println(list.contains(1000));

// //tree tester
// Tree tree = new Tree();
// int[] items = {5, 8, 7, 1, 9, 3, 0, 4, 6, 2};
// for (int i : items)
// tree.addChild(i);

// System.out.println("Is it contain 3: " + tree.contains(3));
// tree.display();


// //hashtable tester
// HashTable hashTable = new HashTable();
// // Put some key values.
// hashTable.insert("cat","1");
// hashTable.insert("cat","2");
// hashTable.insert("dog","3");
// hashTable.remove("cat");
// System.out.println(hashTable.retrieve("dog"));
// }

// }

56 changes: 49 additions & 7 deletions LinkedList.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,70 @@
public class LinkedList {
public Node head;

public void addToTail(int data) {
public class LinkedList {

public Node head=new Node();
public Node tail=new Node();




public void addToTail(int data) {
//your code is here
Node node1=new Node();

node1.value=data;

if(head.next==null){
head.next=node1;
}
if(tail.next!=null){
tail.next.next=node1;

}
tail.next=node1;

}

public boolean contains(int value) {
//your code is here
Node node1 =head;
while(node1.next!=null){
if(node1.value==value){
return true;
}
node1=node1.next;
}
if(node1.value==value){
return true;
}
return false;
}

public int removeHead() {
//your code is here
}
if(head.next!=null){

if(head.next.next==null){
tail.next=null;
}

Node node1=head.next;
head.next=node1.next;
return node1.value;
}
else {
return 0;}

public void printList() {
//your code is here
}

public int getHead() {
public void printList() {
//your code is here
}


public class Node {
//your code is here
public int value ;
public Node next;
}

}
46 changes: 38 additions & 8 deletions Queue.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,43 @@
public class Queue {
// your code is here
public void push(int pushedElement){
//your code is here
}
import java.util.Arrays;


public class Queue{

int [] arr=new int [3];
int front=0;
int rear=0;
int numberelem=0;


public void push(int elem){
if(numberelem<3){
arr[rear]=elem;
rear++;
numberelem++;

}
else {
System.out.println("overflow");
}
}


public void pop(){
//your code is here
if(numberelem>0){
arr[front]="-1";
front++;
numberelem--;
}
else{
System.out.println("queue is empty");
}


}

public void display(){
//your code is here
for(int i=0;i<3;i++){
System.out.println(arr[i]);
}
}

}
39 changes: 31 additions & 8 deletions Stack.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
public class Stack {
//your code is here
public void push(int pushedElement){
//your code is here
}
public void pop() {
//your code is here
import java.util.Arrays;

public class Stack{
public int []= new int[3];
public numberelem=0;
public top=-1;

public void push(int elem){
if(numberelem<3){
arr[top+1]=elem;
top++;
}
}
else{
System.out.println("stack is full ");
}


public void pop(){
if(numberelem>0){
top--;
}
else{
System.out.println("stack is empty ");
}
}



}



}
19 changes: 19 additions & 0 deletions node_modules/acorn-dynamic-import/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/acorn-dynamic-import/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions node_modules/acorn-dynamic-import/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/acorn-dynamic-import/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading