









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A brief overview of data structures in computer science within the context of software engineering. It covers the importance of software development processes, the goals of software design, and the role of data structures in achieving high-quality software. It also discusses the significance of understanding data structures for effective problem-solving and efficient algorithm implementation.
Typology: Lecture notes
1 / 15
This page cannot be seen from the preview
Don't miss anything!
์ํํธ์จ์ด ๋ช ์ธ์ : not how but what ์ค๊ณ ์ํ ๋ถ์ ๊ตฌํ ๊ฒ์ฌ์ ๊ฒ์ฆ ์ด์ ์ ์ง๋ณด์
์ํํธ์จ์ด ์๋ช ์ฃผ๊ธฐ (lifecycle) not sequential!!!
๊ฐ๋ฐํ ์ํํธ์จ์ด์ ํ๋กํ ํ์ ํ๋กํ ํ์ (prototype) ๋๋ ์ผ๋ถ ๊ตฌ์ฑ์์์ ํ๋กํ ํ์ ์ ๋ง๋ค๋ฉด ๊ด๋ จ ์ฌ๋๋ค๊ฐ์ ์ปค๋ฎค๋์ผ์ด์ ์ ํฅ์์ํฌ ์ ์์ผ๋ฉฐ , ์ ๋ฌธ์ ์ ๋ํ ๋ณด๋ค ์ ํํ ๋ต์ ์ป์ ์ ์๋ค.
์ํํธ์จ์ด์ํํธ์จ์ด ๊ณตํ๊ณตํ (software engineering): ๊ณ ํ์ง์ ์ํํธ์จ์ด ๊ฐ๋ฐ์ ๋ชจ๋ ์ธก๋ฉด๊ณผ ๊ด๋ จ๋ ํ๋ฌธ์ ๋งํจ ์ฌ์ฉ๋๋ ๊ธฐ์ ๊ณผ ํ์ ( ๋ฌธ์ํ , ํ์ํฌ ๋ฑ ) ๋ฅผ ๋ชจ๋ ํฌํจ ์ํํธ์จ์ด์ํํธ์จ์ด ํ๋ก์ธ์คํ๋ก์ธ์ค (software process):^ ์์คํ ์ ๊ฐ๋ฐํ๊ธฐ ์ํด ๊ฐ์ธ ๋๋ ์กฐ์ง์ด ์ฌ์ฉํ๋ ์ํํธ์จ์ด ๊ณตํ ๊ธฐ์ ์ ์งํฉ์ ๋งํจ ์ฌ์ฉํ๋ ์ํํธ์จ์ด ๊ธฐ์ ๋๋ ๋๊ตฌ ํ๋์จ์ด ์ํํธ์จ์ด : ์ปดํ์ผ๋ฌ , ๋๋ฒ๊ฑฐ ๋ฑ ์์ด๋์ด์จ์ด : ์ํํธ์จ์ด ๊ธฐ์ ๊ณผ ๊ด๋ จ๋ ์ง์
Panic and do nothing 39% Panic and drop the course 30% Sit down at the computer and begin typing 27% Stop and think 4%
์ถ์ํ์ถ์ํ (abstraction): ํน์ ๊ด์ฐฐ์ ์ ์ฅ์์ ์์คํ ์ ํ์์ ์ธ ์ฌํญ๋ง์ ํฌํจํ๋ ๋ณต์กํ ์์คํ ์ ๋ํ ๋ชจ๋ธ ๊ด์ฐฐ์๋ง๋ค ๋ค๋ฅผ ์ ์์ ๋ถํ์ํ ํ์ ์์ค์ ์ธ๋ถ์ฌํญ์ ๋ํ ๊ณ ๋ ค ์์ด ์ ์ ํ ์์ค์์ ๋ฌธ์ ์ ๋ํด ์ง์คํ ์ ์๋๋ก ํด์ค๋ค. (stepwise-refinement) ์ถ์ํ๋ ๊ฒ์ ์ ์ง์ ์ผ๋ก ์ธ๋ถํ๋์ด ๊ตฌ์ฒดํ๋๋ค. ํํฅ์ (top-down) ์ํฅ์ (bottom-up) ๊ฐ์ฒด์งํฅ ์ ๊ทผ ๋ถํ ์ ๋ณต๋ถํ ์ ๋ณต (divide-and-conquer): ๋ณต์กํ ๋ฌธ์ ์ผ ์๋ก ํ ๋ฉ์ด๋ฆฌ๋ก ์ ๊ทผํ๋ ๊ฒ์ด ๋งค์ฐ ์ด๋ ต๋ค.
์ ์ฒด ๋ฌธ์ ์ ์์ ์ผ๋ถ๋ถ์ ๋ชจ๋๋ชจ๋ (module) ์ด๋ผ ํ๋ค. ์ ๋ณด์ ๋ณด ์๋์๋ (information hiding):^ ๋ชจ๋์ ๊ทธ๊ฒ์ ๋ณต์กํ ๋ด๋ถ ๊ตฌ์กฐ๋ฅผ ์ธ๋ถ๋ก๋ถํฐ ์จ๊ธด๋ค. ๋ณต์ก์ฑ์ ์ค์ด๊ธฐ ์ํ ๋ชฉ์ ๋ชจ๋์ ๊ทธ๊ฒ์ ์ธํฐํ์ด์ค๋ฅผ ํตํด์๋ง ๋ค๋ฅธ ๋ชจ๋๊ณผ ์ํธ์์ฉํ๋ค. ๋ชจ๋์ ์๊ตฌ์ฌํญ ๋์จํ๋์จํ ๊ฒฐํฉ์ฑ๊ฒฐํฉ์ฑ (loosely-coupled): ๋ชจ๋์ ์ํธ ๋ ๋ฆฝ์ ์ด์ด์ผ ํ๋ค. ํ ๋ชจ๋์ ๋ณ๊ฒฝ์ด๋ ์ค๋ฅ๊ฐ ๋ค๋ฅธ ๋ชจ๋์ ์ํฅ์ ์ฃผ์ง ์์์ผ ํ๋ค. ๋์๋์ ์์ง์ฑ์์ง์ฑ (highly-cohesive): ์ ์ ์๋ ๋จ์ผ ์์ ๋งํด์ผ ํ๋ค.
๊ฐ์ฒด์งํฅ๊ฐ์ฒด์งํฅ ์ค๊ณ์ค๊ณ (object-oriented design) ๋ ๋ฌธ์ ์์ ๊ฐ์ฒด๋ฅผ ์๋ณํ๊ณ , ์ด ๊ฐ์ฒด๋ค์ ์ด์ฉํ์ฌ ๋ชจ๋ธ๋งํ๋ค. ( ๋ช ์ฌ ) ๋ฐ์ดํฐ ์ค์ฌ ์ค์ธ๊ณ์ ๊ฐ๊น๊ฒ ๋ชจ๋ธ๋งํ ์ ์์ ๊ตฌ์กฐํ๋๊ตฌ์กฐํ๋ ์ค๊ณ์ค๊ณ (structured design) ๋ ๋ฌธ์ ์์ ํ์๋ฅผ ์๋ณํ์ฌ ํ์ ์์ฃผ๋ก ๋ชจ๋ธ๋งํ๋ค. ( ๋์ฌ ) ์๊ณ ๋ฆฌ์ฆ ์ค์ฌ
๊ฐ์ฒด์งํฅ ํ๋ก๊ทธ๋๋ฐ์ ์ธ๊ฐ์ง ํต์ฌ ์์
1. ์บก์ํ (encapsulation): ๋ฐ์ดํฐ์ ํ์์ ๊ฒฐํฉ 2. ์์ (inheritance): ์ฝ๋์ ์ฌ์ฌ์ฉ 3. ๋คํ์ฑ (polymorphism): ์คํ์๊ฐ์ ๊ฐ์ฒด์ ์ํด ํ์๊ฐ ๊ฒฐ์ ๋จ
์ฌ๋ฌ ์ฌ๋๋ค๊ณผ ๋ธ๋ ์ธ์คํ ๋ฐ (brainstorming) ์ ํ๋ค. ์ฌ๋ฌ ์๋๋ฆฌ์ค๋ฅผ ์๊ฐํด๋ณธ๋ค.
๊ฐ ๊ฐ์ฒด๋ง๋ค CRC(Class, Responsibility, Collaboration) ์นด๋๋ฅผ ์์ฑ
์์
name ํด๋์ค๋ก๋ถํฐ ์ด๋ฆ์
name ํด๋์ค๋ก๋ถํฐ ์ฑ์
ํ๋
์ฃผ์ ์ ๊ณต
์ ์ฒด ์ด๋ฆ์ ํ๋์ ๋ฌธ์์ด๋ก ์ ๊ณต
์ฑ ์
์ฃผ์ ์ฑ ์ : ์ฃผ์๋ก ํ ํญ์ ๋ํ ์ ๋ณด๋ฅผ ๊ด๋ฆฌํ๋ค.
ํด๋์ค ์ด๋ฆ : entry ๋ถ๋ชจ ํด๋์ค : ์์ ํด๋์ค :
์ปดํ์ผ ์๊ฐ ์ค๋ฅ (compile-time error): ๋ฌธ๋ฒ ์ค๋ฅ ์คํ ์๊ฐ ์ค๋ฅ (run-time error) ์ ๋ชป๋ ๊ฐ์ : result = dividend / divisor ์ฌ์ฉ์ ์ ๋ ฅ ์ค๋ฅ ๋ ผ๋ฆฌ ์ค๋ฅ ์ค๋ฅ๊ฐ ๋ฐ์ํ์์ ๋ ๊ทธ๊ฒ์ ๊ทน๋ณตํ ์ ์๋ ๋ฅ๋ ฅ์ ๊ฐ๊ฑด์ฑ (robustness) ์ด๋ผ ํ๋ค. ์์ธ ์ฒ๋ฆฌ (exception handling) ์ค๊ณ๋ถํฐ ์ด๋ค ๊ฐ๋ฅํ ์์ธ ์ํฉ์ด ๋ฐ์ํ ์ ์๋์ง ๊ณ ๋ คํด์ผ ํจ what, where, how
์ฌ์ ์กฐ๊ฑด์ฌ์ ์กฐ๊ฑด (precondition): ์ฌํ์กฐ๊ฑด์ด ๋ณด์ฅ๋๊ธฐ ์ํด ๋ฉ์๋์ ์ง์ ํ๊ธฐ ์ ์ ๋ฐ๋์ ๋ง์กฑํด์ผ ํ๋ ๊ฐ์ ๋ฉ์๋๋ฅผ ํธ์ถํ๋ ์ฌ์ฉ์์ ์ฑ ์ ์ฌ์ ์กฐ๊ฑด์ด ์๋ฐฐ๋ ๊ฒฝ์ฐ์๋ ์ด๋ป๊ฒ? ๋ฐฉ๋ฒ๋ฐฉ๋ฒ 1.1. ์์ธ ์ฒ๋ฆฌ ๋ฐฉ๋ฒ๋ฐฉ๋ฒ 2.2.^ ์๋ฌด๊ฒ๋ ํ์ง ์๋๋ค. ์ฌํ์กฐ๊ฑด์ฌํ์กฐ๊ฑด (postcondition): ์ฌ์ ์กฐ๊ฑด์ด ์ถฉ์กฑ๋์์ ๋ , ๊ธฐ๋๋๋ ๋ฉ์๋์ ์คํ ๊ฒฐ๊ณผ ์ด๋ป๊ฒ ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ์ป๋์ง๋ ์ค์ํ์ง ์์ ๋ฉ์๋๋ฅผ ๊ตฌํํ๋ ๊ฐ๋ฐ์์ ์ฑ ์ ์ฌ์ , ์ฌํ์กฐ๊ฑด์ ๋ํ ์ฌ๋ฐ๋ฅธ ์ดํด๊ฐ ์์ผ๋ฉด ์ฌ๋ฌ ๊ฐ์ง ๋ ผ๋ฆฌ ์ค๋ฅ๋ฅผ ๋ฒํ ์ ์๋ค.
์ฌ์ , ์ฌํ์กฐ๊ฑด์ ์ ) void RemoveLast() ํจ๊ณผ : ๋ฆฌ์คํธ์ ์๋ ๋ง์ง๋ง ์์๋ฅผ ์ ๊ฑฐํ๋ค. ์ฌ์ ์กฐ๊ฑด : ๋ฆฌ์คํธ๊ฐ ๋น์ด์์ง ์์์ผ ํ๋ค. ์ฌํ์กฐ๊ฑด : ๋ฆฌ์คํธ์ ์๋ ๋ง์ง๋ง ์์๊ฐ ์ ๊ฑฐ๋์ด ์๋ค.
WARNING If you try to execute this operation when the preconditions are not true, the results are not guaranteed
๋ฃจํ๋ฃจํ ๋ถ๋ณ์กฐ๊ฑด๋ถ๋ณ์กฐ๊ฑด (loop invariant): ๋ฃจํธ๊ฐ ์์๋๊ธฐ ์ , ๋ฃจํ๊ฐ ๋ฐ๋ณต๋ ํ , ๋ฃจํ๊ฐ ์ข ๋ฃ๋ ํ์ ํญ์ ๋ง์กฑ๋์ด์ผ ํ๋ ์กฐ๊ฑด์ ๋งํ๋ค. ์ถ๊ฐ์ ์ผ๋ก ์๊ณ ๋ฆฌ์ฆ์ ์ ํ์ฑ์ ์ถฉ์กฑ์์ผ์ผ ํ๋ค. ์์ 1.2)1.2) ๋ฐฐ์ด item ์ ์๋ ์์๋ค์ ํฉ ๊ตฌํ๊ธฐ int sum = 0; int i = 0; while(i<n){ sum += item[i]; i++; }
๋ฃจํ ๋ถ๋ณ์กฐ๊ฑด. sum ์ item[0] ๋ถํฐ item[i-1] ๊น์ง์ ํฉ์ด์ด์ผ ํ๋ค.
๋ณดํต ๋ฐ์ดํฐ๋ผ ํ๋ฉด ๊ฐ (value) ๋ฅผ ์๋ฏธํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ ๋ฐ์ดํฐ๋ฐ์ดํฐ ํ์ ํ์ : ๋ค์ ๋ ๊ฐ์ง์ ์ํด ์ ์๋๋ค. ์ด ๋ฐ์ดํฐ ํ์ ์ด ํํํ ์ ์๋ ์์๋ค์ ์งํฉ. ์์ 1.3)1.3) ์ ์ ์ด ์์๋ค์ ์ ์ฉํ ์ ์๋ ์ฐ์ฐ์ ์งํฉ. ์์ 1.4)1.4) ์ฌ์น์ฐ์ฐ ํ๋ก๊ทธ๋๋ฐ ์ธ์ด๋ ๋ ์ข ๋ฅ์ ๋ฐ์ดํฐ ํ์ ์ ์ ๊ณตํ๋ค. ์์คํ ์ ์ ๋ฐ์ดํฐ ํ์ ๋จ์๋จ์ ํ์ ํ์ ( ์์ ํ์ , ์์ ํ์ ): ๋ ์ด์ ๋ถํดํ ์ ์๋ ํ์ ๋ณตํฉ๋ณตํฉ ํ์ ํ์ : ์ฌ๋ฌ ์์๋ก ๊ตฌ์ฑ๋์ด ์๋ ํ์ ร ์์ ์ ๊ทผ ์ฐ์ฐ ๊ตฌ์กฐํ๋ ํ์ ๊ณผ ๋น๊ตฌ์กฐํ๋ ํ์ ์ฌ์ฉ์ ์ ์ ๋ฐ์ดํฐ ํ์
์ ์ฐจ์์ ์ฐจ์ ์ถ์ํ์ถ์ํ (procedural abstraction) ๋ฉ์๋์ ๋ชฉ์ ๊ณผ ๊ทธ๊ฒ์ ๊ตฌํ์ ๋ถ๋ฆฌ ๋ฐ์ดํฐ๋ฐ์ดํฐ ์ถ์ํ์ถ์ํ (data abstraction, encapsulation) ๋ฐ์ดํฐ์ ๊ฐ๋ฅํ ์ฐ์ฐ๊ณผ ๋ฐ์ดํฐ ์ ์ฅ ๋ฐฉ๋ฒ ๋ฐ ์ฐ์ฐ ๊ตฌํ์ ๋ถ๋ฆฌ ์ถ์์ถ์ ๋ฐ์ดํฐ๋ฐ์ดํฐ ํ์ ํ์ (ADT, Abstract Data Type) ํน์ ๊ตฌํ๊ณผ ๋ฌด๊ดํ๊ฒ ํน์ฑ์ด ๋ช ์๋ ๋ฐ์ดํฐ ํ์ ํ๋ก๊ทธ๋๋ฐ ์ธ์ด์์ ์ ๊ณตํ๋ int ํ์ ์ญ์ ADT ๋ก ๋ณผ ์ ์๋ค. ๊ทธ๊ฒ์ ๋ด๋ถ ๊ตฌํ์ ๋ชฐ๋ผ๋ ์ฌ์ฉํ ์ ์๋ค.
์๋ฃ๊ตฌ์กฐ์๋ฃ๊ตฌ์กฐ (data structure) ์ ์์ ์ 1.1.^ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๋ ๋ฐฉ๋ฒ๊ณผ ๊ด๋ จ๋ ๊ฒ์ผ๋ก์ ๋ฐ์ดํฐ๋ฐ์ดํฐ ์์๋ค์์๋ค ์์ ๋ชจ์๋ชจ์์ ๋งํ๋ค. ์ด์ด ๋ชจ์์๋ชจ์์ ๋ ผ๋ฆฌ์ ๋ ผ๋ฆฌ์ ๊ตฌ์ฑ์๊ตฌ์ฑ์ ๊ฐ๋ณ๊ฐ๋ณ ์์์์ ๊ฐ์๊ฐ์ ๋ ผ๋ฆฌ์ ๋ ผ๋ฆฌ์ ๊ด๊ณ๊ด๊ณ๋ฅผ ๋ํ๋ธ๋ค. ์ ์์ ์ 2.2. ๋ฐ์ดํฐ์ ๋ชจ์์ ์ ์ฅํ๊ธฐ ์ํด ํ๋ก๊ทธ๋๋ฐ ์ธ์ด๋ฅผ ์ด์ฉํ์ฌ ์ ์ํ ์ ์๋ ๊ตฌ์กฐ ์๋ฃ๊ตฌ์กฐ๋ ๊ฐ๋ณ ๋ฐ์ดํฐ ์์๋ฅผ ๊ฒ์ํ๊ณ ์ ์ฅํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ ์ ๊ทผ์ ๊ทผ ์ฐ์ฐ์์ฐ์ฐ์ ์ํด์ํด ํน์งํน์ง์ง์ด์ง๋ค. ์๋ฃ๊ตฌ์กฐ๋ ADT ๋ก ๊ตฌํ๋๋ค.