SlideShare a Scribd company logo
1 of 13
구현하기
(Linked List/Insertion sort)
amugona study 3회
전정완
2015-08-13
amugona2015
Programs = Data Structures + Algorithms
program이 올바르고 효율적으로 작성되기 위해서는
data structures와 algorithms이 정확하고 효율적이어야 한다.
Programming
2
amugona2015
목차
linked list 구현2
insertion sort
3
amugona2015
linked list
○ 구조체의 집합으로 표현되며, 그 member로 자기 자신과 똑같은 형의 pointer
를 가짐
○ pointer가 다음 element를 가리킴
○ memory의 물리적인 이동 없이 data의 추가, 삭제, 정렬이 가능하므로 많은
data를 취급 시 적합한 자료구조
○ 원하는 data 참조 시 처음부터 찾아야 함
○ 배열보다 data 호출에 시간이 더 많이 걸림
linked list 구현
4
e1 e2 e3 e4
amugona2015
linked list 구현
구현 내용
○ linked list에 데이터A를 저장하기
○ 리스트의 모든 데이터를 표시하기
○ 새로운 데이터를 제일 끝에 추가하기
○ 원하는 위치에 데이터를 삽입하기
○ 원하는 위치의 데이터를 삭제하기
○ 모든 데이터 삭제하기
구현 환경
○ C, Win32 console app, VS 2012
5
num word
1 accord
2 grant
3 bestow
4 concede
데이터A
list: 표시
add: 추가
insert: 삽입
delete: 삭제
clear: 모두 삭제
quit: 프로그램종료
command 입력
amugona2015
linked list 구현
commad 입력
6
데이터 리스트 출력
데이터 추가
데이터 삽입
데이터 삭제
데이터 모두 삭제
amugona2015
linked list 구현
연결리스트 작성
 linked list에 데이터A를 저장하기
7
• 연결리스트는
구조체의 집합
으로 표현된다
amugona2015
linked list 구현
리스트의 모든 데이터를 표시하기
8
// 다음 가리키는 요소가 없을 때 까지 요소들 출력
amugona2015
linked list 구현
새로운 데이터를 제일 끝에 추가하기
9
// malloc()으로 새 구조체에 대한 메모리 확보
// 마지막 요소의 주소를 얻음
// 마지막 요소의 주소를 얻음
e
1
e
2
n
n
null
amugona2015
linked list 구현
원하는 위치에 데이터를 삽입하기
10
// 새로운 요소의 next에 다음의 주소를 넣음
e
1
e
2
n
n p
e
3
amugona2015
linked list 구현
원하는 위치의 데이터를 삭제하기
11
// 삭제할 요소 앞뒤 포인터를 취해둠
// delitem에는 삭제할 요소의 데이터가 들어있음, 메모리 해제
amugona2015
insertion sort
12
삽입정렬 코딩
○ 문제) 3,0,1,8,7,2,5,4,9,6을 0,1,2,3,4,5,6,7,8,9로 삽입정렬 알고리즘으로 정렬하기
• 첫 번째 원소와 그 다음 원소 2개를 비교하
여 작은 원소를 왼쪽으로 배치
• 두 번째 비교부터 인덱스가 감소하며 원소 2
개를 비교하여 작은 원소를 왼쪽으로 배치
끝
[1]주스 재분배, TopCoder 탑코더 알고리즘 트레이닝
[2]포크댄스로 알고리즘 이해, https://www.youtube.com/watch?v=ROalU379l3U
13

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

