CS/자료구조 11

Programming Exercise: Lab #4

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Exercise #1ProblemsImplement linked structure STACK.~StackType(): destructorsize(): returns the length of stackpush(): pushes a new item into the stackpop(): pops and returns the item at the top of stack (if the stack is empty, return -1)StackType::~StackType(){ NodeType* tempPtr = topPtr; while (tempPtr != nullptr) { topPtr = topPtr->next; ..

CS/자료구조 2025.04.19

Chapter 5: Linked Structures

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Linked Structure Array-based Stack Implementation▶ In the previous implementation, we consider an entire stack (a set of items) as a single object (array). New stack Implementation▶ Here, we consider each item in the stack a single object (Node).How could we define relationships between items? (Who's on top of whom?)Node Implementation▶ A pointer can be used..

CS/자료구조 2025.04.16

Programming Exercise: Lab #3

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Exercise #1ProblemsImplement rotateFirstItem() in Circular Queue with Reserved space.This function "ROTATES" the first item of the queue.▶ Both are OKAY (in-place or not)! HINT: It is allowed to call "other member functions" inside a member function.e.g., enqueue(), dequeue(), isEmpty(), etc.)templatevoid QueueType::rotateFirstItem(){ if(isEmpty()){ ..

CS/자료구조 2025.04.16

Chapter 4.5: Programming Tips

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Call by X▶ Swap Example (1) - call by valueswap1_a = 3swap1_b = 5▶ Looking into 'Swap1'▶ Swap Example (2) - call by referenceswap2_a = 5swap2_b = 3▶ Swap Example (3) - call by pointer(address)swap3_a = 5 swap3_b = 3▶ Swap Example (4)swap1_a = 3swap1_b = 5 C/C++ Basics:it is almost about "copy" How C/C++ Deals with Variables: Copy▶ copyWe learned it as "inser..

CS/자료구조 2025.04.16

Programming Exercise: Lab #2

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Exercise #1ProblemsImplement (1) BinarySearch(int item) and (2) BinarySearchNearest(int item).Assume that there are No duplicated elements in the list.▶ (1) BinarySearch(int item) is the function we already learned in the class.The only difference is that "it returns the index of the item" if foundOtherwise, it returns -1template int SortedType::BinarySearch..

CS/자료구조 2025.04.06

Chapter 4: Queue

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.QueueWhat is Queue?▶ Logical (or ADT) level Queue is an ordered group of homogeneous items (elements).New elements are added at one end (the rear) -- enqueue.Elements are removed from the other end (the front) -- dequeue. A queue is a FIFO "First In, First Out" structure. (선입선출)e.g., Job buffers, Network buffers, and many others (일을 순서대로 처리해야 되는 모든 상황) ※ buf..

CS/자료구조 2025.03.31

Chapter 3: Stack

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.StackWhat is Stack?▶ Logical (or ADT) level Stack is a group of homogeneous items (elements).Removal (pop) and addition (push) of stack items can only occur at the top of the stack. A stack is a LIFO "Last In, First Out" structure.e.g., Undo(무효로 하다, Ctrl + z), Back (browser 뒤로가기), Stack trace ※ stack trace: 프로그램에서 에러가 발생했을 때, 문제를 추적할 수 있도록 함수 호출 순서를 보여주는 로그이..

CS/자료구조 2025.03.28

Programming Exercise: Lab #1

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Encoding errors▶ 운영체제별로 줄 바꿈 문자를 채택한 게 다르다.CR (Carriage Return, \r): 커서가 해당 라인의 젤 앞쪽으로 이동 e.g., Mac OS (클래식 버전)LF (Line Feed, \n): 커서는 그대로 있으면서 줄만 바꿈 e.g., Unix, Linux, Mac OS (현대 버전)CRLF (CR + LF, ENTER): 줄도 바꾸면서 커서도 제일 앞쪽으로 이동 e.g, Windows간혹 협업을 하다 보면 어떤 사람이 Mac OS에서 작업한 코드를 Windows에서 받아 실행 시키려고 하면 에러가 나는 경우가 있다.따라서, Mac에서 작성된 파일을 Windows에서 사용할 경우, “LF” or..

CS/자료구조 2025.03.25

Chapter 2: Unsorted/Sorted Lists

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.List DefinitionsLinear relationship:Each element except the first has a unique predecessor(전임자), and each element except the last has a unique successor(후임자).Length:The number of items in a list; the length can vary over time. (e.g., append, remove)Unsorted list vs Sorted list ※ 배열(Array) vs 리스트(List)C 같은 언어에서 사용하는 배열(Array)은 크기가 고정되어 있어서 한 번 선언하면 크기를 바꿀 수 없..

CS/자료구조 2025.03.23

Chapter 1: Software, Data Structure, and C++

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.What is abstraction?▶ Too abstract.▶ Too concrete(명확한).▶ Between too abstract and too concrete.AbstractionA model of a complex system that includes only the details essential to the perspective of the viewer of the system. Programs are abstractions.Tells what the program mus do, but not how the program does it.Abstraction Data Type (ADT)▶ ADT A data type who..

CS/자료구조 2025.03.22