SlideShare a Scribd company logo
[자료구조] 쏭치
스터디에 앞서 과제가 좀 많습니다 +_+ 근데…쉽잖아요??? 아직은 몸풀기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++]; }

More Related Content

Viewers also liked

Inseptra company product solutions v2 1
Inseptra company product solutions v2 1Inseptra company product solutions v2 1
Inseptra company product solutions v2 1
Mustafa Kuğu
 
RailsClub Meetup #2 React On Rails
RailsClub Meetup #2 React On RailsRailsClub Meetup #2 React On Rails
RailsClub Meetup #2 React On Rails
Zakhar Day
 
2012 ranking 2 trim
2012 ranking 2 trim2012 ranking 2 trim
2012 ranking 2 trim
Daniel Francisco Doffo
 
Taco flash profile
Taco flash profileTaco flash profile
Taco flash profile
Erdian Tomy
 
Article Review
Article ReviewArticle Review
Article Review
Nurnabihah Mohamad Nizar
 
Cooking language
Cooking languageCooking language
Cooking language
dursitarosales
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
Embedding the ecosystem approach in policy: Problems and Potential
Embedding the ecosystem approach in policy: Problems and Potential Embedding the ecosystem approach in policy: Problems and Potential
Embedding the ecosystem approach in policy: Problems and Potential
ruralfringe
 
6 degrees of progress
6 degrees of progress 6 degrees of progress
6 degrees of progress
DeCarlos Love
 
Ila presentation final
Ila presentation finalIla presentation final
Ila presentation final
Katy Hite
 
Spark the Rise 2: How to Vote
Spark the Rise 2: How to VoteSpark the Rise 2: How to Vote
Spark the Rise 2: How to Vote
Mahindra Rise
 
Unit 1,2 essence of ecos
Unit 1,2 essence of ecosUnit 1,2 essence of ecos
Unit 1,2 essence of ecos
Prabha Panth
 
Asynchronous Task Queues with Celery
Asynchronous Task Queues with CeleryAsynchronous Task Queues with Celery
Asynchronous Task Queues with Celery
Kishor Kumar
 
Spain
SpainSpain
Spain
ceipsrc3
 
Phonegap
PhonegapPhonegap
Phonegap
Lucas Brigida
 
萌え要素の効果について分析してみた@第8回ニコニコ学会βシンポジウム
萌え要素の効果について分析してみた@第8回ニコニコ学会βシンポジウム萌え要素の効果について分析してみた@第8回ニコニコ学会βシンポジウム
萌え要素の効果について分析してみた@第8回ニコニコ学会βシンポジウム
Masanori Takano
 
Octubre[1]
Octubre[1]Octubre[1]
Octubre[1]
Anny pe?
 
France
FranceFrance
France
ceipsrc3
 
Eta introdution
Eta introdutionEta introdution
Eta introdution
Lee Joe
 

Viewers also liked (19)

Inseptra company product solutions v2 1
Inseptra company product solutions v2 1Inseptra company product solutions v2 1
Inseptra company product solutions v2 1
 
RailsClub Meetup #2 React On Rails
RailsClub Meetup #2 React On RailsRailsClub Meetup #2 React On Rails
RailsClub Meetup #2 React On Rails
 
2012 ranking 2 trim
2012 ranking 2 trim2012 ranking 2 trim
2012 ranking 2 trim
 
Taco flash profile
Taco flash profileTaco flash profile
Taco flash profile
 
Article Review
Article ReviewArticle Review
Article Review
 
Cooking language
Cooking languageCooking language
Cooking language
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Embedding the ecosystem approach in policy: Problems and Potential
Embedding the ecosystem approach in policy: Problems and Potential Embedding the ecosystem approach in policy: Problems and Potential
Embedding the ecosystem approach in policy: Problems and Potential
 
6 degrees of progress
6 degrees of progress 6 degrees of progress
6 degrees of progress
 
Ila presentation final
Ila presentation finalIla presentation final
Ila presentation final
 
Spark the Rise 2: How to Vote
Spark the Rise 2: How to VoteSpark the Rise 2: How to Vote
Spark the Rise 2: How to Vote
 
Unit 1,2 essence of ecos
Unit 1,2 essence of ecosUnit 1,2 essence of ecos
Unit 1,2 essence of ecos
 
Asynchronous Task Queues with Celery
Asynchronous Task Queues with CeleryAsynchronous Task Queues with Celery
Asynchronous Task Queues with Celery
 
Spain
SpainSpain
Spain
 
Phonegap
PhonegapPhonegap
Phonegap
 
萌え要素の効果について分析してみた@第8回ニコニコ学会βシンポジウム
萌え要素の効果について分析してみた@第8回ニコニコ学会βシンポジウム萌え要素の効果について分析してみた@第8回ニコニコ学会βシンポジウム
萌え要素の効果について分析してみた@第8回ニコニコ学会βシンポジウム
 
Octubre[1]
Octubre[1]Octubre[1]
Octubre[1]
 
France
FranceFrance
France
 
Eta introdution
Eta introdutionEta introdution
Eta introdution
 

More from SongChiWon

제발 이런 실수는 이제 그만
제발 이런 실수는 이제 그만제발 이런 실수는 이제 그만
제발 이런 실수는 이제 그만SongChiWon
 

More from SongChiWon (8)

Study3
Study3Study3
Study3
 
Study3
Study3Study3
Study3
 
Study1
Study1Study1
Study1
 
Study2
Study2Study2
Study2
 
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++]; }