Post

๐Ÿญ๐Ÿฎ ๐——๐—ฎ๐˜๐—ฎ ๐—ฆ๐˜๐—ฟ๐˜‚๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ๐˜€ ๐—ฌ๐—ผ๐˜‚ ๐— ๐˜‚๐˜€๐˜ ๐—ž๐—ป๐—ผ๐˜„

Data structures are the foundation of any programming language. They are used to organize and store data in a way that makes it efficient to access and manipulate.

As a tech professional, it is essential to understand different data structures and how to use them effectively.

Today, we will discuss 12 of the most common and important data structures:

  • โ€ข ๐—”๐—ฟ๐—ฟ๐—ฎ๐˜†๐˜€: An array is a collection of items stored in contiguous memory locations. Arrays are efficient for random access, but they can be slow for inserting or deleting elements in the middle.

  • โ€ข ๐—ฆ๐˜๐—ฟ๐—ถ๐—ป๐—ด๐˜€: A string is a sequence of characters. Strings are used to represent text data.

  • โ€ข ๐—ง๐˜‚๐—ฝ๐—น๐—ฒ๐˜€: A tuple is an immutable list of elements. Tuples are similar to arrays, but they cannot be modified after they are created.

  • โ€ข ๐—Ÿ๐—ถ๐˜€๐˜๐˜€: A list is a linear collection of items that can be of different data types. Lists are flexible and can be used to store a variety of data.

  • โ€ข ๐——๐—ถ๐—ฐ๐˜๐—ถ๐—ผ๐—ป๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€: A dictionary (also called a hash table) is a collection of key-value pairs. Dictionaries are efficient for looking up values by key.

  • โ€ข ๐—ฆ๐—ฒ๐˜๐˜€: A set is a collection of unique elements. Sets are useful for storing unique items and checking for membership.

  • โ€ข ๐—ง๐—ฟ๐—ฒ๐—ฒ๐˜€: A tree is a hierarchical data structure that simulates a tree structure with a root node, child nodes, and so on. Trees are efficient for searching and sorting data.

  • โ€ข ๐—Ÿ๐—ถ๐—ป๐—ธ๐—ฒ๐—ฑ ๐—Ÿ๐—ถ๐˜€๐˜๐˜€: A linked list is a linear data structure where each element (or node) contains data and a reference (or pointer) to the next node in the list. Linked lists are more flexible than arrays for inserting or deleting elements, but they can be slower for random access.

  • โ€ข ๐—ฆ๐˜๐—ฎ๐—ฐ๐—ธ๐˜€: A stack is a LIFO (Last In, First Out) data structure. Stacks are like a pile of plates. You can only add or remove elements from the top of the stack. Stacks are useful for implementing undo/redo functionality and function calls.

  • โ€ข ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ๐˜€: A queue is a FIFO (First In, First Out) data structure. Queues are like a line of people waiting for something. The first person in line is the first person to be served. Queues are useful for processing tasks in a specific order.

  • โ€ข ๐—š๐—ฟ๐—ฎ๐—ฝ๐—ต๐˜€: A graph is a non-linear data structure that consists of nodes (or vertices) and edges (or links) that connect them. Graphs are used to represent relationships between objects.

  • โ€ข ๐— ๐—ฎ๐—ฝ๐˜€: A map is similar to a dictionary but it can store key-value pairs where the keys can be of any data type. Maps are useful for storing and retrieving data based on keys that may not be strings.

By understanding these data structures, you will be able to write more efficient and effective code and answer those nasty interview questions with confidence :-)

 ๐Ÿญ๐Ÿฎ ๐——๐—ฎ๐˜๐—ฎ ๐—ฆ๐˜๐—ฟ๐˜‚๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ๐˜€ ๐—ฌ๐—ผ๐˜‚ ๐— ๐˜‚๐˜€๐˜ ๐—ž๐—ป๐—ผ๐˜„

Translate to Korean

๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋Š” ๋ชจ๋“  ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์˜ ๊ธฐ์ดˆ์ž…๋‹ˆ๋‹ค. ์ด๋Š” ํšจ์œจ์ ์œผ๋กœ ์•ก์„ธ์Šคํ•˜๊ณ  ์กฐ์ž‘ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๊ตฌ์„ฑํ•˜๊ณ  ์ €์žฅํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

