Thạc Sĩ Cấu trúc dữ liệu - Giải Bài tập bằng Passcal

Thảo luận trong 'Công Nghệ Thông Tin' bắt đầu bởi Thúy Viết Bài, 5/12/13.

  1. Thúy Viết Bài

    Thành viên vàng

    Bài viết:
    198,891
    Được thích:
    170
    Điểm thành tích:
    0
    Xu:
    0Xu
    {---------------TRON 2 DANH SACH ----------}
    Procedure MergerList(L1,L2:List;Var L:List);
    Var Q,P,T: List;
    Begin
    sapxep(L1);
    sapxep(L2);
    P:=first(L1);
    { CACH 1: while P<>end_L(L1) do
    begin
    insert_L(retrieve(P,L1),End_L(L),L);
    P:=P^.next;
    end;
    Q:=L2;
    while Q<>end_L(L2) do
    begin
    T:=first(L);
    while (T<>nil) and (retrieve(T,L)<retrieve(Q,L2)) do
    T:=T^.next;
    insert_L(retrieve(Q,L2),T,L);
    Q:=Q^.next;
    end; }
    P:=First(L1);q:=FIRST(L2);
    while (P<>End_L(L1)) and (Q<>End_L(L2)) do
    if retrieve(P,L1)<Retrieve(Q,L2) then
    begin
    insert_L(retrieve(P,L1),End_L(L),L);
    P:=P^.next;
    end
    else
    begin
    insert_L(retrieve(Q,L2),End_L(L),L);
    Q:=Q^.next;
    end ;
    while P<>end_L(L1) do
    begin
    insert_L(retrieve(P,L1),End_L(L),L);
    P:=P^.next;
    end;
    while Q<>end_L(L2) do
    begin
    insert_L(retrieve(Q,L2),End_L(L),L);
    Q:=Q^.next;
    end;
    End;
     

    Các file đính kèm:

Đang tải...