스터디3회 연결리스트, 삽입정렬 구현하기

  • 1. 구현하기 (Linked List/Insertion sort) amugona study 3회 전정완 2015-08-13
  • 2. amugona2015 Programs = Data Structures + Algorithms program이 올바르고 효율적으로 작성되기 위해서는 data structures와 algorithms이 정확하고 효율적이어야 한다. Programming 2
  • 4. amugona2015 linked list ○ 구조체의 집합으로 표현되며, 그 member로 자기 자신과 똑같은 형의 pointer 를 가짐 ○ pointer가 다음 element를 가리킴 ○ memory의 물리적인 이동 없이 data의 추가, 삭제, 정렬이 가능하므로 많은 data를 취급 시 적합한 자료구조 ○ 원하는 data 참조 시 처음부터 찾아야 함 ○ 배열보다 data 호출에 시간이 더 많이 걸림 linked list 구현 4 e1 e2 e3 e4
  • 5. amugona2015 linked list 구현 구현 내용 ○ linked list에 데이터A를 저장하기 ○ 리스트의 모든 데이터를 표시하기 ○ 새로운 데이터를 제일 끝에 추가하기 ○ 원하는 위치에 데이터를 삽입하기 ○ 원하는 위치의 데이터를 삭제하기 ○ 모든 데이터 삭제하기 구현 환경 ○ C, Win32 console app, VS 2012 5 num word 1 accord 2 grant 3 bestow 4 concede 데이터A list: 표시 add: 추가 insert: 삽입 delete: 삭제 clear: 모두 삭제 quit: 프로그램종료 command 입력
  • 6. amugona2015 linked list 구현 commad 입력 6 데이터 리스트 출력 데이터 추가 데이터 삽입 데이터 삭제 데이터 모두 삭제
  • 7. amugona2015 linked list 구현 연결리스트 작성  linked list에 데이터A를 저장하기 7 • 연결리스트는 구조체의 집합 으로 표현된다
  • 8. amugona2015 linked list 구현 리스트의 모든 데이터를 표시하기 8 // 다음 가리키는 요소가 없을 때 까지 요소들 출력
  • 9. amugona2015 linked list 구현 새로운 데이터를 제일 끝에 추가하기 9 // malloc()으로 새 구조체에 대한 메모리 확보 // 마지막 요소의 주소를 얻음 // 마지막 요소의 주소를 얻음 e 1 e 2 n n null
  • 10. amugona2015 linked list 구현 원하는 위치에 데이터를 삽입하기 10 // 새로운 요소의 next에 다음의 주소를 넣음 e 1 e 2 n n p e 3
  • 11. amugona2015 linked list 구현 원하는 위치의 데이터를 삭제하기 11 // 삭제할 요소 앞뒤 포인터를 취해둠 // delitem에는 삭제할 요소의 데이터가 들어있음, 메모리 해제
  • 12. amugona2015 insertion sort 12 삽입정렬 코딩 ○ 문제) 3,0,1,8,7,2,5,4,9,6을 0,1,2,3,4,5,6,7,8,9로 삽입정렬 알고리즘으로 정렬하기 • 첫 번째 원소와 그 다음 원소 2개를 비교하 여 작은 원소를 왼쪽으로 배치 • 두 번째 비교부터 인덱스가 감소하며 원소 2 개를 비교하여 작은 원소를 왼쪽으로 배치
  • 13. 끝 [1]주스 재분배, TopCoder 탑코더 알고리즘 트레이닝 [2]포크댄스로 알고리즘 이해, https://www.youtube.com/watch?v=ROalU379l3U 13

Editor's Notes

  1. 사람이 쉽게 이해하고 이용할 수 있는 data structure와, 이를 대상으로 구현될 프로그램의 논리인 algorithm이 정확하고 효율적이어야 한다. algorithm과 data structure는 밀접한 관계를 가지며, 서로 어느 한쪽이 없이는 이해할 수 없다. 데이터 구조는 소중한 선배 개발자들의 성취 초고층 빌딩을 짓는 것과 1층 단독주택을 짓는 것은 본질적으로는 같은 일이나(“건물을 세운다”) 현실적으로는 완전히 다른 공학적인 고려가 들어간다. 규모가 달라지면 그 규모를 지탱하기 위해 막대한 체계들이 필요해짐
  2. 데이터 삽삭갱하기 -> 좀 더 구체적으로 할일을 정의함