[7급 국가직 자료구조론 2017년 14번]

다음은 원형 연결 리스트(circular linked list)의 길이를 구하는 C 언어 프로그램이다. ㉠ ~ ㉢에 들어갈 내용으로 옳게 짝지은 것은?
typedef struct node {
  int key; 
  struct node *link;
} list_node;
int length(list_node *ptr) {
  list_node *temp;
  int count = 0;
  if (㉠) {
    temp = ptr;
    do {
      count++;
      ㉡;
    } while (㉢);
  }
  return count;
}
㉠ ㉡ ㉢
자료구조론
  1. ①ptr != NULL temp = temp→link temp != ptr
  2. ②ptr == NULL temp = temp→link temp == ptr
  3. ③ptr != NULL ptr = temp→link temp != ptr
  4. ④ptr == NULL ptr = temp→link temp == ptr

선지를 골라 바로 채점해 보세요.

정답 ①

출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)

신고가 접수됐습니다. 감사합니다.

오류 신고