JD의 블로그

2. Physical data structure & Logical data structure 본문

-프로그래밍 언어/알고리즘&자료구조

2. Physical data structure & Logical data structure

GDong 2019. 9. 18. 01:22

1. Physical 

: for storing the data

[1] Array

A collection of continous memory locations, all these locations are side by side. 

This array will have fixed size, once it is created of some size, then that size cannot be increased or decreased. 

The size of array is fixed.

An array can be created either inside stack or heap. 

 

When should I use it? 

When you are sure, what is the maximum number of elements that you are going to sotre. (when you know length of the list)

[2] Linked List 

This is a complete dynamic data structure, and it is a collection of nodes where each node contains data, and is linked to the next node. The length of this list can grow and reduce, dynamically. So, It is having variable length. 

You can go on adding more and more nodes and add more elements. 

The linked list is always created in heap. 

Head may be a pointer, that is pointing the list, so the head pointer may be inside the stack.

 

When should I use it? 

if the size of the list is not known.

We can have more physical data structures, by taking the combination of these. 

The reason why these are called "physical" is these data structure decides or defines how the memory is organized, how the memory is allocated. 

 

2. Logical 

: How you will be performing insertion and deletion?

These data structures are actually used in applications and algorithms.

To implement these data structures, we either use array or linked list.

 

Linear data structures

[1] Stack (LIFO - Last in First out)

[2] Queue (FIFO - First in First out)

 

Non-linear data structures

[3] Tree (collection of nodes and the links between the nodes.)

[4] Graph

 

Tabular data structure

[5] Hash Table

'-프로그래밍 언어 > 알고리즘&자료구조' 카테고리의 다른 글

5. Matrices[1] - Diagonal Matrix  (0) 2019.09.19
4. Time and Space complexity  (0) 2019.09.18
3. ADT(Abstract Data Type)  (0) 2019.09.18
1. Stack vs Heap  (0) 2019.09.18
[Algorithm & Data structure] Introduction  (0) 2019.09.16