SlideShare una empresa de Scribd logo
1 de 11
[자료구조] 쏭치
스터디에 앞서 과제가 좀 많습니다 +_+ 근데…쉽잖아요??? 아직은 몸풀기C문제 수준이니깐  금방 풀 수 있을 거예요…. 스터디했던건 각자 알아서 꼭 구현!! 스터디에서 하는 건 강의를 잘 따라 갈 수 있는 개념 탑재 일뿐 전체가 아님!!
오늘의 Topic Stack Queue
Stack 과 Queue 공통사항 그냥 “개념”일 뿐이다 따라서 구현은 알아서 하면 된다. 보통 Linked List, 배열로 구현 스터디에선 배열로만 구현  Overflow와 Underflow가 존재한다. Overflow : 넣을 공간이 없는데 넣을 시 Underflow : 뺄 자료가 없는데 뺄 시
Stack LIFO(Last In First Out, 후입선출)이 Stack 마지막에 들어갔던 자료가 먼저 나옴 데이터의 위치를 가르치는 top
일반적인 Stack의 함수 Push() // Stack에 Data를 넣음 Pop() // Stack에서 Data를 빼냄 Empty() // Stack이 비었나 확인 Full() // Stack이 꽉 찼나 확나
함수 구현은 이렇게… int stack[MAX], top=0; int Empty(){ return top==0; } int Full(){ return MAX==top; } void Push(int item){ if(!Full()) stack[top++]=item; } int Pop(){ if(!Empty()) return stack[--top]; }
Quiz… Data 1 2 3 4 가 주어지고 Stack이 주어질때 다음은 어떤 연산을 거쳐야 나오나요? 1 2 3 4 PushPopPushPop PushPop PushPop 1 3 2 4 1 4 3 2 4 3 2 1 4 1 2 3
Queue FIFO(First In First Out, 선입선출)이 Queue 선형 큐와 원형 큐가 존재 스터디에서는 선형 큐만  Data가 들어갈 위치를 가르키는 rear 뺄 Data의 위치를 가리키는 front
일반적인 Queue의 함수 Push() // Queue에 Data를 넣음 Pop() // Queue에서 Data를 빼냄 Empty() // Queue이 비었나 확인 Full() // Queue이 꽉 찼나 확나
함수 구현은 이렇게… int queue[MAX], front=0, rear=0; int Empty(){ return front==rear; } int Full(){ return MAX==rear; } void Push(int item){ if(!Full()) queue[rear++]=item; } int Pop(){ if(!Empty()) return queue[front++]; }

Más contenido relacionado

Destacado

Javascripでオブジェクト指向
Javascripでオブジェクト指向Javascripでオブジェクト指向
Javascripでオブジェクト指向1000 VICKY
 
Michelle the little girl and boy book
Michelle the little girl and boy bookMichelle the little girl and boy book
Michelle the little girl and boy bookbowenslide
 
STR2 Winners Round 3
STR2 Winners Round 3STR2 Winners Round 3
STR2 Winners Round 3Mahindra Rise
 
3落實兩岸經濟貿易協議
3落實兩岸經濟貿易協議3落實兩岸經濟貿易協議
3落實兩岸經濟貿易協議twnewone1
 
The peak inside how to
The peak inside how toThe peak inside how to
The peak inside how togrgibson
 
Environmental Planning consultation
Environmental Planning consultation Environmental Planning consultation
Environmental Planning consultation ruralfringe
 
Jon Holland CIM Spring Marketing Conference 2015
Jon Holland   CIM Spring Marketing Conference 2015Jon Holland   CIM Spring Marketing Conference 2015
Jon Holland CIM Spring Marketing Conference 2015CIM East of England
 
Homage to sri aurobindo, part 4
Homage to sri aurobindo, part 4Homage to sri aurobindo, part 4
Homage to sri aurobindo, part 4Jitendra Sharma
 
Neil Garner CIM Spring Marketing Conference 2015
Neil Garner   CIM Spring Marketing Conference 2015Neil Garner   CIM Spring Marketing Conference 2015
Neil Garner CIM Spring Marketing Conference 2015CIM East of England
 
Inseptra company product solutions v2 1
Inseptra company product solutions v2 1Inseptra company product solutions v2 1
Inseptra company product solutions v2 1Mustafa Kuğu
 
Wealthbuilder.ie introduction
Wealthbuilder.ie introductionWealthbuilder.ie introduction
Wealthbuilder.ie introductionWealthbuilder.ie
 

Destacado (18)

Lab8 ubuntu terminal
Lab8 ubuntu terminalLab8 ubuntu terminal
Lab8 ubuntu terminal
 
Sandra
SandraSandra
Sandra
 
Javascripでオブジェクト指向
Javascripでオブジェクト指向Javascripでオブジェクト指向
Javascripでオブジェクト指向
 
Cumple blanka
Cumple blankaCumple blanka
Cumple blanka
 
