diff --git a/d0/d04/qr__decompose_8h__incl.svg b/d0/d04/qr__decompose_8h__incl.svg index 6a6cbc3c8..cb76acd49 100644 --- a/d0/d04/qr__decompose_8h__incl.svg +++ b/d0/d04/qr__decompose_8h__incl.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1
-
14#include <array>
-
15#include <cassert>
-
16#include <cstdint>
-
17#include <iostream>
-
18
-
23namespace ciphers {
-
29namespace base64_encoding {
-
30// chars denoting the format for encoding and decoding array.
-
31// This array is already decided by
-
32// [RFC4648](https://tools.ietf.org/html/rfc4648#section-4) standard
-
33const std::string chars =
-
34 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
41std::string base64_encode(const std::string &input) {
-
42 std::string base64_string;
-
43 // base64 deals with 6-bit chars encoded as per chars, so
-
44 // we will always filter 6-bits from input.
-
45 for (uint32_t i = 0; i < input.size(); i += 3) {
-
46 char first_byte = input[i];
-
47 // Take first six bits of first character.
-
48 // Encode the first six bits with character defined in string `chars`
-
49 base64_string.push_back(chars[first_byte >> 2]);
-
50
-
51 if (i + 1 < input.size()) {
-
52 char second_byte = input[i + 1];
-
53 // Take remaining two bits of first character, and four first bits
-
54 // from second character Combine two numbers as 6-bit digits and
-
55 // encode by array chars (first two bits of first byte and next four
-
56 // of second byte)
-
57 base64_string.push_back(
-
58 chars[(((first_byte & 3) << 4) | ((second_byte & 0xF0) >> 4))]);
-
59
-
60 if (i + 2 < input.size()) {
-
61 char third_byte = input[i + 2];
-
62 // Take remaining four bits of second character, and first two
-
63 // bits from third character Combine two numbers as 6-bit digits
-
64 // and encode by array chars (remaining four bits of second byte
-
65 // and first two of third byte)
-
66 base64_string.push_back(chars[((third_byte & 0xC0) >> 6) |
-
67 ((second_byte & 0x0F) << 2)]);
-
68 // Encode remaining 6-bit of third byte by array chars
-
69 base64_string.push_back(chars[(third_byte & 0x3F)]);
-
70 } else {
-
71 // Take remaining four bits of second character as 6-bit number
-
72 base64_string.push_back(chars[((second_byte & 0x0F) << 2)]);
-
73 base64_string.push_back('='); // padding characters
-
74 }
-
75 } else {
-
76 // Take remaining two bits of first character as 6-bit number
-
77 base64_string.push_back(chars[((first_byte & 3) << 4)]);
+
14#include <cassert>
+
15#include <cstdint>
+
16#include <iostream>
+
17
+
22namespace ciphers {
+
28namespace base64_encoding {
+
29// chars denoting the format for encoding and decoding array.
+
30// This array is already decided by
+
31// [RFC4648](https://tools.ietf.org/html/rfc4648#section-4) standard
+
32const std::string chars =
+
33 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
40std::string base64_encode(const std::string &input) {
+
41 std::string base64_string;
+
42 // base64 deals with 6-bit chars encoded as per chars, so
+
43 // we will always filter 6-bits from input.
+
44 for (uint32_t i = 0; i < input.size(); i += 3) {
+
45 char first_byte = input[i];
+
46 // Take first six bits of first character.
+
47 // Encode the first six bits with character defined in string `chars`
+
48 base64_string.push_back(chars[first_byte >> 2]);
+
49
+
50 if (i + 1 < input.size()) {
+
51 char second_byte = input[i + 1];
+
52 // Take remaining two bits of first character, and four first bits
+
53 // from second character Combine two numbers as 6-bit digits and
+
54 // encode by array chars (first two bits of first byte and next four
+
55 // of second byte)
+
56 base64_string.push_back(
+
57 chars[(((first_byte & 3) << 4) | ((second_byte & 0xF0) >> 4))]);
+
58
+
59 if (i + 2 < input.size()) {
+
60 char third_byte = input[i + 2];
+
61 // Take remaining four bits of second character, and first two
+
62 // bits from third character Combine two numbers as 6-bit digits
+
63 // and encode by array chars (remaining four bits of second byte
+
64 // and first two of third byte)
+
65 base64_string.push_back(chars[((third_byte & 0xC0) >> 6) |
+
66 ((second_byte & 0x0F) << 2)]);
+
67 // Encode remaining 6-bit of third byte by array chars
+
68 base64_string.push_back(chars[(third_byte & 0x3F)]);
+
69 } else {
+
70 // Take remaining four bits of second character as 6-bit number
+
71 base64_string.push_back(chars[((second_byte & 0x0F) << 2)]);
+
72 base64_string.push_back('='); // padding characters
+
73 }
+
74 } else {
+
75 // Take remaining two bits of first character as 6-bit number
+
76 base64_string.push_back(chars[((first_byte & 3) << 4)]);
+
77 base64_string.push_back('='); // padding characters
78 base64_string.push_back('='); // padding characters
-
79 base64_string.push_back('='); // padding characters
-
80 }
-
81 }
-
82 return base64_string;
-
83}
-
91uint8_t find_idx(const char c) {
-
92 if (c >= 'A' && c <= 'Z') {
-
93 return c - 'A';
-
94 } else if (c >= 'a' && c <= 'z') {
-
95 return c - 'a' + 26;
-
96 } else if (c >= '0' && c <= '9') {
-
97 return c - '0' + 52;
-
98 } else if (c == '+') {
-
99 return 62;
-
100 } else if (c == '/') {
-
101 return 63;
-
102 }
-
103 return -1;
-
104}
-
111std::string base64_decode(const std::string &base64_str) {
-
112 std::string
-
113 base64_decoded;
-
114 for (uint32_t i = 0; i < base64_str.size(); i += 4) {
-
116 char first_byte = base64_str[i];
-
118 char second_byte = base64_str[i + 1];
-
119 // Actual str characters are of 8 bits (or 1 byte):
-
120 // :: 8 bits are decode by taking 6 bits from 1st byte of base64 string
-
121 // and first 2 bits from 2nd byte of base64 string.
-
122 char first_actual_byte = static_cast<char>(
-
123 (find_idx(first_byte) << 2) | ((find_idx(second_byte)) >> 4));
-
124 base64_decoded.push_back(first_actual_byte);
-
125 if (i + 2 < base64_str.size() && base64_str[i + 2] != '=') {
-
127 char third_byte = base64_str[i + 2];
-
128 // :: Next 8 bits are decode by taking remaining 4 bits from 2nd
-
129 // byte of base64 string and first 4 bits from 3rd byte of base64
-
130 // string.
-
131 char second_actual_byte =
-
132 static_cast<char>(((find_idx(second_byte) & 0x0F) << 4) |
-
133 (find_idx(third_byte) >> 2));
-
134 base64_decoded.push_back(second_actual_byte);
-
135
-
136 if (i + 3 < base64_str.size() && base64_str[i + 3] != '=') {
-
138 char fourth_byte = base64_str[i + 3];
-
139 // :: Taking remaining 2 bits from 3rd byte of base64 string
-
140 // and all 6 bits from 4th byte of base64 string.
-
141 char third_actual_byte =
-
142 static_cast<char>(((find_idx(third_byte) & 0x03) << 6) |
-
143 find_idx(fourth_byte));
-
144 base64_decoded.push_back(third_actual_byte);
-
145 }
-
146 }
-
147 }
-
148 return base64_decoded;
-
149}
-
150} // namespace base64_encoding
-
151} // namespace ciphers
-
152
-
157static void test() {
-
158 // 1st Test
-
159 std::string str =
-
160 "To err is human, but to really foul things up you need a computer.";
-
161 std::string base64_str = ciphers::base64_encoding::base64_encode(str);
-
162 std::string verify =
-
163 "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZW"
-
164 "VkIGEgY29tcHV0ZXIu";
-
165 // verify encoding
-
166 assert(base64_str == verify);
-
167 std::string original_str =
-
168 ciphers::base64_encoding::base64_decode(base64_str);
-
169 // verify decoding
-
170 assert(original_str == str);
-
171
-
172 // 2nd Test from [Wikipedia](https://en.wikipedia.org/wiki/Base64)
-
173 str =
-
174 "Man is distinguished, not only by his reason, but by this singular "
-
175 "passion from other animals, which is a lust of the mind, that by a "
-
176 "perseverance of delight in the continued and indefatigable generation "
-
177 "of knowledge, exceeds the short vehemence of any carnal pleasure.";
-
178
-
179 base64_str = ciphers::base64_encoding::base64_encode(str);
-
180 verify =
-
181 "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS"
-
182 "B0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBh"
-
183 "IGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodC"
-
184 "BpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25v"
-
185 "d2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbG"
-
186 "Vhc3VyZS4=";
-
187 // verify encoding
-
188 assert(base64_str == verify);
-
189 original_str = ciphers::base64_encoding::base64_decode(base64_str);
-
190 // verify decoding
-
191 assert(original_str == str);
-
192}
-
193
-
198int main() {
-
199 test(); // run self-test implementations
-
200 return 0;
-
201}
+
79 }
+
80 }
+
81 return base64_string;
+
82}
+
90uint8_t find_idx(const char c) {
+
91 if (c >= 'A' && c <= 'Z') {
+
92 return c - 'A';
+
93 } else if (c >= 'a' && c <= 'z') {
+
94 return c - 'a' + 26;
+
95 } else if (c >= '0' && c <= '9') {
+
96 return c - '0' + 52;
+
97 } else if (c == '+') {
+
98 return 62;
+
99 } else if (c == '/') {
+
100 return 63;
+
101 }
+
102 return -1;
+
103}
+
110std::string base64_decode(const std::string &base64_str) {
+
111 std::string
+
112 base64_decoded;
+
113 for (uint32_t i = 0; i < base64_str.size(); i += 4) {
+
115 char first_byte = base64_str[i];
+
117 char second_byte = base64_str[i + 1];
+
118 // Actual str characters are of 8 bits (or 1 byte):
+
119 // :: 8 bits are decode by taking 6 bits from 1st byte of base64 string
+
120 // and first 2 bits from 2nd byte of base64 string.
+
121 char first_actual_byte = static_cast<char>(
+
122 (find_idx(first_byte) << 2) | ((find_idx(second_byte)) >> 4));
+
123 base64_decoded.push_back(first_actual_byte);
+
124 if (i + 2 < base64_str.size() && base64_str[i + 2] != '=') {
+
126 char third_byte = base64_str[i + 2];
+
127 // :: Next 8 bits are decode by taking remaining 4 bits from 2nd
+
128 // byte of base64 string and first 4 bits from 3rd byte of base64
+
129 // string.
+
130 char second_actual_byte =
+
131 static_cast<char>(((find_idx(second_byte) & 0x0F) << 4) |
+
132 (find_idx(third_byte) >> 2));
+
133 base64_decoded.push_back(second_actual_byte);
+
134
+
135 if (i + 3 < base64_str.size() && base64_str[i + 3] != '=') {
+
137 char fourth_byte = base64_str[i + 3];
+
138 // :: Taking remaining 2 bits from 3rd byte of base64 string
+
139 // and all 6 bits from 4th byte of base64 string.
+
140 char third_actual_byte =
+
141 static_cast<char>(((find_idx(third_byte) & 0x03) << 6) |
+
142 find_idx(fourth_byte));
+
143 base64_decoded.push_back(third_actual_byte);
+
144 }
+
145 }
+
146 }
+
147 return base64_decoded;
+
148}
+
149} // namespace base64_encoding
+
150} // namespace ciphers
+
151
+
156static void test() {
+
157 // 1st Test
+
158 std::string str =
+
159 "To err is human, but to really foul things up you need a computer.";
+
160 std::string base64_str = ciphers::base64_encoding::base64_encode(str);
+
161 std::string verify =
+
162 "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZW"
+
163 "VkIGEgY29tcHV0ZXIu";
+
164 // verify encoding
+
165 assert(base64_str == verify);
+
166 std::string original_str =
+
167 ciphers::base64_encoding::base64_decode(base64_str);
+
168 // verify decoding
+
169 assert(original_str == str);
+
170
+
171 // 2nd Test from [Wikipedia](https://en.wikipedia.org/wiki/Base64)
+
172 str =
+
173 "Man is distinguished, not only by his reason, but by this singular "
+
174 "passion from other animals, which is a lust of the mind, that by a "
+
175 "perseverance of delight in the continued and indefatigable generation "
+
176 "of knowledge, exceeds the short vehemence of any carnal pleasure.";
+
177
+
178 base64_str = ciphers::base64_encoding::base64_encode(str);
+
179 verify =
+
180 "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS"
+
181 "B0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBh"
+
182 "IGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodC"
+
183 "BpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25v"
+
184 "d2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbG"
+
185 "Vhc3VyZS4=";
+
186 // verify encoding
+
187 assert(base64_str == verify);
+
188 original_str = ciphers::base64_encoding::base64_decode(base64_str);
+
189 // verify decoding
+
190 assert(original_str == str);
+
191}
+
192
+
197int main() {
+
198 test(); // run self-test implementations
+
199 return 0;
+
200}
static void test()
Self-test implementations.
int main()
Main function.
Functions for Base64 Encoding and Decoding implementation.
diff --git a/d1/d1d/pascal__triangle_8cpp__incl.svg b/d1/d1d/pascal__triangle_8cpp__incl.svg index 7375e64b4..730caaece 100644 --- a/d1/d1d/pascal__triangle_8cpp__incl.svg +++ b/d1/d1d/pascal__triangle_8cpp__incl.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph_org.svg b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph_org.svg index 19743610e..a15d67906 100644 --- a/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph_org.svg +++ b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - diff --git a/d1/dda/structdata__structures_1_1trie__using__hashmap_1_1_trie_1_1_node__coll__graph_org.svg b/d1/dda/structdata__structures_1_1trie__using__hashmap_1_1_trie_1_1_node__coll__graph_org.svg index f95bdc2df..ce607d219 100644 --- a/d1/dda/structdata__structures_1_1trie__using__hashmap_1_1_trie_1_1_node__coll__graph_org.svg +++ b/d1/dda/structdata__structures_1_1trie__using__hashmap_1_1_trie_1_1_node__coll__graph_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - diff --git a/d2/d23/neural__network_8cpp__incl_org.svg b/d2/d23/neural__network_8cpp__incl_org.svg index bd158c980..ad75026af 100644 --- a/d2/d23/neural__network_8cpp__incl_org.svg +++ b/d2/d23/neural__network_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - diff --git a/d2/d4b/spirograph_8cpp__incl_org.svg b/d2/d4b/spirograph_8cpp__incl_org.svg index 9ea8b3090..4941ae7d9 100644 --- a/d2/d4b/spirograph_8cpp__incl_org.svg +++ b/d2/d4b/spirograph_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/d2/dba/non__preemptive__sjf__scheduling_8cpp__incl_org.svg b/d2/dba/non__preemptive__sjf__scheduling_8cpp__incl_org.svg index 422ff6cd1..ceda8b70e 100644 --- a/d2/dba/non__preemptive__sjf__scheduling_8cpp__incl_org.svg +++ b/d2/dba/non__preemptive__sjf__scheduling_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - diff --git a/d3/d1a/hill__cipher_8cpp__incl_org.svg b/d3/d1a/hill__cipher_8cpp__incl_org.svg index a88a83066..1cd0d45ca 100644 --- a/d3/d1a/hill__cipher_8cpp__incl_org.svg +++ b/d3/d1a/hill__cipher_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - diff --git a/d3/d4c/sha1_8cpp__incl_org.svg b/d3/d4c/sha1_8cpp__incl_org.svg index b4d3fc5f0..b6620d4fb 100644 --- a/d3/d4c/sha1_8cpp__incl_org.svg +++ b/d3/d4c/sha1_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - This is an implementation of a recursive version of the Bubble sort algorithm More...

