[7급 국가직 자료구조론 2023년 17번]

다음 C 코드에 10개의 노드로 이루어진 이중 연결 리스트를 입력하여 수행한 후, 이중 연결 리스트에 남아 있는 노드의 개수는? (단, 10개 노드 입력 후 수행 시 start는 첫 번째 노드를 가리킨다)
typedef struct node {
  int key;
  struct node *prev, *next;
} node;

void foobar(node *start) {
    node *current = start; 
    int iseven = 0; 
    while(current != NULL) {
      if(iseven == 1) {
        current->prev->next = current->next;
        if(current->next != NULL) 
          current->next->prev = current->prev;
      }
      current = current->next; 
      iseven = 1 - iseven;
    }
}
자료구조론
  1. ①5
  2. ②6
  3. ③8
  4. ④10

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

정답 ①

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

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

오류 신고