Michelle the little girl and boy book
Michelle the little girl and boy bookMichelle the little girl and boy book
Michelle the little girl and boy book
 
STR2 Winners Round 3
STR2 Winners Round 3STR2 Winners Round 3
STR2 Winners Round 3
 
Welcome Book
Welcome BookWelcome Book
Welcome Book
 
Names of alah
Names of alahNames of alah
Names of alah
 
3落實兩岸經濟貿易協議
3落實兩岸經濟貿易協議3落實兩岸經濟貿易協議
3落實兩岸經濟貿易協議
 
The peak inside how to
The peak inside how toThe peak inside how to
The peak inside how to
 
Environmental Planning consultation
Environmental Planning consultation Environmental Planning consultation
Environmental Planning consultation
 
Jon Holland CIM Spring Marketing Conference 2015
Jon Holland   CIM Spring Marketing Conference 2015Jon Holland   CIM Spring Marketing Conference 2015
Jon Holland CIM Spring Marketing Conference 2015
 
4 wimax
4 wimax4 wimax
4 wimax
 
Intro les 1&2
Intro les 1&2Intro les 1&2
Intro les 1&2
 
Homage to sri aurobindo, part 4
Homage to sri aurobindo, part 4Homage to sri aurobindo, part 4
Homage to sri aurobindo, part 4
 
Neil Garner CIM Spring Marketing Conference 2015
Neil Garner   CIM Spring Marketing Conference 2015Neil Garner   CIM Spring Marketing Conference 2015
Neil Garner CIM Spring Marketing Conference 2015
 
Inseptra company product solutions v2 1
Inseptra company product solutions v2 1Inseptra company product solutions v2 1
Inseptra company product solutions v2 1
 
Wealthbuilder.ie introduction
Wealthbuilder.ie introductionWealthbuilder.ie introduction
Wealthbuilder.ie introduction
 

Más de SongChiWon

Más de SongChiWon (8)

Study3
Study3Study3
Study3
 
Study3
Study3Study3
Study3
 
Study2
Study2Study2
Study2
 
Study1
Study1Study1
Study1
 
Study1
Study1Study1
Study1
 
Study3
Study3Study3
Study3
 
제발 이런 실수는 이제 그만
제발 이런 실수는 이제 그만제발 이런 실수는 이제 그만
제발 이런 실수는 이제 그만
 
Stack
StackStack
Stack
 

Study2

  • 2. 스터디에 앞서 과제가 좀 많습니다 +_+ 근데…쉽잖아요??? 아직은 몸풀기C문제 수준이니깐  금방 풀 수 있을 거예요…. 스터디했던건 각자 알아서 꼭 구현!! 스터디에서 하는 건 강의를 잘 따라 갈 수 있는 개념 탑재 일뿐 전체가 아님!!
  • 4. Stack 과 Queue 공통사항 그냥 “개념”일 뿐이다 따라서 구현은 알아서 하면 된다. 보통 Linked List, 배열로 구현 스터디에선 배열로만 구현  Overflow와 Underflow가 존재한다. Overflow : 넣을 공간이 없는데 넣을 시 Underflow : 뺄 자료가 없는데 뺄 시
  • 5. Stack LIFO(Last In First Out, 후입선출)이 Stack 마지막에 들어갔던 자료가 먼저 나옴 데이터의 위치를 가르치는 top
  • 6. 일반적인 Stack의 함수 Push() // Stack에 Data를 넣음 Pop() // Stack에서 Data를 빼냄 Empty() // Stack이 비었나 확인 Full() // Stack이 꽉 찼나 확나
  • 7. 함수 구현은 이렇게… int stack[MAX], top=0; int Empty(){ return top==0; } int Full(){ return MAX==top; } void Push(int item){ if(!Full()) stack[top++]=item; } int Pop(){ if(!Empty()) return stack[--top]; }
  • 8. Quiz… Data 1 2 3 4 가 주어지고 Stack이 주어질때 다음은 어떤 연산을 거쳐야 나오나요? 1 2 3 4 PushPopPushPop PushPop PushPop 1 3 2 4 1 4 3 2 4 3 2 1 4 1 2 3
  • 9. Queue FIFO(First In First Out, 선입선출)이 Queue 선형 큐와 원형 큐가 존재 스터디에서는 선형 큐만  Data가 들어갈 위치를 가르키는 rear 뺄 Data의 위치를 가리키는 front
  • 10. 일반적인 Queue의 함수 Push() // Queue에 Data를 넣음 Pop() // Queue에서 Data를 빼냄 Empty() // Queue이 비었나 확인 Full() // Queue이 꽉 찼나 확나
  • 11. 함수 구현은 이렇게… int queue[MAX], front=0, rear=0; int Empty(){ return front==rear; } int Full(){ return MAX==rear; } void Push(int item){ if(!Full()) queue[rear++]=item; } int Pop(){ if(!Empty()) return queue[front++]; }