Code IT/Data-Structure11 [자료구조] Circular Queue 원형 큐 front와 rear 설정 시 % 해줘야 하는 것 말고는 무난 ! import java.io.*; public class CircularQueue { private int[] key; // 원형 큐이므로 이후 연산에 front나 rear 값 설정 시 % cq.max_qsize 해줘야 함. private int front; private int rear; private int qsize; private int max_qsize; public CircularQueue() { front = 0; rear = 0; qsize = 0; max_qsize = 0; } public static CircularQueue CreateCircularQ(int max) { // 큐 생성 CircularQueue cq = n.. 2021. 4. 3. [자료구조] 중위표기식, 후위표기식, 변환 1InToPost - 중위에서 후위로 표기 변환 import java.io.*; import java.util.*;; public class InToPost { private static class Stack { // 배열로 stack 구현 ArrayList key = new ArrayList(); int top; // 배열의 마지막 부분이 top으로 작용 void push(String newKey) { // 배열의 마지막으로 삽입 key.add(newKey); top = key.indexOf(newKey); } void pop() { // 마지막 요소 꺼내고 출력 후 삭제 if (key.get(top).equals("(")) { // 열린 괄호는 출력하지 않고 삭제 key.remove(top--); }.. 2021. 4. 3. [자료구조] LinkedList 연결 리스트 학생 객체를 노드로 받아서 연결리스트로 표현하기. - dirty code 안되도록 더 노력해보기. import java.io.*; class Node { //리스트의 노드 객체 생성 int studentId; String studentName; Node next; } class List { // 리스트 생성 Node first; List() { first = null; // 헤더 역할. first } } public class LinkedListTest { //메인 & 메서드 public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new FileReader("input.txt")); .. 2021. 4. 3. 이전 1 2 3 다음