검색어 입력폼

[공학]자료구조

저작시기 2006.01 |등록일 2006.12.11 한글파일한글 (hwp) | 5페이지 | 가격 700원

소개글

C로 쓴 자료구조 연습문제 4장입니다.
원서 제목은 fundamentals of datastructures in C 입니다.
모두 있는 것은 아니고, 원서로는 146쪽 1번, 6번, 150쪽 1번, 162쪽 7번에 a,b,c,g , 입니다.

번역판으로는 148쪽 1번, 6번, 153쪽 1번, 165쪽, 7번에 a,b,c,g, 입니다.

목차

없음

본문내용

146 page
1. Rewrite delete(Program 4.4) so that it uses only two pointers, ptr and trail.
->
void delete(list_pointer *ptr, list_pointer trail) {
list_pointer temp;
temp = *ptr;
if(trail) {
temp = trail->link;
trail->link=trail->link->link;
}
else *ptr=(*ptr)->link;
free(temp);
}

6. Let x=(x1, x2, ..., xn) and y=(y1, y2, ..., ym) be two linked lists. Assume that in each list, the nodes are in nondecreasing order of their data field values. Write an algorithm to merge the two lists together to obtain a new linked list z in which the nodes are also in this order. Following the merge, x and y do not exist as individual lists. Each node initially in x or y is now in z. No additional nodes may be used. What is the time complexity of your algorithm?
->
list_pointer merge(list_pointer x, list_pointer y) {
list_pointer front, rear;
if(x->data < y->data) {
rear = x;
x = x->link;
}
else {
rear = y;
y = y->link;
}
front = rear;
while(x && y) {
if(x->data < y->data) {
rear->link = x;
x = x->link;
}
else {
rear->link = y;
y = y->link;
}
다운로드 맨위로