csemod 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- csemod-0.0.2/PKG-INFO +24 -0
- csemod-0.0.2/README.md +3 -0
- csemod-0.0.2/csemod/__init__.py +3 -0
- csemod-0.0.2/csemod/content.py +834 -0
- csemod-0.0.2/csemod/main.py +15 -0
- csemod-0.0.2/csemod.egg-info/PKG-INFO +24 -0
- csemod-0.0.2/csemod.egg-info/SOURCES.txt +11 -0
- csemod-0.0.2/csemod.egg-info/dependency_links.txt +1 -0
- csemod-0.0.2/csemod.egg-info/requires.txt +1 -0
- csemod-0.0.2/csemod.egg-info/top_level.txt +1 -0
- csemod-0.0.2/setup.cfg +24 -0
- csemod-0.0.2/setup.py +28 -0
csemod-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: csemod
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Personal Project - Education Purpose Only
|
|
5
|
+
Author: BonzoDon
|
|
6
|
+
License: CC0-1.0
|
|
7
|
+
Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.6
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: pyperclip
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: classifier
|
|
15
|
+
Dynamic: description
|
|
16
|
+
Dynamic: description-content-type
|
|
17
|
+
Dynamic: license
|
|
18
|
+
Dynamic: requires-dist
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
Dynamic: summary
|
|
21
|
+
|
|
22
|
+
# CSEMOD
|
|
23
|
+
|
|
24
|
+
Personal Project - Education Purpose Only
|
csemod-0.0.2/README.md
ADDED
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
insert_element = """
|
|
2
|
+
#include <iostream>
|
|
3
|
+
using namespace std;
|
|
4
|
+
|
|
5
|
+
int main() {
|
|
6
|
+
int arr[100];
|
|
7
|
+
int size, pos, value;
|
|
8
|
+
|
|
9
|
+
cout << "Size of Array: ";
|
|
10
|
+
cin >> size;
|
|
11
|
+
|
|
12
|
+
cout << "Enter the elements: " << endl;
|
|
13
|
+
for (int i = 0; i < size; i++) {
|
|
14
|
+
cin >> arr[i];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
cout << "Enter the element to insert: ";
|
|
18
|
+
cin >> value;
|
|
19
|
+
cout << "Enter the position to insert: ";
|
|
20
|
+
cin >> pos;
|
|
21
|
+
|
|
22
|
+
if (pos<0 || pos>size){
|
|
23
|
+
cout << "Invalid position!" << endl;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
for (int i = size; i > pos; i--){
|
|
27
|
+
arr[i] = arr[i - 1];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
arr[pos] = value;
|
|
31
|
+
size++;
|
|
32
|
+
cout << "Array after insertion: " << endl;
|
|
33
|
+
for (int i = 0; i < size; i++) {
|
|
34
|
+
cout << arr[i] << " ";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
delete_element = """
|
|
43
|
+
#include <iostream>
|
|
44
|
+
using namespace std;
|
|
45
|
+
|
|
46
|
+
int main() {
|
|
47
|
+
int arr[100];
|
|
48
|
+
int size, pos;
|
|
49
|
+
|
|
50
|
+
cout << "Size of Array: ";
|
|
51
|
+
cin >> size;
|
|
52
|
+
|
|
53
|
+
cout << "Enter the elements: " << endl;
|
|
54
|
+
for (int i = 0; i < size; i++) {
|
|
55
|
+
cin >> arr[i];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
cout << "Enter the position: ";
|
|
59
|
+
cin >> pos;
|
|
60
|
+
|
|
61
|
+
if (pos <0 || pos >=size) {
|
|
62
|
+
cout << "Invalid position!" << endl;
|
|
63
|
+
} else {
|
|
64
|
+
for (int i = pos; i < size - 1; i++) {
|
|
65
|
+
arr[i] = arr[i + 1];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
size--;
|
|
69
|
+
cout << "Array after deletion: " << endl;
|
|
70
|
+
for (int i = 0; i < size; i++) {
|
|
71
|
+
cout << arr[i] << " ";
|
|
72
|
+
}
|
|
73
|
+
cout << endl;
|
|
74
|
+
}
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
"""
|
|
78
|
+
linear_search = """
|
|
79
|
+
#include <iostream>
|
|
80
|
+
using namespace std;
|
|
81
|
+
|
|
82
|
+
int main() {
|
|
83
|
+
int arr[100];
|
|
84
|
+
int size, value;
|
|
85
|
+
int loc = -1;
|
|
86
|
+
|
|
87
|
+
cout << "Enter the size of array: ";
|
|
88
|
+
cin >> size;
|
|
89
|
+
|
|
90
|
+
cout << "Enter elements: " << endl;
|
|
91
|
+
for (int i = 0; i < size; i++) {
|
|
92
|
+
cin >> arr[i];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
cout << "Enter the element to find: ";
|
|
96
|
+
cin >> value;
|
|
97
|
+
|
|
98
|
+
for (int i = 0; i < size; i++) {
|
|
99
|
+
if (arr[i] == value) {
|
|
100
|
+
loc = i;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (loc != -1) {
|
|
106
|
+
cout << "Element " << value << " found at position: " << loc << endl;
|
|
107
|
+
} else {
|
|
108
|
+
cout << "Element " << value << " not found." << endl;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
bubble_sort_asc = """
|
|
116
|
+
#include <iostream>
|
|
117
|
+
using namespace std;
|
|
118
|
+
|
|
119
|
+
int main() {
|
|
120
|
+
int arr[100];
|
|
121
|
+
int size;
|
|
122
|
+
|
|
123
|
+
cout << "Enter the size of the array: ";
|
|
124
|
+
cin >> size;
|
|
125
|
+
|
|
126
|
+
cout << "Enter " << size << " elements: " " << endl;
|
|
127
|
+
for (int i = 0; i < size; i++) {
|
|
128
|
+
cin >> arr[i];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
for (int i = 0; i < size - 1; i++){
|
|
132
|
+
for (int j = 0; j < size - i - 1; j++) {
|
|
133
|
+
if (arr[j] > arr[j + 1]) { // use < for descending order
|
|
134
|
+
int temp = arr[j];
|
|
135
|
+
arr[j] = arr[j + 1];
|
|
136
|
+
arr[j + 1] = temp;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
cout << "Array sorted in ascending order: " << endl;
|
|
142
|
+
for (int i = 0; i < size; i++) {
|
|
143
|
+
cout << arr[i] << " ";
|
|
144
|
+
}
|
|
145
|
+
cout << endl;
|
|
146
|
+
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
selection_sort = """
|
|
152
|
+
#include <iostream>
|
|
153
|
+
using namespace std;
|
|
154
|
+
|
|
155
|
+
int main() {
|
|
156
|
+
int arr[100];
|
|
157
|
+
int size;
|
|
158
|
+
|
|
159
|
+
cout << "Enter the size of the array: ";
|
|
160
|
+
cin >> size;
|
|
161
|
+
|
|
162
|
+
cout << "Enter " << size << " elements: " << endl;
|
|
163
|
+
for (int i = 0; i < size; i++) {
|
|
164
|
+
cin >> arr[i];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Selection Sort Algorithm
|
|
168
|
+
for (int i = 0; i < size - 1; i++) {
|
|
169
|
+
|
|
170
|
+
int min_idx = i;
|
|
171
|
+
for (int j = i + 1; j < size; j++) {
|
|
172
|
+
if (arr[j] < arr[min_idx]){ // use > for descending order
|
|
173
|
+
min_idx = j;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
int temp = arr[min_idx];
|
|
178
|
+
arr[min_idx] = arr[i];
|
|
179
|
+
arr[i] = temp;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
cout << "Array sorted in ascending order: " << endl;
|
|
183
|
+
for (int i = 0; i < size; i++) {
|
|
184
|
+
cout << arr[i] << " ";
|
|
185
|
+
}
|
|
186
|
+
cout << endl;
|
|
187
|
+
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
"""
|
|
191
|
+
stack = """
|
|
192
|
+
#include <iostream>
|
|
193
|
+
using namespace std;
|
|
194
|
+
|
|
195
|
+
#define STACK_SIZE 100
|
|
196
|
+
|
|
197
|
+
int stack[STACK_SIZE];
|
|
198
|
+
int top = -1;
|
|
199
|
+
|
|
200
|
+
void push(int value) {
|
|
201
|
+
if (top >= STACK_SIZE - 1) {
|
|
202
|
+
cout << "Overflow!" << endl;
|
|
203
|
+
} else {
|
|
204
|
+
top++;
|
|
205
|
+
stack[top] = value;
|
|
206
|
+
cout << value << " pushed in stack" << endl;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
void pop() {
|
|
211
|
+
if (top == -1) {
|
|
212
|
+
cout << "Underflow!" << endl;
|
|
213
|
+
} else {
|
|
214
|
+
int poppedValue = stack[top];
|
|
215
|
+
top--;
|
|
216
|
+
cout << poppedValue << " popped from stack." << endl;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
void display() {
|
|
221
|
+
if (top == -1) {
|
|
222
|
+
cout << "Empty." << endl;
|
|
223
|
+
} else {
|
|
224
|
+
cout << "Elements in stack:" << endl;
|
|
225
|
+
for (int i = top; i >= 0; i--) {
|
|
226
|
+
cout << stack[i] << endl;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
int main() {
|
|
232
|
+
int choice, value;
|
|
233
|
+
|
|
234
|
+
do {
|
|
235
|
+
cout << "1. Push (Add)" << endl;
|
|
236
|
+
cout << "2. Pop (Remove)" << endl;
|
|
237
|
+
cout << "3. Display" << endl;
|
|
238
|
+
cout << "Enter your choice: ";
|
|
239
|
+
cin >> choice;
|
|
240
|
+
|
|
241
|
+
switch (choice) {
|
|
242
|
+
case 1:
|
|
243
|
+
cout << "Enter value to push: ";
|
|
244
|
+
cin >> value;
|
|
245
|
+
push(value);
|
|
246
|
+
break;
|
|
247
|
+
case 2:
|
|
248
|
+
pop();
|
|
249
|
+
break;
|
|
250
|
+
case 3:
|
|
251
|
+
display();
|
|
252
|
+
break;
|
|
253
|
+
default:
|
|
254
|
+
cout << "Invalid choice" << endl;
|
|
255
|
+
}
|
|
256
|
+
} while (choice != 4);
|
|
257
|
+
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
insertion_sort = """
|
|
263
|
+
#include <iostream>
|
|
264
|
+
using namespace std;
|
|
265
|
+
|
|
266
|
+
int main() {
|
|
267
|
+
int arr[100];
|
|
268
|
+
int size;
|
|
269
|
+
|
|
270
|
+
cout << "Enter the size of the array: ";
|
|
271
|
+
cin >> size;
|
|
272
|
+
|
|
273
|
+
cout << "Enter " << size << " elements: " << endl;
|
|
274
|
+
for (int i = 0; i < size; i++) {
|
|
275
|
+
cin >> arr[i];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Insertion Sort Algorithm
|
|
279
|
+
for (int i = 1; i < size; i++) {
|
|
280
|
+
|
|
281
|
+
int key = arr[i];
|
|
282
|
+
int j = i - 1;
|
|
283
|
+
|
|
284
|
+
while (j >= 0 && arr[j] > key) { // invert signs for descending order
|
|
285
|
+
arr[j + 1] = arr[j];
|
|
286
|
+
j = j - 1;
|
|
287
|
+
}
|
|
288
|
+
arr[j + 1] = key;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
cout << "Array sorted in ascending order: " << endl;
|
|
292
|
+
for (int i = 0; i < size; i++) {
|
|
293
|
+
cout << arr[i] << " ";
|
|
294
|
+
}
|
|
295
|
+
cout << endl;
|
|
296
|
+
|
|
297
|
+
return 0;
|
|
298
|
+
}
|
|
299
|
+
"""
|
|
300
|
+
|
|
301
|
+
linear_queue = """
|
|
302
|
+
#include <iostream>
|
|
303
|
+
using namespace std;
|
|
304
|
+
|
|
305
|
+
#define QUEUE_SIZE 100
|
|
306
|
+
int queue[QUEUE_SIZE];
|
|
307
|
+
int front = -1;
|
|
308
|
+
int rear = -1;
|
|
309
|
+
|
|
310
|
+
void enqueue(int value) {
|
|
311
|
+
if (rear >= QUEUE_SIZE - 1) {
|
|
312
|
+
cout << "Overflow!" << endl;
|
|
313
|
+
} else {
|
|
314
|
+
if (front == -1) {
|
|
315
|
+
front = 0;
|
|
316
|
+
}
|
|
317
|
+
rear++;
|
|
318
|
+
queue[rear] = value;
|
|
319
|
+
cout << value << " enqueued to the queue." << endl;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
void dequeue() {
|
|
324
|
+
if (front == -1 || front > rear) {
|
|
325
|
+
|
|
326
|
+
cout << "Queue Underflow!." << endl;
|
|
327
|
+
} else {
|
|
328
|
+
int dequeuedValue = queue[front];
|
|
329
|
+
front++;
|
|
330
|
+
cout << "Dequeued " << dequeuedValue << " from the queue." << endl;
|
|
331
|
+
|
|
332
|
+
if (front > rear) {
|
|
333
|
+
front = -1;
|
|
334
|
+
rear = -1;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
void display() {
|
|
340
|
+
if (front == -1 || front > rear) {
|
|
341
|
+
cout << "Queue is empty." << endl;
|
|
342
|
+
} else {
|
|
343
|
+
cout << "Elements in queue:" << endl;
|
|
344
|
+
for (int i = front; i <= rear; i++) {
|
|
345
|
+
cout << queue[i] << " ";
|
|
346
|
+
}
|
|
347
|
+
cout << endl;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
int main() {
|
|
352
|
+
int choice, value;
|
|
353
|
+
|
|
354
|
+
do {
|
|
355
|
+
cout << "1. Add" << endl;
|
|
356
|
+
cout << "2. Remove" << endl;
|
|
357
|
+
cout << "3. Display" << endl;
|
|
358
|
+
cout << "4. Exit" << endl;
|
|
359
|
+
cout << "Enter your choice: ";
|
|
360
|
+
cin >> choice;
|
|
361
|
+
|
|
362
|
+
switch (choice) {
|
|
363
|
+
case 1:
|
|
364
|
+
cout << "Enter value to enqueue: ";
|
|
365
|
+
cin >> value;
|
|
366
|
+
enqueue(value);
|
|
367
|
+
break;
|
|
368
|
+
case 2:
|
|
369
|
+
dequeue();
|
|
370
|
+
break;
|
|
371
|
+
case 3:
|
|
372
|
+
display();
|
|
373
|
+
break;
|
|
374
|
+
default:
|
|
375
|
+
cout << "Invalid choice." << endl;
|
|
376
|
+
}
|
|
377
|
+
} while (choice != 4);
|
|
378
|
+
|
|
379
|
+
return 0;
|
|
380
|
+
}
|
|
381
|
+
"""
|
|
382
|
+
|
|
383
|
+
circular_queue = """
|
|
384
|
+
#include <iostream>
|
|
385
|
+
using namespace std;
|
|
386
|
+
|
|
387
|
+
#define QUEUE_SIZE 5
|
|
388
|
+
|
|
389
|
+
int queue[QUEUE_SIZE];
|
|
390
|
+
int front = -1;
|
|
391
|
+
int rear = -1;
|
|
392
|
+
|
|
393
|
+
bool isFull() {
|
|
394
|
+
return (front == (rear + 1) % QUEUE_SIZE);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
bool isEmpty() {
|
|
398
|
+
return (front == -1);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
void enqueue(int value) {
|
|
402
|
+
if (isFull()) {
|
|
403
|
+
cout << "Queue Overflow" << endl;
|
|
404
|
+
} else {
|
|
405
|
+
if (isEmpty()) {
|
|
406
|
+
front = 0;
|
|
407
|
+
}
|
|
408
|
+
rear = (rear + 1) % QUEUE_SIZE;
|
|
409
|
+
queue[rear] = value;
|
|
410
|
+
cout << value << " enqueued to the queue." << endl;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
void dequeue() {
|
|
415
|
+
if (isEmpty()) {
|
|
416
|
+
cout << "Queue Underflow!" << endl;
|
|
417
|
+
} else {
|
|
418
|
+
int dequeuedValue = queue[front];
|
|
419
|
+
|
|
420
|
+
if (front == rear) {
|
|
421
|
+
front = -1;
|
|
422
|
+
rear = -1;
|
|
423
|
+
} else {
|
|
424
|
+
front = (front + 1) % QUEUE_SIZE;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
cout << "Dequeued " << dequeuedValue << " from the queue." << endl;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
void display() {
|
|
432
|
+
if (isEmpty()) {
|
|
433
|
+
cout << "Queue is empty." << endl;
|
|
434
|
+
} else {
|
|
435
|
+
cout << "Elements in queue:" << endl;
|
|
436
|
+
cout << "FRONT -> ";
|
|
437
|
+
|
|
438
|
+
int i = front;
|
|
439
|
+
while (true) {
|
|
440
|
+
cout << queue[i] << " ";
|
|
441
|
+
if (i == rear) {
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
i = (i + 1) % QUEUE_SIZE;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
cout << "<- REAR" << endl;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
int main() {
|
|
452
|
+
int choice, value;
|
|
453
|
+
|
|
454
|
+
do {
|
|
455
|
+
cout << "1. Enqueue (Add)" << endl;
|
|
456
|
+
cout << "2. Dequeue (Remove)" << endl;
|
|
457
|
+
cout << "3. Display" << endl;
|
|
458
|
+
cout << "4. Exit" << endl;
|
|
459
|
+
cout << "Enter your choice: ";
|
|
460
|
+
cin >> choice;
|
|
461
|
+
|
|
462
|
+
switch (choice) {
|
|
463
|
+
case 1:
|
|
464
|
+
cout << "Enter value to enqueue: ";
|
|
465
|
+
cin >> value;
|
|
466
|
+
enqueue(value);
|
|
467
|
+
break;
|
|
468
|
+
case 2:
|
|
469
|
+
dequeue();
|
|
470
|
+
break;
|
|
471
|
+
case 3:
|
|
472
|
+
display();
|
|
473
|
+
break;
|
|
474
|
+
default:
|
|
475
|
+
cout << "Invalid choice. Please try again." << endl;
|
|
476
|
+
}
|
|
477
|
+
} while (choice != 4);
|
|
478
|
+
|
|
479
|
+
return 0;
|
|
480
|
+
}
|
|
481
|
+
"""
|
|
482
|
+
prioriy_queue = """
|
|
483
|
+
#include <iostream>
|
|
484
|
+
using namespace std;
|
|
485
|
+
|
|
486
|
+
#define QUEUE_SIZE 100
|
|
487
|
+
|
|
488
|
+
int queue[QUEUE_SIZE];
|
|
489
|
+
int front = -1;
|
|
490
|
+
int rear = -1;
|
|
491
|
+
|
|
492
|
+
bool isFull() {
|
|
493
|
+
return (rear >= QUEUE_SIZE - 1);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
bool isEmpty() {
|
|
497
|
+
return (front == -1 || front > rear);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
void enqueue(int value) {
|
|
501
|
+
if (isFull()) {
|
|
502
|
+
cout << "Queue Overflow!" << endl;
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
if (isEmpty()) {
|
|
507
|
+
front = 0;
|
|
508
|
+
rear = 0;
|
|
509
|
+
queue[0] = value;
|
|
510
|
+
} else {
|
|
511
|
+
int j = rear;
|
|
512
|
+
|
|
513
|
+
while (j >= front && queue[j] < value) {
|
|
514
|
+
queue[j + 1] = queue[j];
|
|
515
|
+
j--;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
queue[j + 1] = value;
|
|
519
|
+
rear++;
|
|
520
|
+
}
|
|
521
|
+
cout << value << " enqueued to the priority queue." << endl;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
void dequeue() {
|
|
525
|
+
if (isEmpty()) {
|
|
526
|
+
cout << "Queue Underflow!" << endl;
|
|
527
|
+
} else {
|
|
528
|
+
int dequeuedValue = queue[front];
|
|
529
|
+
|
|
530
|
+
if (front == rear) {
|
|
531
|
+
front = -1;
|
|
532
|
+
rear = -1;
|
|
533
|
+
} else {
|
|
534
|
+
front++;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
cout << "Dequeued " << dequeuedValue << "(highest priority) from the queue." << endl;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
void display() {
|
|
542
|
+
if (isEmpty()) {
|
|
543
|
+
cout << "Queue is empty." << endl;
|
|
544
|
+
} else {
|
|
545
|
+
cout << "Elements in queue(from highest):" << endl;
|
|
546
|
+
cout << "FRONT -> ";
|
|
547
|
+
for (int i = front; i <= rear; i++) {
|
|
548
|
+
cout << queue[i] << " ";
|
|
549
|
+
}
|
|
550
|
+
cout << "<- REAR" << endl;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
int main() {
|
|
555
|
+
int choice, value;
|
|
556
|
+
|
|
557
|
+
do {
|
|
558
|
+
cout << "1. Enqueue (Add)" << endl;
|
|
559
|
+
cout << "2. Dequeue (Remove)" << endl;
|
|
560
|
+
cout << "3. Display" << endl;
|
|
561
|
+
cout << "Enter your choice: ";
|
|
562
|
+
cin >> choice;
|
|
563
|
+
|
|
564
|
+
switch (choice) {
|
|
565
|
+
case 1:
|
|
566
|
+
cout << "Enter value to enqueue: ";
|
|
567
|
+
cin >> value;
|
|
568
|
+
enqueue(value);
|
|
569
|
+
break;
|
|
570
|
+
case 2:
|
|
571
|
+
dequeue();
|
|
572
|
+
break;
|
|
573
|
+
case 3:
|
|
574
|
+
display();
|
|
575
|
+
break;
|
|
576
|
+
default:
|
|
577
|
+
cout << "Invalid choice. Please try again." << endl;
|
|
578
|
+
}
|
|
579
|
+
} while (choice != 4);
|
|
580
|
+
|
|
581
|
+
return 0;
|
|
582
|
+
}
|
|
583
|
+
"""
|
|
584
|
+
|
|
585
|
+
linked_list = """
|
|
586
|
+
#include <iostream>
|
|
587
|
+
using namespace std;
|
|
588
|
+
|
|
589
|
+
struct Node {
|
|
590
|
+
int data;
|
|
591
|
+
Node* next;
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
Node* head = NULL;
|
|
595
|
+
|
|
596
|
+
void display() {
|
|
597
|
+
if (head == NULL) {
|
|
598
|
+
cout << "The list is empty." << endl;
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
Node* temp = head;
|
|
602
|
+
cout << "List (Head to Tail): HEAD -> ";
|
|
603
|
+
while (temp != NULL) {
|
|
604
|
+
cout << temp->data << " -> ";
|
|
605
|
+
temp = temp->next;
|
|
606
|
+
}
|
|
607
|
+
cout << "NULL" << endl;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
void insertAtBeginning(int data) {
|
|
611
|
+
Node* newNode = new Node();
|
|
612
|
+
newNode->data = data;
|
|
613
|
+
newNode->next = head;
|
|
614
|
+
head = newNode;
|
|
615
|
+
cout << data << " inserted at the beginning." << endl;
|
|
616
|
+
display();
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
void insertAtEnd(int data) {
|
|
620
|
+
Node* newNode = new Node();
|
|
621
|
+
newNode->data = data;
|
|
622
|
+
newNode->next = NULL;
|
|
623
|
+
|
|
624
|
+
if (head == NULL) {
|
|
625
|
+
head = newNode;
|
|
626
|
+
} else {
|
|
627
|
+
Node* temp = head;
|
|
628
|
+
while (temp->next != NULL) {
|
|
629
|
+
temp = temp->next;
|
|
630
|
+
}
|
|
631
|
+
temp->next = newNode;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
cout << data << " inserted at the end." << endl;
|
|
635
|
+
display();
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
void insertAtPosition(int data, int pos) {
|
|
639
|
+
if (pos < 1) {
|
|
640
|
+
cout << "Invalid position. Position must be 1 or greater." << endl;
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
if (pos == 1) {
|
|
645
|
+
insertAtBeginning(data);
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
Node* newNode = new Node();
|
|
650
|
+
newNode->data = data;
|
|
651
|
+
|
|
652
|
+
Node* prev = head;
|
|
653
|
+
for (int i = 1; i < pos - 1; i++) {
|
|
654
|
+
if (prev == NULL) {
|
|
655
|
+
cout << "Position " << pos << " is out of bounds." << endl;
|
|
656
|
+
delete newNode;
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
prev = prev->next;
|
|
660
|
+
}
|
|
661
|
+
if (prev == NULL) {
|
|
662
|
+
cout << "Position " << pos << " is out of bounds." << endl;
|
|
663
|
+
delete newNode;
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
newNode->next = prev->next;
|
|
668
|
+
prev->next = newNode;
|
|
669
|
+
|
|
670
|
+
cout << data << " inserted at position " << pos << "." << endl;
|
|
671
|
+
display();
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
void deleteFromBeginning() {
|
|
675
|
+
if (head == NULL) {
|
|
676
|
+
cout << "List is empty. Cannot delete." << endl;
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
Node* temp = head;
|
|
680
|
+
head = head->next;
|
|
681
|
+
int deletedValue = temp->data;
|
|
682
|
+
delete temp;
|
|
683
|
+
|
|
684
|
+
cout << deletedValue << " deleted from the beginning." << endl;
|
|
685
|
+
display();
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
void deleteFromEnd() {
|
|
689
|
+
if (head == NULL) {
|
|
690
|
+
cout << "List is empty. Cannot delete." << endl;
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
Node* temp = head;
|
|
695
|
+
Node* secondLast = NULL;
|
|
696
|
+
|
|
697
|
+
if (temp->next == NULL){
|
|
698
|
+
int deletedValue = temp->data;
|
|
699
|
+
delete head;
|
|
700
|
+
head = NULL;
|
|
701
|
+
cout << deletedValue << " deleted from the end." << endl;
|
|
702
|
+
display();
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
while (temp->next != NULL) {
|
|
707
|
+
secondLast = temp;
|
|
708
|
+
temp = temp->next;
|
|
709
|
+
}
|
|
710
|
+
int deletedValue = temp->data;
|
|
711
|
+
secondLast->next = NULL;
|
|
712
|
+
|
|
713
|
+
delete temp;
|
|
714
|
+
cout << deletedValue << " deleted from the end." << endl;
|
|
715
|
+
display();
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
void deleteFromPosition(int pos) {
|
|
719
|
+
if (pos < 1) {
|
|
720
|
+
cout << "Invalid position. Position must be 1 or greater." << endl;
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
if (head == NULL) {
|
|
725
|
+
cout << "List is empty. Cannot delete." << endl;
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
if (pos == 1) {
|
|
730
|
+
deleteFromBeginning();
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
Node* prev = head;
|
|
735
|
+
for (int i = 1; i < pos - 1; i++) {
|
|
736
|
+
if (prev == NULL || prev->next == NULL) {
|
|
737
|
+
cout << "Position " << pos << " is out of bounds." << endl;
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
prev = prev->next;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
if (prev == NULL || prev->next == NULL) {
|
|
744
|
+
cout << "Position " << pos << " is out of bounds." << endl;
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
Node* temp = prev->next;
|
|
749
|
+
prev->next = temp->next;
|
|
750
|
+
|
|
751
|
+
int deletedValue = temp->data;
|
|
752
|
+
delete temp;
|
|
753
|
+
cout << deletedValue << " deleted from position " << pos << "." << endl;
|
|
754
|
+
display();
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
int main() {
|
|
759
|
+
int choice, value, position;
|
|
760
|
+
|
|
761
|
+
do {
|
|
762
|
+
cout << "1. Display List" << endl;
|
|
763
|
+
cout << "2. Insert at Beginning" << endl;
|
|
764
|
+
cout << "3. Insert at End" << endl;
|
|
765
|
+
cout << "4. Insert at Specific Position" << endl;
|
|
766
|
+
cout << "5. Delete from Beginning" << endl;
|
|
767
|
+
cout << "6. Delete from End" << endl;
|
|
768
|
+
cout << "7. Delete from Specific Position" << endl;
|
|
769
|
+
cout << "8. Exit" << endl;
|
|
770
|
+
cout << "Enter your choice: ";
|
|
771
|
+
cin >> choice;
|
|
772
|
+
|
|
773
|
+
switch (choice) {
|
|
774
|
+
case 1:
|
|
775
|
+
display();
|
|
776
|
+
break;
|
|
777
|
+
case 2:
|
|
778
|
+
cout << "Enter value to insert: ";
|
|
779
|
+
cin >> value;
|
|
780
|
+
insertAtBeginning(value);
|
|
781
|
+
break;
|
|
782
|
+
case 3:
|
|
783
|
+
cout << "Enter value to insert: ";
|
|
784
|
+
cin >> value;
|
|
785
|
+
insertAtEnd(value);
|
|
786
|
+
break;
|
|
787
|
+
case 4:
|
|
788
|
+
cout << "Enter value to insert: ";
|
|
789
|
+
cin >> value;
|
|
790
|
+
cout << "Enter position (1-based): ";
|
|
791
|
+
cin >> position;
|
|
792
|
+
insertAtPosition(value, position);
|
|
793
|
+
break;
|
|
794
|
+
case 5:
|
|
795
|
+
deleteFromBeginning();
|
|
796
|
+
break;
|
|
797
|
+
case 6:
|
|
798
|
+
deleteFromEnd();
|
|
799
|
+
break;
|
|
800
|
+
case 7:
|
|
801
|
+
cout << "Enter position to delete (1-based): ";
|
|
802
|
+
cin >> position;
|
|
803
|
+
deleteFromPosition(position);
|
|
804
|
+
break;
|
|
805
|
+
case 8:
|
|
806
|
+
cout << "Exiting program. Goodbye!" << endl;
|
|
807
|
+
break;
|
|
808
|
+
default:
|
|
809
|
+
cout << "Invalid choice. Please try again." << endl;
|
|
810
|
+
}
|
|
811
|
+
} while (choice != 8);
|
|
812
|
+
|
|
813
|
+
Node* temp = head;
|
|
814
|
+
while (temp != NULL) {
|
|
815
|
+
Node* toDelete = temp;
|
|
816
|
+
temp = temp->next;
|
|
817
|
+
delete toDelete;
|
|
818
|
+
}
|
|
819
|
+
return 0;
|
|
820
|
+
}
|
|
821
|
+
"""
|
|
822
|
+
answer_dict = {
|
|
823
|
+
"insertelement": insert_element,
|
|
824
|
+
"deleteelement": delete_element,
|
|
825
|
+
"linearsearch": linear_search,
|
|
826
|
+
"bubblesort": bubble_sort_asc,
|
|
827
|
+
"selectionsort": selection_sort,
|
|
828
|
+
"stack": stack,
|
|
829
|
+
"insertionsort": insertion_sort,
|
|
830
|
+
"linearqueue": linear_queue,
|
|
831
|
+
"circularqueue": circular_queue,
|
|
832
|
+
"priorityqueue": prioriy_queue,
|
|
833
|
+
"linkedlist": linked_list,
|
|
834
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
""" A simple Python Module for Educational Purpose"""
|
|
2
|
+
|
|
3
|
+
import pyperclip
|
|
4
|
+
from .content import answer_dict
|
|
5
|
+
|
|
6
|
+
def get(arg_string):
|
|
7
|
+
arg_string = arg_string.replace(" ", "").replace("_", "").lower()
|
|
8
|
+
answer_text = answer_dict.get(arg_string, None)
|
|
9
|
+
if answer_text is None:
|
|
10
|
+
print("Not found")
|
|
11
|
+
else:
|
|
12
|
+
pyperclip.copy(answer_text)
|
|
13
|
+
print("Success")
|
|
14
|
+
|
|
15
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: csemod
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Personal Project - Education Purpose Only
|
|
5
|
+
Author: BonzoDon
|
|
6
|
+
License: CC0-1.0
|
|
7
|
+
Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.6
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: pyperclip
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: classifier
|
|
15
|
+
Dynamic: description
|
|
16
|
+
Dynamic: description-content-type
|
|
17
|
+
Dynamic: license
|
|
18
|
+
Dynamic: requires-dist
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
Dynamic: summary
|
|
21
|
+
|
|
22
|
+
# CSEMOD
|
|
23
|
+
|
|
24
|
+
Personal Project - Education Purpose Only
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyperclip
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
csemod
|
csemod-0.0.2/setup.cfg
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = csemod
|
|
3
|
+
version = 0.0.2
|
|
4
|
+
description = Personal Project - Education Purpose Only
|
|
5
|
+
long_description = file: README.md
|
|
6
|
+
long_description_content_type = text/markdown
|
|
7
|
+
author = BonzoDon
|
|
8
|
+
license = CC0-1.0
|
|
9
|
+
license_files =
|
|
10
|
+
classifiers =
|
|
11
|
+
License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
12
|
+
Operating System :: OS Independent
|
|
13
|
+
Programming Language :: Python :: 3 :: Only
|
|
14
|
+
|
|
15
|
+
[options]
|
|
16
|
+
python_requires = >=3.6
|
|
17
|
+
packages = csemod
|
|
18
|
+
install_requires =
|
|
19
|
+
pyperclip
|
|
20
|
+
|
|
21
|
+
[egg_info]
|
|
22
|
+
tag_build =
|
|
23
|
+
tag_date = 0
|
|
24
|
+
|
csemod-0.0.2/setup.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
def get_long_description(path):
|
|
4
|
+
"""Opens and fetches text of long descrition file."""
|
|
5
|
+
with open(path, 'r') as f:
|
|
6
|
+
text = f.read()
|
|
7
|
+
return text
|
|
8
|
+
|
|
9
|
+
setup(
|
|
10
|
+
name='csemod',
|
|
11
|
+
version='0.0.2',
|
|
12
|
+
description="Personal Project - Education Purpose Only",
|
|
13
|
+
license="CC0-1.0",
|
|
14
|
+
long_description=get_long_description('README.md'),
|
|
15
|
+
long_description_content_type="text/markdown",
|
|
16
|
+
author='BonzoDon',
|
|
17
|
+
classifiers=[
|
|
18
|
+
"License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
],
|
|
22
|
+
keywords=[],
|
|
23
|
+
install_requires=[
|
|
24
|
+
'pyperclip',
|
|
25
|
+
],
|
|
26
|
+
packages=["csemod"],
|
|
27
|
+
python_requires='>=3.6',
|
|
28
|
+
)
|