.


:




:

































 

 

 

 


. 20 , 4




20 , 4 . .

 

I.

L1, L2, L3 , - ( ), N - .

 

1. append (L1, L2, L3): L3 () L1 L2;

2. reverse (L1, L2): L2 - L1;

3. delete_first (E, L1, L2): L2 L1 ;

4. delete_all (E, L1, L2): L2 - L1, ;

5. delete_one (E, L1, L2): L2 - L1, ( - L1);

6. no_doubles (L1, L2): L2 - , L1 ;

7. sublist (L1, L2): L1 - L2, .. L2;

8. number (E, N, L): N - E L;

9. sort (L1, L2): L2 - L1;

 

II.

1, 2, 3 , , , - .

 

10. subset (1, 2): 1 2;

11. union (1, 2, 3): 3 - 1 2;

intersection (1, 2, 3): 3 - 1 2, subtraction (1, 2, 3): 3 - 1 2.


III.

, 1 2 , ,

tree (< >, < >, <>)

nil ( ). ,

tree (tree (nil, nil, f), tree (tree(nil, nil, p), tree (nil, nil, r), k))

, .1. - ( - ).

 

       
 
 
   
. 1

 

 


12. tree_depth (, N): N - (.. );

13. sub_tree (1, 2): 1 2;

14. flatten_tree (, L): L - - ( );

15. substitute (1, V, , 2): 2 - , V 1 .

 

IV.

- , - edge (P, R, N), () () P R N ( ) . , .

, 2,

edge(a, c, 8), edge(a, b, 3), edge(c, d, 12), edge(b, d, 0),(e, d, 9),

graph([edge(a, c, 8), edge(a, b, 3), edge(c, d, 12), edge(b, d, 0),edge(e, d, 9)], [a, b, c, d, e]),

graph - , e dge - .


               
   
     
c
 
 
 
 
   
. 2

 


, Y , L - .

 

16. path (, Y, L): L - Y, .. ;

17. min_path (, Y, L): L - Y, ( );

18. short_path (, Y, L): L - Y ( );

19. cyclic: (.. );

20. is_connected: (.. ).

 

:

1) 16-19 ;

2) IV - , : path (G, X, Y, L), G - , .

 

 





:


: 2015-10-01; !; : 518 |


:

:

: , .
==> ...

1855 - | 1460 -


© 2015-2024 lektsii.org - -

: 0.012 .