[Algorithm] What is the Data Structure?

William Parker·2022년 11월 1일
0

Algorithm

목록 보기
5/7
post-thumbnail

I studied a lot about data structures, but looking back, I didn't mention what a data structure is, why it should be used, what's good about it, and how it can be used. It was something I was aware of and overlooked because it was taken for granted, but there is a limit to my memory and I decided that it would be better to organize it in one post, so I will have time to write it in a separate post like this.

What is a data structure?

Ask your readers a question. When you think of data structures, what comes to mind? As common data structures, queues, stacks, linked lists, and trees may come to mind, or sorting algorithms such as selection sort and insertion sort may come to mind first.

The dictionary meaning is a set of data, and each element is listed according to a logically defined rule, and it is said that the data is divided and expressed so that data processing can be performed efficiently. What is the purpose of using these data structures?

The purpose is clear. Used to store and manage data more efficiently, a well-chosen data structure can shorten execution time or lead to memory savings.

Data structure selection criteria

  • Processing time of data

  • size of material

  • Frequency of data use

  • Degree of data update

  • Ease of program

In order to process data more efficiently, it should be selected and used in consideration of the above.

Characteristics of data structures

1. Efficiency

As mentioned earlier, the purpose of using data structures is to efficiently manage and use data. Therefore, if an appropriate data structure is selected and used, work efficiency will increase. As an example, when implementing an algorithm for search, if the amount of data is large, it would be more efficient to use binary search than to use linear search. Because if there are 1 million student data in the student table, if you search the data with sequential search, you can find it in 1 operation if you are lucky, but you will have to go through 1 million operations if you are unlucky. . In contrast, binary search requires far fewer computations. It is efficient to use a data structure suitable for this purpose.

2. Abstraction

Abstraction is the abstraction of core concepts from complex data, modules, and systems. When implementing a data structure, the important thing is to focus on when to insert data and how to use this data at what time, so you can spend more time on things outside of implementation. It does not focus on the algorithm itself.

Similarly, the implementation inside the data structure doesn't matter. You should know how to use it rather than how to implement it.

For example, in the case of a stack, it has the form of FILO (First In Last Out), which comes in first. You can insert data using the push() function and extract data using the pop() function. It doesn't matter what the internal implementation of that function is. Each person will write different codes, and different codes will come out depending on the environment variables such as the language used and the development tool, so if you understand only the abstract concept, you can use it.

3. Reusability

When designing a data structure, it is not designed to work only in a specific program. Since it is designed to be universally designed to be operated in various programs, it can be used in other projects other than the corresponding project.

Classification of data structures

Data structures are broadly divided into linear data structures and non-linear data structures. In the case of a linear data structure, it means that data is arranged in a row, and a non-linear data structure means that it has a specific shape. The data structures corresponding to each are as follows.

linear structure

  • Array

  • Linked List

  • Stack

  • Queue

non-linear structure

  • Tree

  • Graph

profile
Developer who does not give up and keeps on going.

1개의 댓글

comment-user-thumbnail
2023년 4월 4일

who need help improving their coding skills moonstone necklace , daily game solve cross

답글 달기