SlideShare a Scribd company logo
1 of 50
3 장 ADTs Stack and Queue
What is a Stack? ,[object Object],[object Object],[object Object],[object Object]
스택 추상 데이타 타입 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
스택 추상 데이타 타입 ,[object Object]
Stack ADT Operations (ADT  연산 ) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ADT Stack Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Interface  및  Stack 의 배열 구현 StackType class StackType Pop Push IsFull IsEmpty Private data: top [maxStack] . . . [ 2 ] [ 1 ] items  [ 0 ] MakeEmpty
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Stack   구현 void StackType::Push(ItemType newItem) //  삽입 { if( IsFull() ) {   cout << “Stack is full ”; //  예외처리 return; } top++; items[top] = newItem; } void StackType::Pop(ItemType item)  //  삭제 {  if( IsEmpty() ) {   cout << “Stack is empty ”; // 예외처리  return; } item = items[top]; top--; }
Tracing Client Code char letter = ‘V’; StackType  charStack; charStack.Push(letter); charStack.Push(‘C’); charStack.Push(‘S’); if ( !charStack.IsEmpty( )) charStack.Pop( ); charStack.Push(‘K’); while (!charStack.IsEmpty( )) { letter = charStack.Top(); charStack.Pop(0)} Private data: top [ MAX_ITEMS-1 ] . . . [ 2 ] [ 1 ] items  [ 0 ] letter ‘ V’
What is a Generic Data Type? ,[object Object],[object Object]
What is a Class Template? ,[object Object],[object Object],[object Object],[object Object],[object Object]
StackType<int> numStack; ACTUAL PARAMETER top   3 [MAX_ITEMS-1] . . .   [ 3 ]  789   [ 2 ]    -56   [ 1 ]    132 items  [ 0 ]    5670
StackType<float> numStack; ACTUAL PARAMETER top   3 [MAX_ITEMS-1] . . .   [ 3 ]  3456.8   [ 2 ]    -90.98   [ 1 ]    98.6 items  [ 0 ]    167.87
StackType<StrType> numStack; ACTUAL PARAMETER top   3 [MAX_ITEMS-1] . . .   [ 3 ]  Bradley   [ 2 ]    Asad   [ 1 ]    Rodrigo items  [ 0 ]    Max
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using class templates ,[object Object],[object Object],[object Object],[object Object],[object Object]
What is a pointer variable? ,[object Object],[object Object],[object Object],[object Object],[object Object]
Using a pointer variable ,[object Object],[object Object],[object Object],[object Object],[object Object],2000 12 x 3000 2000 ptr
C++  Data Types Structured array  struct  union  class Simple Integral Floating char  short  int  long  enum float  double  long double Address pointer  reference
The  NULL Pointer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Allocation of memory ( 메모리 할당 ) STATIC ALLOCATION ( 정적할당 ) Static allocation is the allocation of memory space at compile time. ( 컴파일시 메모리 공간을 할당 ) DYNAMIC ALLOCATION ( 동적 할당 ) Dynamic allocation is the allocation of memory space at run time by using operator new. ( 실행시  new  연산자를 사용하여 메모리 공간을 할당 )
3 Kinds of Program Data ,[object Object],[object Object],[object Object],[object Object]
Using operator new ,[object Object],[object Object],[object Object],[object Object]
Dynamically Allocated Data ,[object Object],[object Object],[object Object],[object Object],2000 ptr
[object Object],[object Object],[object Object],Using operator delete
Some C++ pointer operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dynamic Array Allocation   char  *ptr;   // ptr is a pointer variable that //  can hold the address of a char ptr  =  new  char[ 5 ];   // dynamically, during run time, allocates // memory for 5 characters and places into    // the contents of ptr their beginning address ptr 6000 6000
Dynamic Array Allocation   char  *ptr ; ptr  =  new  char[ 5 ];   strcpy( ptr, “Bye” ); ptr[ 1 ] = ‘u’;   // a pointer can be subscripted cout  << ptr[ 2] ;   ptr 6000 6000 ‘ B’  ‘y’  ‘e’  ‘’  ‘ u’
Dynamic Array Deallocation   char  *ptr ; ptr  =  new  char[ 5 ];   strcpy( ptr, “Bye” ); ptr[ 1 ] = ‘u’; delete  ptr;   // deallocates array pointed to by ptr // ptr itself is not deallocated, but // the value of ptr is considered unassigned   ptr ?
[object Object],[object Object],[object Object],[object Object],What happens here? 3 ptr 3 ptr   4
Memory Leak ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],8 ptr -5 ptr2
Causing a Memory Leak ,[object Object],[object Object],[object Object],[object Object],[object Object],8 ptr -5 ptr2 8 ptr -5 ptr2
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],A Dangling Pointer 8 ptr -5 ptr2 FOR EXAMPLE,
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Leaving a Dangling Pointer 8 ptr NULL  ptr2 8 ptr -5 ptr2
DYNAMIC ARRAY IMPLEMENTATION StackType ~StackType Push Pop . . . class StackType Private Data: top   2 maxStack  5 items 50  43 80 items [0] items [1] items [2] items [3] items [4]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
스택의 응용 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
함수 호출과  return 의 구현 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
함수 호출과  return 의 구현 ,[object Object],함수 호출 뒤의 시스템 스택
수식의 표현방법 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Postfix  수식의 계산 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Infix  수식의  Postfix  수식변환 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Infix  수식의  Postfix  수식변환 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
예 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],* ( * * ( + *
예 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],-

More Related Content

What's hot

Matplotlib 기초 이해하기_20160730
Matplotlib 기초 이해하기_20160730Matplotlib 기초 이해하기_20160730
Matplotlib 기초 이해하기_20160730Yong Joon Moon
 
파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409Yong Joon Moon
 
파이썬+함수 데코레이터+이해하기 20160229
파이썬+함수 데코레이터+이해하기 20160229파이썬+함수 데코레이터+이해하기 20160229
파이썬+함수 데코레이터+이해하기 20160229Yong Joon Moon
 
Swift3 subscript inheritance initialization
Swift3 subscript inheritance initializationSwift3 subscript inheritance initialization
Swift3 subscript inheritance initializationEunjoo Im
 
Swift3 generic
Swift3 genericSwift3 generic
Swift3 genericEunjoo Im
 
Swift3 typecasting nested_type
Swift3 typecasting nested_typeSwift3 typecasting nested_type
Swift3 typecasting nested_typeEunjoo Im
 
Javascript introduction, dynamic data type, operator
Javascript introduction, dynamic data type, operatorJavascript introduction, dynamic data type, operator
Javascript introduction, dynamic data type, operatorYoung-Beom Rhee
 
나에 첫번째 자바8 람다식 지앤선
나에 첫번째 자바8 람다식   지앤선나에 첫번째 자바8 람다식   지앤선
나에 첫번째 자바8 람다식 지앤선daewon jeong
 
Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석용 최
 
Python Programming: Function
Python Programming: FunctionPython Programming: Function
Python Programming: FunctionChan Shik Lim
 
파이썬정리 20160130
파이썬정리 20160130파이썬정리 20160130
파이썬정리 20160130Yong Joon Moon
 
파이썬 기본 문법
파이썬 기본 문법파이썬 기본 문법
파이썬 기본 문법SeongHyun Ahn
 
[devil's camp] - 알고리즘 대회와 STL (박인서)
[devil's camp] - 알고리즘 대회와 STL (박인서)[devil's camp] - 알고리즘 대회와 STL (박인서)
[devil's camp] - 알고리즘 대회와 STL (박인서)NAVER D2
 
파이썬+객체지향+이해하기 20160131
파이썬+객체지향+이해하기 20160131파이썬+객체지향+이해하기 20160131
파이썬+객체지향+이해하기 20160131Yong Joon Moon
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Circulus
 
Javascript 함수(function) 개념, 호출패턴, this, prototype, scope
Javascript 함수(function) 개념, 호출패턴, this, prototype, scopeJavascript 함수(function) 개념, 호출패턴, this, prototype, scope
Javascript 함수(function) 개념, 호출패턴, this, prototype, scopeYoung-Beom Rhee
 
파이썬 플라스크 이해하기
파이썬 플라스크 이해하기 파이썬 플라스크 이해하기
파이썬 플라스크 이해하기 Yong Joon Moon
 
포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++KWANGIL KIM
 
Javascript 교육자료 pdf
Javascript 교육자료 pdfJavascript 교육자료 pdf
Javascript 교육자료 pdfHyosang Hong
 
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)Circulus
 

What's hot (20)

Matplotlib 기초 이해하기_20160730
Matplotlib 기초 이해하기_20160730Matplotlib 기초 이해하기_20160730
Matplotlib 기초 이해하기_20160730
 
파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409
 
파이썬+함수 데코레이터+이해하기 20160229
파이썬+함수 데코레이터+이해하기 20160229파이썬+함수 데코레이터+이해하기 20160229
파이썬+함수 데코레이터+이해하기 20160229
 
Swift3 subscript inheritance initialization
Swift3 subscript inheritance initializationSwift3 subscript inheritance initialization
Swift3 subscript inheritance initialization
 
Swift3 generic
Swift3 genericSwift3 generic
Swift3 generic
 
Swift3 typecasting nested_type
Swift3 typecasting nested_typeSwift3 typecasting nested_type
Swift3 typecasting nested_type
 
Javascript introduction, dynamic data type, operator
Javascript introduction, dynamic data type, operatorJavascript introduction, dynamic data type, operator
Javascript introduction, dynamic data type, operator
 
나에 첫번째 자바8 람다식 지앤선
나에 첫번째 자바8 람다식   지앤선나에 첫번째 자바8 람다식   지앤선
나에 첫번째 자바8 람다식 지앤선
 
Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석
 
Python Programming: Function
Python Programming: FunctionPython Programming: Function
Python Programming: Function
 
파이썬정리 20160130
파이썬정리 20160130파이썬정리 20160130
파이썬정리 20160130
 
파이썬 기본 문법
파이썬 기본 문법파이썬 기본 문법
파이썬 기본 문법
 
[devil's camp] - 알고리즘 대회와 STL (박인서)
[devil's camp] - 알고리즘 대회와 STL (박인서)[devil's camp] - 알고리즘 대회와 STL (박인서)
[devil's camp] - 알고리즘 대회와 STL (박인서)
 
파이썬+객체지향+이해하기 20160131
파이썬+객체지향+이해하기 20160131파이썬+객체지향+이해하기 20160131
파이썬+객체지향+이해하기 20160131
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체
 
Javascript 함수(function) 개념, 호출패턴, this, prototype, scope
Javascript 함수(function) 개념, 호출패턴, this, prototype, scopeJavascript 함수(function) 개념, 호출패턴, this, prototype, scope
Javascript 함수(function) 개념, 호출패턴, this, prototype, scope
 
파이썬 플라스크 이해하기
파이썬 플라스크 이해하기 파이썬 플라스크 이해하기
파이썬 플라스크 이해하기
 
포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++
 
Javascript 교육자료 pdf
Javascript 교육자료 pdfJavascript 교육자료 pdf
Javascript 교육자료 pdf
 
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
 

Viewers also liked

05. timer.counter.pwm
05. timer.counter.pwm05. timer.counter.pwm
05. timer.counter.pwm성호 정
 
Myth essay
Myth essayMyth essay
Myth essaydomm7
 
Казанский юридический центр
Казанский юридический центрКазанский юридический центр
Казанский юридический центрkaanow
 
Storyboard haastattelu 1
Storyboard haastattelu 1Storyboard haastattelu 1
Storyboard haastattelu 1Marjo Jussila
 
2012 Al's Day
2012 Al's Day2012 Al's Day
2012 Al's DayGolin
 
デザインスプリント試行してみて
デザインスプリント試行してみてデザインスプリント試行してみて
デザインスプリント試行してみてShosaku Suzuki
 
How mobile marketing can bring you more business
How mobile marketing can bring you more businessHow mobile marketing can bring you more business
How mobile marketing can bring you more businesssuccessenter
 
Property june july_13_final
Property june july_13_finalProperty june july_13_final
Property june july_13_finalruralfringe
 
Catálogo Cerruti
Catálogo CerrutiCatálogo Cerruti
Catálogo CerrutiCoartegift
 
Distance learning presentation_hite
Distance learning presentation_hiteDistance learning presentation_hite
Distance learning presentation_hiteKaty Hite
 
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRII OPERELOR DE ARTĂ MONUMENTALE ...
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRIIOPERELOR DE ARTĂ MONUMENTALE ...INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRIIOPERELOR DE ARTĂ MONUMENTALE ...
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRII OPERELOR DE ARTĂ MONUMENTALE ...Alexandru Vlad Murzac
 
Social Media Warren Knight Digital Bootcamp April 2012
Social Media Warren Knight Digital Bootcamp April 2012Social Media Warren Knight Digital Bootcamp April 2012
Social Media Warren Knight Digital Bootcamp April 2012CIM East of England
 
APBDRF Scientific Advisory Board Meeting December 2013: Research Update
APBDRF Scientific Advisory Board Meeting December 2013: Research UpdateAPBDRF Scientific Advisory Board Meeting December 2013: Research Update
APBDRF Scientific Advisory Board Meeting December 2013: Research UpdateBen Decker
 
Crm success with offshore outsourcing
Crm success with offshore outsourcingCrm success with offshore outsourcing
Crm success with offshore outsourcingCRM Vision
 

Viewers also liked (20)

05. timer.counter.pwm
05. timer.counter.pwm05. timer.counter.pwm
05. timer.counter.pwm
 
Myth essay
Myth essayMyth essay
Myth essay
 
Antalya
AntalyaAntalya
Antalya
 
Казанский юридический центр
Казанский юридический центрКазанский юридический центр
Казанский юридический центр
 
Each other myself ni1
Each other myself ni1Each other myself ni1
Each other myself ni1
 
Fiskalitatea gasteiz
Fiskalitatea gasteizFiskalitatea gasteiz
Fiskalitatea gasteiz
 
Storyboard haastattelu 1
Storyboard haastattelu 1Storyboard haastattelu 1
Storyboard haastattelu 1
 
2012 ranking 2 trim
2012 ranking 2 trim2012 ranking 2 trim
2012 ranking 2 trim
 
2012 Al's Day
2012 Al's Day2012 Al's Day
2012 Al's Day
 
デザインスプリント試行してみて
デザインスプリント試行してみてデザインスプリント試行してみて
デザインスプリント試行してみて
 
How mobile marketing can bring you more business
How mobile marketing can bring you more businessHow mobile marketing can bring you more business
How mobile marketing can bring you more business
 
Property june july_13_final
Property june july_13_finalProperty june july_13_final
Property june july_13_final
 
Payment of wages act
Payment of wages actPayment of wages act
Payment of wages act
 
Sage Software Deals In Quarter 3
Sage Software Deals In Quarter 3Sage Software Deals In Quarter 3
Sage Software Deals In Quarter 3
 
Catálogo Cerruti
Catálogo CerrutiCatálogo Cerruti
Catálogo Cerruti
 
Distance learning presentation_hite
Distance learning presentation_hiteDistance learning presentation_hite
Distance learning presentation_hite
 
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRII OPERELOR DE ARTĂ MONUMENTALE ...
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRIIOPERELOR DE ARTĂ MONUMENTALE ...INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRIIOPERELOR DE ARTĂ MONUMENTALE ...
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRII OPERELOR DE ARTĂ MONUMENTALE ...
 
Social Media Warren Knight Digital Bootcamp April 2012
Social Media Warren Knight Digital Bootcamp April 2012Social Media Warren Knight Digital Bootcamp April 2012
Social Media Warren Knight Digital Bootcamp April 2012
 
APBDRF Scientific Advisory Board Meeting December 2013: Research Update
APBDRF Scientific Advisory Board Meeting December 2013: Research UpdateAPBDRF Scientific Advisory Board Meeting December 2013: Research Update
APBDRF Scientific Advisory Board Meeting December 2013: Research Update
 
Crm success with offshore outsourcing
Crm success with offshore outsourcingCrm success with offshore outsourcing
Crm success with offshore outsourcing
 

Similar to 강의자료4

Boost라이브러리의내부구조 20151111 서진택
Boost라이브러리의내부구조 20151111 서진택Boost라이브러리의내부구조 20151111 서진택
Boost라이브러리의내부구조 20151111 서진택JinTaek Seo
 
C++ Advanced 강의 2주차
C++ Advanced 강의 2주차C++ Advanced 강의 2주차
C++ Advanced 강의 2주차HyunJoon Park
 
Ai C#세미나
Ai C#세미나Ai C#세미나
Ai C#세미나Astin Choi
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산S.O.P.T - Shout Our Passion Together
 
SpringCamp 2013 : About Jdk8
SpringCamp 2013 : About Jdk8SpringCamp 2013 : About Jdk8
SpringCamp 2013 : About Jdk8Sangmin Lee
 
읽기 좋은 코드가 좋은 코드다 Part one
읽기 좋은 코드가 좋은 코드다   Part one읽기 좋은 코드가 좋은 코드다   Part one
읽기 좋은 코드가 좋은 코드다 Part oneJi Hun Kim
 
Java advancd ed10
Java advancd ed10Java advancd ed10
Java advancd ed10hungrok
 
[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기Sang Heon Lee
 
2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdfkd19h
 
More effective c++ chapter1,2
More effective c++ chapter1,2More effective c++ chapter1,2
More effective c++ chapter1,2문익 장
 
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 명신 김
 
C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부Gwangwhi Mah
 
Collection framework
Collection frameworkCollection framework
Collection frameworkssuser34b989
 
2012 Ds D2 03
2012 Ds D2 032012 Ds D2 03
2012 Ds D2 03chl132435
 

Similar to 강의자료4 (20)

강의자료3
강의자료3강의자료3
강의자료3
 
STL study (skyLab)
STL study (skyLab)STL study (skyLab)
STL study (skyLab)
 
Boost라이브러리의내부구조 20151111 서진택
Boost라이브러리의내부구조 20151111 서진택Boost라이브러리의내부구조 20151111 서진택
Boost라이브러리의내부구조 20151111 서진택
 
4. stack
4. stack4. stack
4. stack
 
C++ Advanced 강의 2주차
C++ Advanced 강의 2주차C++ Advanced 강의 2주차
C++ Advanced 강의 2주차
 
Ai C#세미나
Ai C#세미나Ai C#세미나
Ai C#세미나
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
[SOPT] 데이터 구조 및 알고리즘 스터디 - #02 : 스택, 큐, 수식 연산
 
SpringCamp 2013 : About Jdk8
SpringCamp 2013 : About Jdk8SpringCamp 2013 : About Jdk8
SpringCamp 2013 : About Jdk8
 
읽기 좋은 코드가 좋은 코드다 Part one
읽기 좋은 코드가 좋은 코드다   Part one읽기 좋은 코드가 좋은 코드다   Part one
읽기 좋은 코드가 좋은 코드다 Part one
 
Java advancd ed10
Java advancd ed10Java advancd ed10
Java advancd ed10
 
[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기
 
2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf2012 Ds D2 03 Pdf
2012 Ds D2 03 Pdf
 
More effective c++ chapter1,2
More effective c++ chapter1,2More effective c++ chapter1,2
More effective c++ chapter1,2
 
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14
 
C review
C  reviewC  review
C review
 
C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부
 
Collection framework
Collection frameworkCollection framework
Collection framework
 
2012 Ds D2 03
2012 Ds D2 032012 Ds D2 03
2012 Ds D2 03
 
강의자료5
강의자료5강의자료5
강의자료5
 
강의자료 2
강의자료 2강의자료 2
강의자료 2
 

강의자료4

  • 1. 3 장 ADTs Stack and Queue
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. Class Interface 및 Stack 의 배열 구현 StackType class StackType Pop Push IsFull IsEmpty Private data: top [maxStack] . . . [ 2 ] [ 1 ] items [ 0 ] MakeEmpty
  • 10.
  • 11. Tracing Client Code char letter = ‘V’; StackType charStack; charStack.Push(letter); charStack.Push(‘C’); charStack.Push(‘S’); if ( !charStack.IsEmpty( )) charStack.Pop( ); charStack.Push(‘K’); while (!charStack.IsEmpty( )) { letter = charStack.Top(); charStack.Pop(0)} Private data: top [ MAX_ITEMS-1 ] . . . [ 2 ] [ 1 ] items [ 0 ] letter ‘ V’
  • 12.
  • 13.
  • 14. StackType<int> numStack; ACTUAL PARAMETER top 3 [MAX_ITEMS-1] . . . [ 3 ] 789 [ 2 ] -56 [ 1 ] 132 items [ 0 ] 5670
  • 15. StackType<float> numStack; ACTUAL PARAMETER top 3 [MAX_ITEMS-1] . . . [ 3 ] 3456.8 [ 2 ] -90.98 [ 1 ] 98.6 items [ 0 ] 167.87
  • 16. StackType<StrType> numStack; ACTUAL PARAMETER top 3 [MAX_ITEMS-1] . . . [ 3 ] Bradley [ 2 ] Asad [ 1 ] Rodrigo items [ 0 ] Max
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22. C++ Data Types Structured array struct union class Simple Integral Floating char short int long enum float double long double Address pointer reference
  • 23.
  • 24. Allocation of memory ( 메모리 할당 ) STATIC ALLOCATION ( 정적할당 ) Static allocation is the allocation of memory space at compile time. ( 컴파일시 메모리 공간을 할당 ) DYNAMIC ALLOCATION ( 동적 할당 ) Dynamic allocation is the allocation of memory space at run time by using operator new. ( 실행시 new 연산자를 사용하여 메모리 공간을 할당 )
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30. Dynamic Array Allocation char *ptr; // ptr is a pointer variable that // can hold the address of a char ptr = new char[ 5 ]; // dynamically, during run time, allocates // memory for 5 characters and places into // the contents of ptr their beginning address ptr 6000 6000
  • 31. Dynamic Array Allocation char *ptr ; ptr = new char[ 5 ]; strcpy( ptr, “Bye” ); ptr[ 1 ] = ‘u’; // a pointer can be subscripted cout << ptr[ 2] ; ptr 6000 6000 ‘ B’ ‘y’ ‘e’ ‘’ ‘ u’
  • 32. Dynamic Array Deallocation char *ptr ; ptr = new char[ 5 ]; strcpy( ptr, “Bye” ); ptr[ 1 ] = ‘u’; delete ptr; // deallocates array pointed to by ptr // ptr itself is not deallocated, but // the value of ptr is considered unassigned ptr ?
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38. DYNAMIC ARRAY IMPLEMENTATION StackType ~StackType Push Pop . . . class StackType Private Data: top 2 maxStack 5 items 50 43 80 items [0] items [1] items [2] items [3] items [4]
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.