다음 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;
}
}- ①5
- ②6
- ③8
- ④10
선지를 골라 바로 채점해 보세요.
정답 ①
출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)