๊ธฐ์ˆ  ์ „๋ฌธ๊ฐ€๋กœ์„œ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์™€ ์ด๋ฅผ ํšจ๊ณผ์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ดํ•ดํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

์˜ค๋Š˜์€ ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์ด๊ณ  ์ค‘์š”ํ•œ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ 12๊ฐ€์ง€์— ๋Œ€ํ•ด ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

  • โ€ข ๐—”๐—ฟ๐—ฟ๐—ฎ๐˜†๐˜€: ๋ฐฐ์—ด์€ ์ธ์ ‘ํ•œ ๋ฉ”๋ชจ๋ฆฌ ์œ„์น˜์— ์ €์žฅ๋œ ํ•ญ๋ชฉ์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ฐฐ์—ด์€ ์ž„์˜ ์•ก์„ธ์Šค์—๋Š” ํšจ์œจ์ ์ด์ง€๋งŒ ์ค‘๊ฐ„์— ์š”์†Œ๋ฅผ ์‚ฝ์ž…ํ•˜๊ฑฐ๋‚˜ ์‚ญ์ œํ•˜๋Š” ๋ฐ๋Š” ์†๋„๊ฐ€ ๋Š๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • โ€ข ๐—ฆ๐˜๐—ฟ๐—ถ๐—ป๐—ด๐˜€.: ๋ฌธ์ž์—ด์€ ์ผ๋ จ์˜ ๋ฌธ์ž์ž…๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์€ ํ…์ŠคํŠธ ๋ฐ์ดํ„ฐ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

  • โ€ข ๐—ง๐˜‚๐—ฝ๐—น๐—ฒ๐˜€: ํŠœํ”Œ์€ ๋ถˆ๋ณ€์˜ ์š”์†Œ ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค. ํŠœํ”Œ์€ ๋ฐฐ์—ด๊ณผ ์œ ์‚ฌํ•˜์ง€๋งŒ ์ƒ์„ฑ๋œ ํ›„์—๋Š” ์ˆ˜์ •ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

  • โ€ข ๐—Ÿ๐—ถ๐˜€๐˜๐˜€: ๋ชฉ๋ก์€ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์ด ๋  ์ˆ˜ ์žˆ๋Š” ํ•ญ๋ชฉ์˜ ์„ ํ˜• ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ๋ชฉ๋ก์€ ์œ ์—ฐํ•˜๋ฉฐ ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” ๋ฐ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • โ€ข ๐——๐—ถ๐—ฐ๐˜๐—ถ๐—ผ๐—ป๐—ฎ๐—ฟ๐—ถ๐—ฒ๐˜€: ์‚ฌ์ „(ํ•ด์‹œ ํ…Œ์ด๋ธ”์ด๋ผ๊ณ ๋„ ํ•จ)์€ ํ‚ค-๊ฐ’ ์Œ์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ์‚ฌ์ „์€ ํ‚ค๋ณ„๋กœ ๊ฐ’์„ ์ฐพ๋Š” ๋ฐ ํšจ์œจ์ ์ž…๋‹ˆ๋‹ค.

  • โ€ข ๐—ฆ๐—ฒ๐˜๐˜€: ์„ธํŠธ๋Š” ๊ณ ์œ ํ•œ ์š”์†Œ์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค. ์„ธํŠธ๋Š” ๊ณ ์œ ํ•œ ํ•ญ๋ชฉ์„ ์ €์žฅํ•˜๊ณ  ํšŒ์› ์ž๊ฒฉ์„ ํ™•์ธํ•˜๋Š” ๋ฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

  • โ€ข ๐—ง๐—ฟ๐—ฒ๐—ฒ๐˜€: ํŠธ๋ฆฌ๋Š” ๋ฃจํŠธ ๋…ธ๋“œ, ํ•˜์œ„ ๋…ธ๋“œ ๋“ฑ์œผ๋กœ ํŠธ๋ฆฌ ๊ตฌ์กฐ๋ฅผ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ํ•˜๋Š” ๊ณ„์ธต์  ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค. ํŠธ๋ฆฌ๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ  ์ •๋ ฌํ•˜๋Š” ๋ฐ ํšจ์œจ์ ์ž…๋‹ˆ๋‹ค.

  • โ€ข ๐—Ÿ๐—ถ๐—ป๐—ธ๐—ฒ๐—ฑ ๐—Ÿ๐—ถ๐˜€๐˜๐˜€: ์—ฐ๊ฒฐ๋œ ๋ชฉ๋ก์€ ๊ฐ ์š”์†Œ(๋˜๋Š” ๋…ธ๋“œ)๊ฐ€ ๋ฐ์ดํ„ฐ์™€ ๋ชฉ๋ก์˜ ๋‹ค์Œ ๋…ธ๋“œ์— ๋Œ€ํ•œ ์ฐธ์กฐ(๋˜๋Š” ํฌ์ธํ„ฐ)๋ฅผ ํฌํ•จํ•˜๋Š” ์„ ํ˜• ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค. ์—ฐ๊ฒฐ ๋ชฉ๋ก์€ ์š”์†Œ๋ฅผ ์‚ฝ์ž…ํ•˜๊ฑฐ๋‚˜ ์‚ญ์ œํ•˜๋Š” ๋ฐ ๋ฐฐ์—ด๋ณด๋‹ค ์œ ์—ฐํ•˜์ง€๋งŒ ์ž„์˜ ์•ก์„ธ์Šค์—๋Š” ์†๋„๊ฐ€ ๋Š๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • โ€ข ๐—ฆ๐˜๐—ฎ๐—ฐ๐—ธ๐˜€: ์Šคํƒ์€ LIFO(Last In, First Out) ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค. ์Šคํƒ์€ ์ ‘์‹œ ๋”๋ฏธ์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์Šคํƒ ์ƒ๋‹จ์—์„œ๋งŒ ์š”์†Œ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์Šคํƒ์€ ์‹คํ–‰ ์ทจ์†Œ/๋‹ค์‹œ ์‹คํ–‰ ๊ธฐ๋Šฅ๊ณผ ํ•จ์ˆ˜ ํ˜ธ์ถœ์„ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

  • โ€ข ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ๐˜€: ํ๋Š” FIFO(์„ ์ž…์„ ์ถœ) ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค. ๋Œ€๊ธฐ์—ด์€ ๋ฌด์–ธ๊ฐ€๋ฅผ ๊ธฐ๋‹ค๋ฆฌ๋Š” ์‚ฌ๋žŒ๋“ค์˜ ์ค„๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ค„์„ ์„œ ์žˆ๋Š” ์ฒซ ๋ฒˆ์งธ ์‚ฌ๋žŒ์ด ๊ฐ€์žฅ ๋จผ์ € ์„œ๋น„์Šค๋ฅผ ๋ฐ›๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋Œ€๊ธฐ์—ด์€ ํŠน์ • ์ˆœ์„œ๋กœ ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

  • โ€ข ๐—š๐—ฟ๐—ฎ๐—ฝ๐—ต๐˜€: ๊ทธ๋ž˜ํ”„๋Š” ๋…ธ๋“œ(๋˜๋Š” ๊ผญ์ง€์ )์™€ ์ด๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” ๋ชจ์„œ๋ฆฌ(๋˜๋Š” ๋งํฌ)๋กœ ๊ตฌ์„ฑ๋œ ๋น„์„ ํ˜• ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ž˜ํ”„๋Š” ๊ฐœ์ฒด ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

  • โ€ข ๐— ๐—ฎ๐—ฝ๐˜€: ๋งต์€ ์‚ฌ์ „๊ณผ ์œ ์‚ฌํ•˜์ง€๋งŒ ํ‚ค๊ฐ€ ๋ชจ๋“  ๋ฐ์ดํ„ฐ ์œ ํ˜•์ผ ์ˆ˜ ์žˆ๋Š” ํ‚ค-๊ฐ’ ์Œ์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋งต์€ ๋ฌธ์ž์—ด์ด ์•„๋‹ ์ˆ˜๋„ ์žˆ๋Š” ํ‚ค๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๊ณ  ๊ฒ€์ƒ‰ํ•˜๋Š” ๋ฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋ฅผ ์ดํ•ดํ•จ์œผ๋กœ์จ ๋ณด๋‹ค ํšจ์œจ์ ์ด๊ณ  ํšจ๊ณผ์ ์ธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ๋ถˆ์พŒํ•œ ์ธํ„ฐ๋ทฐ ์งˆ๋ฌธ์— ์ž์‹ ์žˆ๊ฒŒ ๋‹ตํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค :-)

This post is licensed under CC BY 4.0 by the author.