less than 1 minute read

경계 조건(Boundary Condition)

어떤 자료구조든 신경써야할 경계조건 5가지

  1. 자료 구조가 비어있는 경우(Empty data structure)

  2. 자료 구조에 단 하나의 요소가 들어있을 때(Single element in the data structure)
  3. 자료 구조의 첫번째 요소를 제거하거나 추가하는 경우(Adding / removing beginning of data structure)

Head를 주의하고 Head를 어떻게 다룰 것인지.

  1. 자료 구조의 마지막 요소를 제거하거나 추가할 때(Adding / removing end of the data structure)

  2. 중간 부분을 처리할 때(Working in the middle)




    생각해보기

    1) 자료 구조의 첫 번째 요소를 제거하거나 추가할 때 어떤 포인터를 고려해야 되나요?

    첫 번째 요소를 추가할 때 head의 next가 첫 번째 요소를 가르키게 만들어 줘야 한다. 첫번째 요소를 제거할 때는 head의 next가 두 번째 요소의 주소값으로 바꾸어 주어야 한다.




    References

    자바로 구현하고 배우는 자료구조 -Rob Edwards (boostcourse)

Updated:

Leave a comment