#include <algorithm>
-#include <array>
#include <cassert>
#include <cstdint>
#include <iostream>
@@ -128,7 +127,7 @@ $(function(){initNavTree('d3/df9/recursive__bubble__sort_8cpp.html','../../','')
Include dependency graph for recursive_bubble_sort.cpp:
-
+

Go to the source code of this file.

@@ -184,12 +183,12 @@ Algorithm

Main function.

Returns
0 on exit
-

Definition at line 155 of file recursive_bubble_sort.cpp.

-
155 {
-
156 test(); // run self-test implementations
-
157 return 0;
-
158}
-
static void test()
Self-test implementations.
+

Definition at line 154 of file recursive_bubble_sort.cpp.

+
154 {
+
155 test(); // run self-test implementations
+
156 return 0;
+
157}
+
static void test()
Self-test implementations.
@@ -219,53 +218,53 @@ Algorithm

Self-test implementations.

Returns
void
-

Definition at line 105 of file recursive_bubble_sort.cpp.

-
105 {
-
106 // 1st example. Creating an array of type `int`.
-
107 std::cout << "1st test using `int`\n";
-
108 const uint64_t size = 6;
-
109 std::vector<int64_t> arr;
-
110 // populating the array
-
111 arr.push_back(22);
-
112 arr.push_back(46);
-
113 arr.push_back(94);
-
114 arr.push_back(12);
-
115 arr.push_back(37);
-
116 arr.push_back(63);
-
117 // array populating ends
-
118
- -
120 assert(std::is_sorted(std::begin(arr), std::end(arr)));
-
121 std::cout << " 1st test passed!\n";
-
122 // printing the array
-
123 for (uint64_t i = 0; i < size; i++) {
-
124 std::cout << arr[i] << ", ";
-
125 }
-
126 std::cout << std::endl;
-
127
-
128 // 2nd example. Creating an array of type `double`.
-
129 std::cout << "2nd test using doubles\n";
-
130 std::vector<double> double_arr;
-
131
-
132 // populating the array
-
133 double_arr.push_back(20.4);
-
134 double_arr.push_back(62.7);
-
135 double_arr.push_back(12.2);
-
136 double_arr.push_back(43.6);
-
137 double_arr.push_back(74.1);
-
138 double_arr.push_back(57.9);
-
139 // array populating ends
-
140
-
141 sorting::recursive_bubble_sort(&double_arr, size);
-
142 assert(std::is_sorted(std::begin(double_arr), std::end(double_arr)));
-
143 std::cout << " 2nd test passed!\n";
-
144 // printing the array
-
145 for (uint64_t i = 0; i < size; i++) {
-
146 std::cout << double_arr[i] << ", ";
-
147 }
-
148 std::cout << std::endl;
-
149}
-
void recursive_bubble_sort(std::vector< T > *nums, uint64_t n)
This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is t...
+

Definition at line 104 of file recursive_bubble_sort.cpp.

+
104 {
+
105 // 1st example. Creating an array of type `int`.
+
106 std::cout << "1st test using `int`\n";
+
107 const uint64_t size = 6;
+
108 std::vector<int64_t> arr;
+
109 // populating the array
+
110 arr.push_back(22);
+
111 arr.push_back(46);
+
112 arr.push_back(94);
+
113 arr.push_back(12);
+
114 arr.push_back(37);
+
115 arr.push_back(63);
+
116 // array populating ends
+
117
+ +
119 assert(std::is_sorted(std::begin(arr), std::end(arr)));
+
120 std::cout << " 1st test passed!\n";
+
121 // printing the array
+
122 for (uint64_t i = 0; i < size; i++) {
+
123 std::cout << arr[i] << ", ";
+
124 }
+
125 std::cout << std::endl;
+
126
+
127 // 2nd example. Creating an array of type `double`.
+
128 std::cout << "2nd test using doubles\n";
+
129 std::vector<double> double_arr;
+
130
+
131 // populating the array
+
132 double_arr.push_back(20.4);
+
133 double_arr.push_back(62.7);
+
134 double_arr.push_back(12.2);
+
135 double_arr.push_back(43.6);
+
136 double_arr.push_back(74.1);
+
137 double_arr.push_back(57.9);
+
138 // array populating ends
+
139
+
140 sorting::recursive_bubble_sort(&double_arr, size);
+
141 assert(std::is_sorted(std::begin(double_arr), std::end(double_arr)));
+
142 std::cout << " 2nd test passed!\n";
+
143 // printing the array
+
144 for (uint64_t i = 0; i < size; i++) {
+
145 std::cout << double_arr[i] << ", ";
+
146 }
+
147 std::cout << std::endl;
+
148}
+
void recursive_bubble_sort(std::vector< T > *nums, uint64_t n)
This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is t...
diff --git a/d3/df9/recursive__bubble__sort_8cpp_source.html b/d3/df9/recursive__bubble__sort_8cpp_source.html index ff2b797b0..eedb1178f 100644 --- a/d3/df9/recursive__bubble__sort_8cpp_source.html +++ b/d3/df9/recursive__bubble__sort_8cpp_source.html @@ -119,90 +119,89 @@ $(function(){initNavTree('d3/df9/recursive__bubble__sort_8cpp_source.html','../. Go to the documentation of this file.
1
59
60#include <algorithm>
-
61#include <array>
-
62#include <cassert>
-
63#include <cstdint>
-
64#include <iostream>
-
65#include <vector>
-
66
-
71namespace sorting {
-
72
-
83template <typename T>
-
-
84void recursive_bubble_sort(std::vector<T> *nums, uint64_t n) {
-
85 if (n == 1) {
-
86 return;
-
87 }
-
88
-
89 for (uint64_t i = 0; i < n - 1; i++) {
-
91 if ((*nums)[i] > (*nums)[i + 1]) {
-
92 std::swap((*nums)[i], (*nums)[i + 1]);
-
93 }
-
94 }
-
95
-
97 recursive_bubble_sort(nums, n - 1);
-
98}
+
61#include <cassert>
+
62#include <cstdint>
+
63#include <iostream>
+
64#include <vector>
+
65
+
70namespace sorting {
+
71
+
82template <typename T>
+
+
83void recursive_bubble_sort(std::vector<T> *nums, uint64_t n) {
+
84 if (n == 1) {
+
85 return;
+
86 }
+
87
+
88 for (uint64_t i = 0; i < n - 1; i++) {
+
90 if ((*nums)[i] > (*nums)[i + 1]) {
+
91 std::swap((*nums)[i], (*nums)[i + 1]);
+
92 }
+
93 }
+
94
+
96 recursive_bubble_sort(nums, n - 1);
+
97}
-
99} // namespace sorting
-
100
-
-
105static void test() {
-
106 // 1st example. Creating an array of type `int`.
-
107 std::cout << "1st test using `int`\n";
-
108 const uint64_t size = 6;
-
109 std::vector<int64_t> arr;
-
110 // populating the array
-
111 arr.push_back(22);
-
112 arr.push_back(46);
-
113 arr.push_back(94);
-
114 arr.push_back(12);
-
115 arr.push_back(37);
-
116 arr.push_back(63);
-
117 // array populating ends
-
118
- -
120 assert(std::is_sorted(std::begin(arr), std::end(arr)));
-
121 std::cout << " 1st test passed!\n";
-
122 // printing the array
-
123 for (uint64_t i = 0; i < size; i++) {
-
124 std::cout << arr[i] << ", ";
-
125 }
-
126 std::cout << std::endl;
-
127
-
128 // 2nd example. Creating an array of type `double`.
-
129 std::cout << "2nd test using doubles\n";
-
130 std::vector<double> double_arr;
-
131
-
132 // populating the array
-
133 double_arr.push_back(20.4);
-
134 double_arr.push_back(62.7);
-
135 double_arr.push_back(12.2);
-
136 double_arr.push_back(43.6);
-
137 double_arr.push_back(74.1);
-
138 double_arr.push_back(57.9);
-
139 // array populating ends
-
140
-
141 sorting::recursive_bubble_sort(&double_arr, size);
-
142 assert(std::is_sorted(std::begin(double_arr), std::end(double_arr)));
-
143 std::cout << " 2nd test passed!\n";
-
144 // printing the array
-
145 for (uint64_t i = 0; i < size; i++) {
-
146 std::cout << double_arr[i] << ", ";
-
147 }
-
148 std::cout << std::endl;
-
149}
+
98} // namespace sorting
+
99
+
+
104static void test() {
+
105 // 1st example. Creating an array of type `int`.
+
106 std::cout << "1st test using `int`\n";
+
107 const uint64_t size = 6;
+
108 std::vector<int64_t> arr;
+
109 // populating the array
+
110 arr.push_back(22);
+
111 arr.push_back(46);
+
112 arr.push_back(94);
+
113 arr.push_back(12);
+
114 arr.push_back(37);
+
115 arr.push_back(63);
+
116 // array populating ends
+
117
+ +
119 assert(std::is_sorted(std::begin(arr), std::end(arr)));
+
120 std::cout << " 1st test passed!\n";
+
121 // printing the array
+
122 for (uint64_t i = 0; i < size; i++) {
+
123 std::cout << arr[i] << ", ";
+
124 }
+
125 std::cout << std::endl;
+
126
+
127 // 2nd example. Creating an array of type `double`.
+
128 std::cout << "2nd test using doubles\n";
+
129 std::vector<double> double_arr;
+
130
+
131 // populating the array
+
132 double_arr.push_back(20.4);
+
133 double_arr.push_back(62.7);
+
134 double_arr.push_back(12.2);
+
135 double_arr.push_back(43.6);
+
136 double_arr.push_back(74.1);
+
137 double_arr.push_back(57.9);
+
138 // array populating ends
+
139
+
140 sorting::recursive_bubble_sort(&double_arr, size);
+
141 assert(std::is_sorted(std::begin(double_arr), std::end(double_arr)));
+
142 std::cout << " 2nd test passed!\n";
+
143 // printing the array
+
144 for (uint64_t i = 0; i < size; i++) {
+
145 std::cout << double_arr[i] << ", ";
+
146 }
+
147 std::cout << std::endl;
+
148}
-
150
-
-
155int main() {
-
156 test(); // run self-test implementations
-
157 return 0;
-
158}
+
149
+
+
154int main() {
+
155 test(); // run self-test implementations
+
156 return 0;
+
157}
for working with vectors
-
void recursive_bubble_sort(std::vector< T > *nums, uint64_t n)
This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is t...
-
static void test()
Self-test implementations.
-
int main()
Main function.
+
void recursive_bubble_sort(std::vector< T > *nums, uint64_t n)
This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is t...
+
static void test()
Self-test implementations.
+
int main()
Main function.
diff --git a/d3/dfd/trie__using__hashmap_8cpp__incl.svg b/d3/dfd/trie__using__hashmap_8cpp__incl.svg index fddaee8b7..94c87372c 100644 --- a/d3/dfd/trie__using__hashmap_8cpp__incl.svg +++ b/d3/dfd/trie__using__hashmap_8cpp__incl.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - diff --git a/d4/d26/durand__kerner__roots_8cpp__incl_org.svg b/d4/d26/durand__kerner__roots_8cpp__incl_org.svg index 49ffa5936..2a91de311 100644 --- a/d4/d26/durand__kerner__roots_8cpp__incl_org.svg +++ b/d4/d26/durand__kerner__roots_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - diff --git a/d4/d2f/fcfs__scheduling_8cpp__incl_org.svg b/d4/d2f/fcfs__scheduling_8cpp__incl_org.svg index 5bae84638..c24a21aee 100644 --- a/d4/d2f/fcfs__scheduling_8cpp__incl_org.svg +++ b/d4/d2f/fcfs__scheduling_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - diff --git a/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph_org.svg b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph_org.svg index 2e96c31ae..9ab29ecde 100644 --- a/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph_org.svg +++ b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph_org.svg @@ -1,7 +1,7 @@ - - - - - - diff --git a/d4/d60/kohonen__som__trace_8cpp__incl_org.svg b/d4/d60/kohonen__som__trace_8cpp__incl_org.svg index 66eecdc47..a603e1b7b 100644 --- a/d4/d60/kohonen__som__trace_8cpp__incl_org.svg +++ b/d4/d60/kohonen__som__trace_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Sorting algorithms

for std::is_sorted(), std::swap() for std::array for assert for initializing random number generator for IO operations

Sorting algorithms

-

for std::is_sorted for std::array for IO operations for std::vector

+

for std::is_sorted for IO operations for std::vector

Sorting algorithms

for std::is_sorted for IO operations for std::vector

for std::is_sorted for assert for std::swap and io operations

@@ -1127,21 +1127,21 @@ template<typename T>

< iterating over the entire array

< if a larger number appears before the smaller one, swap them.

-

Definition at line 84 of file recursive_bubble_sort.cpp.

-
84 {
-
85 if (n == 1) {
-
86 return;
-
87 }
-
88
-
89 for (uint64_t i = 0; i < n - 1; i++) {
-
91 if ((*nums)[i] > (*nums)[i + 1]) {
-
92 std::swap((*nums)[i], (*nums)[i + 1]);
-
93 }
-
94 }
-
95
-
97 recursive_bubble_sort(nums, n - 1);
-
98}
-
void recursive_bubble_sort(std::vector< T > *nums, uint64_t n)
This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is t...
+

Definition at line 83 of file recursive_bubble_sort.cpp.

+
83 {
+
84 if (n == 1) {
+
85 return;
+
86 }
+
87
+
88 for (uint64_t i = 0; i < n - 1; i++) {
+
90 if ((*nums)[i] > (*nums)[i + 1]) {
+
91 std::swap((*nums)[i], (*nums)[i + 1]);
+
92 }
+
93 }
+
94
+
96 recursive_bubble_sort(nums, n - 1);
+
97}
+
void recursive_bubble_sort(std::vector< T > *nums, uint64_t n)
This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is t...
diff --git a/d5/d95/binary__addition_8cpp__incl.svg b/d5/d95/binary__addition_8cpp__incl.svg index 21b89d457..b4272a000 100644 --- a/d5/d95/binary__addition_8cpp__incl.svg +++ b/d5/d95/binary__addition_8cpp__incl.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - diff --git a/d5/dcd/kohonen__som__topology_8cpp__incl_org.svg b/d5/dcd/kohonen__som__topology_8cpp__incl_org.svg index 319ab821d..b18f59301 100644 --- a/d5/dcd/kohonen__som__topology_8cpp__incl_org.svg +++ b/d5/dcd/kohonen__som__topology_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/d6/d47/classrange__queries_1_1per_seg_tree__coll__graph_org.svg b/d6/d47/classrange__queries_1_1per_seg_tree__coll__graph_org.svg index 3c07b5967..83a53984e 100644 --- a/d6/d47/classrange__queries_1_1per_seg_tree__coll__graph_org.svg +++ b/d6/d47/classrange__queries_1_1per_seg_tree__coll__graph_org.svg @@ -1,7 +1,7 @@ - - - - -

for std::transform and std::replace for assert for uint8_t for IO operations for std::map for std::stringstream for std::string for std::vector

for assert for IO operations for std::map

Algorithms for encryption and decryption

-

In programming, Base64 is a group of binary-to-text encoding schemes that represent binary data (more specifically, a sequence of 8-bit bytes) in an ASCII string format by translating the data into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding. Each non-final Base64 digit represents exactly 6 bits of data. Three 8-bit bytes (i.e., a total of 24 bits) can therefore be represented by four 6-bit Base64 digits.

Author
Ashish Daulatabad for std::array for assert operations for IO operations
+

In programming, Base64 is a group of binary-to-text encoding schemes that represent binary data (more specifically, a sequence of 8-bit bytes) in an ASCII string format by translating the data into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding. Each non-final Base64 digit represents exactly 6 bits of data. Three 8-bit bytes (i.e., a total of 24 bits) can therefore be represented by four 6-bit Base64 digits.

Author
Ashish Daulatabad for assert operations for IO operations

Cipher algorithms

for assert for 256-bit integer

Cipher algorithms

diff --git a/d6/d5c/travelling__salesman__problem_8cpp__incl.svg b/d6/d5c/travelling__salesman__problem_8cpp__incl.svg index 5f43a8fd1..0759f4783 100644 --- a/d6/d5c/travelling__salesman__problem_8cpp__incl.svg +++ b/d6/d5c/travelling__salesman__problem_8cpp__incl.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/d7/da7/adaline__learning_8cpp__incl_org.svg b/d7/da7/adaline__learning_8cpp__incl_org.svg index 86e501405..53a8bf2cc 100644 --- a/d7/da7/adaline__learning_8cpp__incl_org.svg +++ b/d7/da7/adaline__learning_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/d8/dc0/heavy__light__decomposition_8cpp__incl_org.svg b/d8/dc0/heavy__light__decomposition_8cpp__incl_org.svg index 01b6481c4..f53dac040 100644 --- a/d8/dc0/heavy__light__decomposition_8cpp__incl_org.svg +++ b/d8/dc0/heavy__light__decomposition_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - + - - - - - - - - - - - + + + + + + + + + diff --git a/d9/d31/recursive__bubble__sort_8cpp__incl.md5 b/d9/d31/recursive__bubble__sort_8cpp__incl.md5 index 2d413e497..1c5062e15 100644 --- a/d9/d31/recursive__bubble__sort_8cpp__incl.md5 +++ b/d9/d31/recursive__bubble__sort_8cpp__incl.md5 @@ -1 +1 @@ -a34d55f409021b818979a1fe196f30b2 \ No newline at end of file +ece42388bbc490cf68c1e111af58e328 \ No newline at end of file diff --git a/d9/d31/recursive__bubble__sort_8cpp__incl.svg b/d9/d31/recursive__bubble__sort_8cpp__incl.svg index 5b8c73cbd..1ec41c646 100644 --- a/d9/d31/recursive__bubble__sort_8cpp__incl.svg +++ b/d9/d31/recursive__bubble__sort_8cpp__incl.svg @@ -1,11 +1,11 @@ - - + @@ -23,9 +23,9 @@ Node1 - -sorting/recursive_bubble -_sort.cpp + +sorting/recursive_bubble +_sort.cpp @@ -42,8 +42,8 @@ Node1->Node2 - - + + @@ -51,8 +51,8 @@ Node3 - -array + +cassert @@ -60,8 +60,8 @@ Node1->Node3 - - + + @@ -69,8 +69,8 @@ Node4 - -cassert + +cstdint @@ -78,8 +78,8 @@ Node1->Node4 - - + + @@ -87,8 +87,8 @@ Node5 - -cstdint + +iostream @@ -96,8 +96,8 @@ Node1->Node5 - - + + @@ -105,8 +105,8 @@ Node6 - -iostream + +vector @@ -114,26 +114,8 @@ Node1->Node6 - - - - - - - -Node7 - - -vector - - - - - -Node1->Node7 - - - + + diff --git a/d9/d31/recursive__bubble__sort_8cpp__incl_org.svg b/d9/d31/recursive__bubble__sort_8cpp__incl_org.svg index 3d47889b1..8b847aa92 100644 --- a/d9/d31/recursive__bubble__sort_8cpp__incl_org.svg +++ b/d9/d31/recursive__bubble__sort_8cpp__incl_org.svg @@ -1,20 +1,20 @@ - - + sorting/recursive_bubble_sort.cpp Node1 - -sorting/recursive_bubble -_sort.cpp + +sorting/recursive_bubble +_sort.cpp @@ -31,8 +31,8 @@ Node1->Node2 - - + + @@ -40,8 +40,8 @@ Node3 - -array + +cassert @@ -49,8 +49,8 @@ Node1->Node3 - - + + @@ -58,8 +58,8 @@ Node4 - -cassert + +cstdint @@ -67,8 +67,8 @@ Node1->Node4 - - + + @@ -76,8 +76,8 @@ Node5 - -cstdint + +iostream @@ -85,8 +85,8 @@ Node1->Node5 - - + + @@ -94,8 +94,8 @@ Node6 - -iostream + +vector @@ -103,26 +103,8 @@ Node1->Node6 - - - - - - - -Node7 - - -vector - - - - - -Node1->Node7 - - - + + diff --git a/d9/d33/quick__sort__iterative_8cpp__incl.svg b/d9/d33/quick__sort__iterative_8cpp__incl.svg index c8a989c3e..aabda8c84 100644 --- a/d9/d33/quick__sort__iterative_8cpp__incl.svg +++ b/d9/d33/quick__sort__iterative_8cpp__incl.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/da/d32/classdata__structures_1_1trie__using__hashmap_1_1_trie__coll__graph_org.svg b/da/d32/classdata__structures_1_1trie__using__hashmap_1_1_trie__coll__graph_org.svg index 70de97eea..91ddb3c70 100644 --- a/da/d32/classdata__structures_1_1trie__using__hashmap_1_1_trie__coll__graph_org.svg +++ b/da/d32/classdata__structures_1_1trie__using__hashmap_1_1_trie__coll__graph_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dc/dd2/sha256_8cpp__incl_org.svg b/dc/dd2/sha256_8cpp__incl_org.svg index 62946ec46..877840ba4 100644 --- a/dc/dd2/sha256_8cpp__incl_org.svg +++ b/dc/dd2/sha256_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - diff --git a/dc/dd9/classrange__queries_1_1heavy__light__decomposition_1_1_h_l_d__coll__graph_org.svg b/dc/dd9/classrange__queries_1_1heavy__light__decomposition_1_1_h_l_d__coll__graph_org.svg index 265fee3ee..6d42b3575 100644 --- a/dc/dd9/classrange__queries_1_1heavy__light__decomposition_1_1_h_l_d__coll__graph_org.svg +++ b/dc/dd9/classrange__queries_1_1heavy__light__decomposition_1_1_h_l_d__coll__graph_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - diff --git a/dd/d0f/md5_8cpp__incl_org.svg b/dd/d0f/md5_8cpp__incl_org.svg index 9b6b1889b..502874592 100644 --- a/dd/d0f/md5_8cpp__incl_org.svg +++ b/dd/d0f/md5_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/df/dd6/a1z26__cipher_8cpp__incl_org.svg b/df/dd6/a1z26__cipher_8cpp__incl_org.svg index 7563407a5..6e7d94b0b 100644 --- a/df/dd6/a1z26__cipher_8cpp__incl_org.svg +++ b/df/dd6/a1z26__cipher_8cpp__incl_org.svg @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -