CS/자료구조
-
[whiteship스터디 4주차 과제]LinkedList를 이용해 Queue 구현CS/자료구조 2021. 6. 19. 11:50
큐의 FIFO 특징을 간단하게 구현했습니다. Main 클래스 package Week4_Queue_ListNode; public class Test { public static void main(String[] args) { Queue queue = new Queue(); for (int i = 0; i < 3; i++) { queue.push(i); } System.out.println("Queue Size : " + queue.size); queue.showItems(); System.out.println(queue.pop().data); System.out.println(queue.pop().data); System.out.println(queue.pop().data); System.out.print..
-
[whiteship스터디 4주차 과제]ListNode클래스를 이용해 Stack구현CS/자료구조 2021. 5. 16. 10:39
과제 4. 앞서 만든 ListNode를 사용해서 Stack을 구현하세요. ListNode head를 가지고 있는 ListNodeStack 클래스를 구현하세요. void push(int data)를 구현하세요. int pop()을 구현하세요. package Week4_Stack_ListNode; public class ListNode { public int data; public ListNode next; ListNode(){ this.data = 0; this.next=null; } } package Week4_Stack_ListNode; public class Stack { public ListNode head; public int size = 0; public void push(int data) { ..
-
[whiteship스터디 4주차 과제]배열을 이용한 스택 구현CS/자료구조 2021. 5. 15. 09:40
Stack 클래스 package Week3_Stack; public class Stack { private int[] list; private int pointer; private int size; Stack(int size) { this.pointer = 0; this.size = size; this.list = new int[size]; } void push(int data) { if (pointer >= size) { System.out.println("OverFlow"); return; } list[pointer] = data; pointer++; //스택의 상태를 출력 for (int i = 0; i ");..
-
[whiteship스터디]single linked list 구현CS/자료구조 2021. 4. 11. 13:52
과제 2. LinkedList를 구현하세요. LinkedList에 대해 공부하세요. 정수를 저장하는 ListNode 클래스를 구현하세요. ListNode add(ListNode head, ListNode nodeToAdd, int position)를 구현하세요. ListNode remove(ListNode head, int positionToRemove)를 구현하세요. boolean contains(ListNode head, ListNode nodeTocheck)를 구현하세요. 2021.01.26 - [스터디/[whiteship]JAVA] - [4주차]제어문 [노드 클래스] public class Node { public T data; public Node next; public Node(T data) ..