2025/04 6

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 (1)

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.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

XSS game

경희대학교 중앙동아리 쿠러그의 정보보안 강의를 기반으로 정리한 글입니다.XSS gameXSS game은 XSS 공격을 통해 다음과 같이 alert()를 띄우는 게임이다.Level 1: Hello, world of XSS해당 창에 "hi"라고 입력하면,다음과 같이 "hi"가 그대로 뜨는 것을 확인할 수 있다. 주어진 Target code에서 해당 페이지를 보여주는 부분을 찾아보면,message = "Sorry, no results were found for " + query + "." 해당 코드를 찾을 수 있다.이 코드를 보면 입력한 대로 query로 들어간다. 때문에, 아래와 같이 입력을 넣어주면 alert()를 띄울 수 있다. Level 2: Persistence is keyLevel 1을 풀었던 방식..