|
4 | 4 |
|
5 | 5 | ## Working with lists |
6 | 6 |
|
7 | | -[P01](src/main/scala/list/P01.scala) (*) Find the last element of a list. |
| 7 | +[P01](list/src/P01.scala) (*) Find the last element of a list. |
8 | 8 |
|
9 | | -[P02](src/main/scala/list/P02.scala) (*) Find the last but one element of a list. |
| 9 | +[P02](list/src/P02.scala) (*) Find the last but one element of a list. |
10 | 10 |
|
11 | | -[P03](src/main/scala/list/P03.scala) (*) Find the Kth element of a list. |
| 11 | +[P03](list/src/P03.scala) (*) Find the Kth element of a list. |
12 | 12 |
|
13 | | -[P04](src/main/scala/list/P04.scala) (*) Find the number of elements of a list. |
| 13 | +[P04](list/src/P04.scala) (*) Find the number of elements of a list. |
14 | 14 |
|
15 | | -[P05](src/main/scala/list/P05.scala) (*) Reverse a list. |
| 15 | +[P05](list/src/P05.scala) (*) Reverse a list. |
16 | 16 |
|
17 | | -[P06](src/main/scala/list/P06.scala) (*) Find out whether a list is a palindrome. |
| 17 | +[P06](list/src/P06.scala) (*) Find out whether a list is a palindrome. |
18 | 18 |
|
19 | | -[P07](src/main/scala/list/P07.scala) (**) Flatten a nested list structure. |
| 19 | +[P07](list/src/P07.scala) (**) Flatten a nested list structure. |
20 | 20 |
|
21 | | -[P08](src/main/scala/list/P08.scala) (**) Eliminate consecutive duplicates of list elements. |
| 21 | +[P08](list/src/P08.scala) (**) Eliminate consecutive duplicates of list elements. |
22 | 22 |
|
23 | | -[P09](src/main/scala/list/P09.scala) (**) Pack consecutive duplicates of list elements into sublists. |
| 23 | +[P09](list/src/P09.scala) (**) Pack consecutive duplicates of list elements into sublists. |
24 | 24 |
|
25 | | -[P10](src/main/scala/list/P10.scala) (*) Run-length encoding of a list. |
| 25 | +[P10](list/src/P10.scala) (*) Run-length encoding of a list. |
26 | 26 |
|
27 | | -[P11](src/main/scala/list/P11.scala) (*) Modified run-length encoding. |
| 27 | +[P11](list/src/P11.scala) (*) Modified run-length encoding. |
28 | 28 |
|
29 | | -[P12](src/main/scala/list/P12.scala) (**) Decode a run-length encoded list. |
| 29 | +[P12](list/src/P12.scala) (**) Decode a run-length encoded list. |
30 | 30 |
|
31 | | -[P13](src/main/scala/list/P13.scala) (**) Run-length encoding of a list (direct solution). |
| 31 | +[P13](list/src/P13.scala) (**) Run-length encoding of a list (direct solution). |
32 | 32 |
|
33 | | -[P14](src/main/scala/list/P14.scala) (*) Duplicate the elements of a list. |
| 33 | +[P14](list/src/P14.scala) (*) Duplicate the elements of a list. |
34 | 34 |
|
35 | | -[P15](src/main/scala/list/P15.scala) (**) Duplicate the elements of a list a given number of times. |
| 35 | +[P15](list/src/P15.scala) (**) Duplicate the elements of a list a given number of times. |
36 | 36 |
|
37 | | -[P16](src/main/scala/list/P16.scala) (**) Drop every Nth element from a list. |
| 37 | +[P16](list/src/P16.scala) (**) Drop every Nth element from a list. |
38 | 38 |
|
39 | | -[P17](src/main/scala/list/P17.scala) (*) Split a list into two parts. |
| 39 | +[P17](list/src/P17.scala) (*) Split a list into two parts. |
40 | 40 |
|
41 | | -[P18](src/main/scala/list/P18.scala) (**) Extract a slice from a list. |
| 41 | +[P18](list/src/P18.scala) (**) Extract a slice from a list. |
42 | 42 |
|
43 | | -[P19](src/main/scala/list/P19.scala) (**) Rotate a list N places to the left. |
| 43 | +[P19](list/src/P19.scala) (**) Rotate a list N places to the left. |
44 | 44 |
|
45 | | -[P20](src/main/scala/list/P20.scala) (*) Remove the Kth element from a list. |
| 45 | +[P20](list/src/P20.scala) (*) Remove the Kth element from a list. |
46 | 46 |
|
47 | | -[P21](src/main/scala/list/P21.scala) (*) Insert an element at a given position into a list. |
| 47 | +[P21](list/src/P21.scala) (*) Insert an element at a given position into a list. |
48 | 48 |
|
49 | | -[P22](src/main/scala/list/P22.scala) (*) Create a list containing all integers within a given range. |
| 49 | +[P22](list/src/P22.scala) (*) Create a list containing all integers within a given range. |
50 | 50 |
|
51 | | -[P23](src/main/scala/list/P23.scala) (**) Extract a given number of randomly selected elements from a list. |
| 51 | +[P23](list/src/P23.scala) (**) Extract a given number of randomly selected elements from a list. |
52 | 52 |
|
53 | | -[P24](src/main/scala/list/P24.scala) (*) Lotto: Draw N different random numbers from the set 1..M. |
| 53 | +[P24](list/src/P24.scala) (*) Lotto: Draw N different random numbers from the set 1..M. |
54 | 54 |
|
55 | | -[P25](src/main/scala/list/P25.scala) (*) Generate a random permutation of the elements of a list. |
| 55 | +[P25](list/src/P25.scala) (*) Generate a random permutation of the elements of a list. |
56 | 56 |
|
57 | | -[P26](src/main/scala/list/P26.scala) (**) Generate the combinations of K distinct objects chosen from the N elements of a list. |
| 57 | +[P26](list/src/P26.scala) (**) Generate the combinations of K distinct objects chosen from the N elements of a list. |
58 | 58 |
|
59 | | -[P27](src/main/scala/list/P27.scala) (**) Group the elements of a set into disjoint subsets. |
| 59 | +[P27](list/src/P27.scala) (**) Group the elements of a set into disjoint subsets. |
60 | 60 |
|
61 | | -[P28](src/main/scala/list/P28.scala) (**) Sorting a list of lists according to length of sublists. |
| 61 | +[P28](list/src/P28.scala) (**) Sorting a list of lists according to length of sublists. |
62 | 62 |
|
63 | 63 | ## Arithmetic |
64 | 64 |
|
65 | | -[P31](src/main/scala/arithmetic/P31.scala) (**) Determine whether a given integer number is prime. |
| 65 | +[P31](arithmetic/src/P31.scala) (**) Determine whether a given integer number is prime. |
66 | 66 |
|
67 | | -[P32](src/main/scala/arithmetic/P32.scala) (**) Determine the greatest common divisor of two positive integer numbers. |
| 67 | +[P32](arithmetic/src/P32.scala) (**) Determine the greatest common divisor of two positive integer numbers. |
68 | 68 |
|
69 | | -[P33](src/main/scala/arithmetic/P33.scala) (*) Determine whether two positive integer numbers are coprime. |
| 69 | +[P33](arithmetic/src/P33.scala) (*) Determine whether two positive integer numbers are coprime. |
70 | 70 |
|
71 | | -[P34](src/main/scala/arithmetic/P34.scala) (**) Calculate Euler’s totient function ϕ(m). |
| 71 | +[P34](arithmetic/src/P34.scala) (**) Calculate Euler’s totient function ϕ(m). |
72 | 72 |
|
73 | | -[P35](src/main/scala/arithmetic/P35.scala) (**) Determine the prime factors of a given positive integer. |
| 73 | +[P35](arithmetic/src/P35.scala) (**) Determine the prime factors of a given positive integer. |
74 | 74 |
|
75 | | -[P36](src/main/scala/arithmetic/P36.scala) (**) Determine the prime factors of a given positive integer (2). |
| 75 | +[P36](arithmetic/src/P36.scala) (**) Determine the prime factors of a given positive integer (2). |
76 | 76 |
|
77 | 77 | P37 (**) Calculate Euler’s totient function ϕ(m) (improved). |
78 | 78 |
|
79 | 79 | P38 (*) Compare the two methods of calculating Euler’s totient function. |
80 | 80 |
|
81 | | -[P39](src/main/scala/arithmetic/P39.scala) (*) A list of prime numbers. |
| 81 | +[P39](arithmetic/src/P39.scala) (*) A list of prime numbers. |
82 | 82 |
|
83 | | -[P40](src/main/scala/arithmetic/P40.scala) (**) Goldbach's conjecture. |
| 83 | +[P40](arithmetic/src/P40.scala) (**) Goldbach's conjecture. |
84 | 84 |
|
85 | | -[P41](src/main/scala/arithmetic/P41.scala) (**) A list of Goldbach compositions. |
| 85 | +[P41](arithmetic/src/P41.scala) (**) A list of Goldbach compositions. |
86 | 86 |
|
87 | 87 | ## Logic and Codes |
88 | 88 |
|
89 | | -[P46](src/main/scala/logic/P46.scala) (**) Truth tables for logical expressions. |
| 89 | +[P46](logic/src/P46.scala) (**) Truth tables for logical expressions. |
90 | 90 |
|
91 | | -[P47](src/main/scala/logic/P47.scala) (*) Truth tables for logical expressions (2). |
| 91 | +[P47](logic/src/P47.scala) (*) Truth tables for logical expressions (2). |
92 | 92 |
|
93 | 93 | P48 (**) Truth tables for logical expressions (3). |
94 | 94 |
|
95 | | -[P49](src/main/scala/logic/P49.scala) (**) Gray code. |
| 95 | +[P49](logic/src/P49.scala) (**) Gray code. |
96 | 96 |
|
97 | | -[P50](src/main/scala/logic/P50.scala) (***) Huffman code. |
| 97 | +[P50](logic/src/P50.scala) (***) Huffman code. |
98 | 98 |
|
99 | 99 | ## Binary Trees |
100 | 100 |
|
101 | 101 | P54 Omitted; our tree representation will only allow well-formed trees. |
102 | 102 |
|
103 | | -[P55](src/main/scala/bintree/P55.scala) (**) Construct completely balanced binary trees. |
| 103 | +[P55](bintree/src/P55.scala) (**) Construct completely balanced binary trees. |
104 | 104 |
|
105 | | -[P56](src/main/scala/bintree/P56.scala) (**) Symmetric binary trees. |
| 105 | +[P56](bintree/src/P56.scala) (**) Symmetric binary trees. |
106 | 106 |
|
107 | | -[P57](src/main/scala/bintree/P57.scala) (**) Binary search trees (dictionaries). |
| 107 | +[P57](bintree/src/P57.scala) (**) Binary search trees (dictionaries). |
108 | 108 |
|
109 | | -[P58](src/main/scala/bintree/P58.scala) (**) Generate-and-test paradigm. |
| 109 | +[P58](bintree/src/P58.scala) (**) Generate-and-test paradigm. |
110 | 110 |
|
111 | | -[P59](src/main/scala/bintree/P59.scala) (**) Construct height-balanced binary trees. |
| 111 | +[P59](bintree/src/P59.scala) (**) Construct height-balanced binary trees. |
112 | 112 |
|
113 | | -P60 (**) Construct height-balanced binary trees with a given number of nodes. |
| 113 | +[P60](bintree/src/P60.scala) (**) Construct height-balanced binary trees with a given number of nodes. |
114 | 114 |
|
115 | | -P61 (*) Count the leaves of a binary tree. |
| 115 | +[P61](bintree/src/P61.scala) (*) Count the leaves of a binary tree. |
116 | 116 |
|
117 | | -P61A (*) Collect the leaves of a binary tree in a list. |
| 117 | +[P61A](bintree/P61A.scala) (*) Collect the leaves of a binary tree in a list. |
118 | 118 |
|
119 | | -P62 (*) Collect the internal nodes of a binary tree in a list. |
| 119 | +[P62](bintree/src/P62.scala) (*) Collect the internal nodes of a binary tree in a list. |
120 | 120 |
|
121 | | -P62B (*) Collect the nodes at a given level in a list. |
| 121 | +[P62B](bintree/P62B.scala) (*) Collect the nodes at a given level in a list. |
122 | 122 |
|
123 | | -P63 (**) Construct a complete binary tree. |
| 123 | +[P63](bintree/src/P63.scala) (**) Construct a complete binary tree. |
124 | 124 |
|
125 | | -P64 (**) Layout a binary tree (1). |
| 125 | +[P64](bintree/src/P64.scala) (**) Layout a binary tree (1). |
126 | 126 |
|
127 | | -P65 (**) Layout a binary tree (2). |
| 127 | +[P65](bintree/src/P65.scala) (**) Layout a binary tree (2). |
128 | 128 |
|
129 | 129 | P66 (***) Layout a binary tree (3). |
130 | 130 |
|
131 | | -P67 (**) A string representation of binary trees. |
| 131 | +[P67](bintree/src/P67.scala) (**) A string representation of binary trees. |
132 | 132 |
|
133 | | -P68 (**) Preorder and inorder sequences of binary trees. |
| 133 | +[P68](bintree/src/P68.scala) (**) Preorder and inorder sequences of binary trees. |
134 | 134 |
|
135 | | -P69 (**) Dotstring representation of binary trees. |
| 135 | +[P69](bintree/src/P69.scala) (**) Dotstring representation of binary trees. |
136 | 136 |
|
137 | 137 | ## Multiway Trees |
138 | 138 |
|
|
0 commit comments