Computer Science 387

자료구조 | Linked Queue, Linked Stack | Linked Lists

자료구조 | Singly Linked List | Linked List (tistory.com) 자료구조 | Singly Linked List | Linked List singly Linked List가 동작하기 위해 필요한 클래스 링크드 리스트는 노드로 구성된다. 노드는 노드 자신의 data와 다른 노드와 연결되는 link로 구성된다. 단방향으로만 연결해주는 리스트 형태를 Singl tomatolife.tistory.com Linked Queue Singly Linked List에 미리 구현해둔 함수 중 몇 개를 가져오면 된다. isEmtpy add_rear pop_front import random class Node: def __init__(self, item): self.data = item se..

자료구조 | Singly Linked List | Linked List

singly Linked List가 동작하기 위해 필요한 클래스 링크드 리스트는 노드로 구성된다. 노드는 노드 자신의 data와 다른 노드와 연결되는 link로 구성된다. 단방향으로만 연결해주는 리스트 형태를 Singly linked list라고 한다. DLL Doubly linked list의 경우, left link와 right link를 모두 제공한다. 스켈레톤 코드 : 함수가.. 많기도 하다. class Node: def __init__(self): pass class SLL: def __init__(self): pass def isEmpty(self): pass def addFront(self, node): pass def addRear(self, node): pass def addSort(se..

자료구조 | Maze Problem | linear DS

미로 탈출하기 문제 : 입구로부터 출구로 나가는 길을 찾아라! 조건 : 0은 움직일 수 있는 길, 1은 불가능한 길이다. 방향 : 상하좌우, 대각선으로 움직일 수 있다. 추가적인 안내 미로는 2차원 배열에 구현되어 있다. 입구는 maze[0][0]이고, 출구는 maze[row-1][col-1]이다. 나가는 길을 찾기 위해 move[0] move[1] move[2] move[3] 을 사용할 수 있다. maze[next_row][next_col] = ? mark라는 배열을 만들어 지나온 길을 기록해둔다. mark = [[0]*10 for i in range(10)] mark=[[0]*10 for i in range(10)] print(mark) path stack backtracking을 위한 stack으로..

자료구조 7강 | Search 탐색 (순차, 이진, 해시, 보간) | 숙명여대 학점교류

숙명여대 학점교류로 듣는 자료구조 day 6. 2021.12.29. 수요일 Search Sequential search binary search interpolation search hashing search Sequential search a search key is searched sequentially from the first item of a list with unordered items average # of comparisons : (n+1)/2 def seqsearch(num, item, n): for i in range(n): if item == num[i]: return i return -1 레코드에서 아무런 가공을 하지 않고 탐색을 시작한다. 계속 반복적으로 + 순서대로 비교한다. b..

자료구조 6강-2 | Linked List | 숙명여대 학점교류

숙명여대 학점교류로 듣는 자료구조 day 6. 2021.12.29. 수요일 Doubly linked list problem of SLL when deleting a node, it should know a prior node to connect the list DLL each node had both before and after nodes easy to delete / insert a node fields data left link right link applications binary tree DLL Insert class Node: def __init__(self, data): self.data = data self.llink = None self.rlink = None def insert(self..

자료구조 | 수식 변환 계산 expression evaluation | postfix, prefix

Expression evaluation 파이썬 자료구조를 활용해서 수식을 계산해보자! 수식에는 + - * / 와 같은 연산자와 1 2 3 a b c와 같은 피연산자가 있다. 수식 = {연산자 operator} + {피연산자 operand} 이때 연산자는 산술 연산자(+ - / *), 논리 연산자(and or), 할당 연산자(=) 등이 있다. 수식을 표현하는 방식은 연산자의 위치에 따라 infix, postfix, prefix로 분류할 수 있다. infix notation 주로 사람이 쓰는 수식 표현 방식이다. a / b - c + d * e - a * c postfix notation 컴퓨터가 이해하기 위한 수식 표현 방식으로 연산자가 계산의 대상이 되는 피연산자 바로 뒤에 위치한다. infix nota..

자료구조 6장 | Linked List | 숙명여대 학점교류

학점교류로 듣는 숙명여대 자료구조 day 4. 2021.12.27. 월 Introduction Singly linked list linked stack and queue deque circular list doubly linked list Introduction list a list is a collection data type that has a sequence of elements ex) days of week, months of year linked list elements are physically distributed in memory logically sequential by link pointer # link 변수 variable list size easy to Create, insert, ..

자료구조 5-2장 | Linear Data Structure | 숙명여대 학점교류

학점교류로 듣는 숙명여대 자료구조 day 4. 2021.12.27. 월 INTRO 선형 큐를 리스트로 만들었다. 반면, Circular Queue는 None 만큼의 사이즈를 만들었다. Expression Evaluation 수식 변환 an expression consists of operator = arithmetic, logical, assignment operand = variable, constant types of expression notation depends on operator position against operand infix notation : a/b - c+d*e-a*c postfix notation : a b / c - d e * + a c * - prefix notation :..

Simple Data Structure | Queue, Circular Queue, Stack, N Queens Problem, fraction, prime number, fibonacci, bowling game, binary search

학점교류로 듣는 숙명여대 학점교류 자료구조 연습 Queue Circular Queue Stack N Queens Problem fraction prime number fibonacci bowling game permutation binary search hanoi tower Queue # queue class queue: # __init__ def __init__(self): self.que = [] # empty def empty(self): return len(self.que)==0 # size def size(self): return len(self.que) # enqueue def enqueue(self,data): self.que.append(data) # dequeue def dequeue(s..

자료구조 5장 | Linear Data Structure | 숙명여대 학점교류

학점교류로 듣는 숙명여대 자료구조 day 3. 2021.12.24. 금 Linear DS Stack Queue Circular Queue Expression Evaluation Maze Problem Stack 스택 last in first out LIFO Stack and Queue special types of ordered list elements are inserted, deleted thru one end of stack, called top applications procedure call management expression evaluation Balanced Parenthesis (5+6)*(9+8)/(6+2) open close가 같아야 한다. Decimal to Binary 123(1..