Compare commits

...

98 Commits

Author SHA1 Message Date
efbc7e7b02 Update README.md 2023-12-22 12:03:36 +05:30
Afan Toofaan
8dde96d97a Adding QBank to Notes folder 2023-12-22 12:01:03 +05:30
Afan Toofaan
4b4d6b97cc Yo! Adding Question Banks for FDS. Og shit! 2023-12-22 11:55:41 +05:30
f49c3e4c86
added credits for handwritten important notes for end-sem, mr. afan 2023-12-19 21:35:34 +05:30
edee0faedf readme updated 2023-12-19 12:59:13 +05:30
7f09d718ed imp notes endsem added 2023-12-19 12:58:09 +05:30
4e5b364e11 entire e31 updated old one had error and was goofy 2023-12-11 17:06:21 +05:30
3a6ad7c77f
changed to only single for loop in quick for to reduce time complexity. thanks to mr. lalit hinduja 2023-12-11 09:47:09 +05:30
d8ad39d234
moved if temp>freq in highest frequency outside the inner loop, as it should be 2023-12-11 09:12:31 +05:30
a78f6deacc
updated the code for better understanding: added alternative method for quick sort and added description for some lines of code 2023-12-10 19:32:22 +05:30
6db1cebae8
took me a few months to figure this out (jeez im dumb) but by changing the less than sign to greater than in top 5, the list can be sorted in descending order :) 2023-12-10 16:47:58 +05:30
4b2cfdc89b
updated top 5 function to only show top 5 scores instead of the whole list in descending order. requires minimum 6 elements in the list. also removed 'designed and engineered by kshitij' 2023-12-10 16:12:39 +05:30
79a69ad179
updated top 5 function to only show top 5 scores instead of the whole list in descending order. requires minimum 6 elements in the list. 2023-12-10 16:10:56 +05:30
ed996705db
fixed binary and fibonacci 2023-12-10 10:37:50 +05:30
9820343428
fixed certain functions, simplified the code and added descrption for certain lines of code. [perfect code] 2023-12-07 16:19:16 +05:30
5e97a900f4
fixed certain functions, simplified the code and added descrption for certain lines of code. [perfect code] 2023-12-07 16:07:16 +05:30
6cbcb483c7
fixed certain functions, simplified the code and added descrption for certain lines of code. [perfect code] 2023-12-07 15:58:43 +05:30
9e047e1c49
fixed last option in assignment-1, changed variable names for better understanding, cleaner code. [perfect code] 2023-12-07 14:28:42 +05:30
39e5ac734c
fixed last option in assignment-1, changed variable names for better understanding, cleaner code. [perfect code] 2023-12-07 14:25:56 +05:30
efc3d6820b readme updated 2023-12-06 18:20:51 +05:30
6637f9ce6e e29 fixed dequeue error 2023-12-05 10:19:07 +05:30
75bd1ee855 readme updated 2023-12-04 10:36:31 +05:30
cb6c88f699 readme updated 2023-12-04 10:34:32 +05:30
548f149416 readme updated 2023-12-04 10:30:47 +05:30
2f37503f03 unit 6,quicksort, dqueue, priority queue added 2023-12-04 10:25:03 +05:30
cf9c477b1d readme updated 2023-11-23 20:17:58 +05:30
ee39339e03 readme updated 2023-11-23 20:17:23 +05:30
4b533ba417 readme updated 2023-11-23 20:16:17 +05:30
e89fd49c34 Merge branch 'main' of https://git.kska.io/sppu-se-comp-codes/DSL 2023-11-23 20:14:04 +05:30
0e6dae91b6 index pdf added 2023-11-23 20:13:19 +05:30
b8dac278ca
converted lab manuals for assignment 26 and 27 to pdf and added apparatus 2023-11-13 20:07:42 +05:30
929bff9d5f readme updated 2023-11-13 15:17:11 +05:30
707f5d17f9 assgn2 diwali writeup added 2023-11-13 15:15:21 +05:30
c884abf9b3 readme updated 2023-11-13 11:43:58 +05:30
c2d38e68c6 diwali assgn1 added 2023-11-13 11:42:37 +05:30
0856a752e1
added questions for Diwali work assignments 1&2 2023-11-12 10:37:40 +05:30
04c084c4aa
updated readme 2023-11-10 23:34:02 +05:30
49ccf6a1e0
added write-up for assignment 27 2023-11-10 23:32:14 +05:30
665558530c readme updated 2023-11-10 18:28:04 +05:30
007fe2844a added d27 code 2023-11-10 18:24:57 +05:30
1299c94a4b readme updated 2023-11-10 16:47:28 +05:30
c76b64055d d26 writeup added 2023-11-10 16:45:03 +05:30
2e66eaf943 readme updated 2023-11-10 12:20:08 +05:30
d04b2f3753 dsl d26 code added 2023-11-10 12:17:33 +05:30
7d37851214 readme updated 2023-11-10 10:37:38 +05:30
dd7a0ad429 readme updated 2023-11-10 10:36:19 +05:30
18cb8895c2 d27 and d26 lab manual added 2023-11-10 10:30:10 +05:30
c7928e12f9
added credits for shh_itsourlittlesecret (Afan) 2023-11-05 23:07:21 +05:30
0caf37885e Unit 5 added to README 2023-11-05 21:49:09 +05:30
Afan Shaikh
35ae8f5074 Unit 5 is now Available exclusively on KSKA git!!!! 2023-11-05 21:40:41 +05:30
e79fc6ef7c
added writeup for assignment-20 2023-11-05 20:48:40 +05:30
18733117b5 readme updated 2023-11-05 08:01:28 +05:30
c22af64427 writeup added c19 2023-11-05 07:59:18 +05:30
04ad26ec99
removed unnecessary file 2023-10-31 11:18:06 +05:30
43034014a1
Merge branch 'main' of https://git.kska.io/sppu-se-comp-codes/DSL into main 2023-10-31 11:11:57 +05:30
cd3f7681ab
added code and lab manual for assignment 20 and updated README link 2023-10-31 11:11:22 +05:30
7a4e1f1ad0 readme updated 2023-10-30 11:28:41 +05:30
f9b05b7fa9 C19 updated entire code 2023-10-30 11:23:47 +05:30
ceef4d3713
added question paper for end sem (nov 2022) 2023-10-29 23:40:44 +05:30
5952abdc0b
changed back to og suiiiiiiiiiii 2023-10-29 18:02:40 +05:30
47acafef28
changed for testing gpg keys 2023-10-29 17:57:55 +05:30
tejasjokin
49ce0361ae readme fixed 2023-10-28 23:51:26 +05:30
tejasjokin
bb84fdc046 c19 manual copy deleted my bad TT 2023-10-28 18:55:06 +05:30
tejasjokin
525d85ba15 c19 manual added 2023-10-28 18:53:36 +05:30
tejasjokin
dcf2512134 c19 added 2023-10-28 18:52:39 +05:30
8321c44c81
changed compiler from python3 to g++ in apparatus for lab manuals 19,29,31,32. thanks to Mehul for pointing it out :) 2023-10-28 17:01:23 +05:30
9627f0dca8
added question paper link in index 2023-10-28 16:55:31 +05:30
afe218f550
updated readme and removed unnecessary content from assignment 31,32 codes 2023-10-26 20:44:08 +05:30
c56cdf2b5c
added assignment 31, 32 2023-10-26 20:35:33 +05:30
4d229935db
added assignment 31,32 2023-10-26 20:23:39 +05:30
tejasjokin
6abb9031d5
readme updated for unit 4 notes 2023-10-26 00:33:59 +05:30
tejasjokin
9d9bc69d58 readme updated for unit 4 notes 2023-10-26 00:00:08 +05:30
88685783bc
updated assignment 29 write-up 2023-10-25 23:57:09 +05:30
tejasjokin
595e92b49c unit 4 ppt added 2023-10-25 23:55:23 +05:30
9f4e52eb53
added assignment 31 (pre-production) 2023-10-25 00:15:36 +05:30
f6f211dbeb
added assignment-29 (pre-production) 2023-10-25 00:12:05 +05:30
5aa6c233e1
finally added assignment-2 (marks) write-up 2023-10-22 16:29:29 +05:30
8b7ba873b6
added assignment 31 and 32 from ma'am in index 2023-10-19 23:37:51 +05:30
d5c02eceb6
restructuring repo 2023-10-19 19:21:04 +05:30
tejasjokin
7b052a3bd8 b16 writeup quicksort added 2023-10-19 16:10:27 +05:30
21e67b031a
Added assignment-11 (linear, sentinel, binary, fibonacci) code. Binary and fibonacci don't exactly work 2023-10-17 19:09:59 +05:30
015ff48f61
Added link for assignment-19 2023-10-17 18:21:22 +05:30
dc66a90d9b
Added assignment-19 (singly linked list for PRN and name) which takes PRN and names for n students and displays it 2023-10-17 18:21:09 +05:30
5049898263
Added lab manuals for B19, C19 and added links for the same in README 2023-10-16 20:51:39 +05:30
c0839fca65
Fixed links and formatting in README 2023-10-16 20:36:30 +05:30
1adbeb7229
Updated link for assignment-16 (quick sort) in README 2023-10-16 20:33:35 +05:30
59af8b2d59
Merged quick sort in main branch from testing 2023-10-16 19:32:29 +05:30
tejasjokin
9719232f80 Question papers added 2023-10-10 01:05:14 +05:30
640edc04f5
Added notes for time complexity 2023-10-04 16:18:11 +05:30
25c3b70e4f
Added question bank 2023-10-04 10:47:40 +05:30
4d71661503
Added notes for unit 2 (sparse matrix part) 2023-10-04 10:34:01 +05:30
8b40c04500
Added question bank for fds (unit 1 to 6) 2023-10-04 10:33:21 +05:30
0242838b42
Added notes for unit 2 2023-10-04 10:29:19 +05:30
10246f7167
Added link for assignment-11 write-up 2023-10-01 23:03:29 +05:30
d3dd4995cd
Added write up for assignment-11 2023-10-01 22:59:06 +05:30
5e10f2c1c8
Fixed naming for assignnment-14 which was accidentally named assignment-11 2023-10-01 22:58:40 +05:30
2244255623
Updated links for assignment-29 and quick sort since they've been migrated to testing branch 2023-09-29 15:59:34 +05:30
64799ecf44
Moved assignment-29 and quick sort algorithm to testing branch 2023-09-29 15:59:01 +05:30
58 changed files with 2041 additions and 430 deletions

2
.gitignore vendored
View File

@ -194,3 +194,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
# VIM swap file
*.swp

BIN
DSL Index.pdf Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
# DSL # DSL
Explore our Data Structure Lab repo: codes, lab manuals, write-ups. Ace your assignments with practical examples and clear guidance. Explore our Data Structure Lab repository: codes, lab manuals, write-ups. Ace your assignments with practical examples and clear guidance.
--- ---
@ -9,47 +9,89 @@ In this repository, you'll find codes for Data Structure Lab.
## Index ## Index
### Codes ### Codes
1. [DSL - Assignment 1 (Cricket, Badminton, Football)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-1.py) 1. [DSL - Assignment 1 (Cricket, Badminton, Football)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-1.py)
2. [DSL - Assignment 2 (Marks)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-2.py) 2. [DSL - Assignment 2 (Marks)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-2.py)
5. [DSL - Assignment 5 (String)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-5.py) 5. [DSL - Assignment 5 (String)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-5.py)
11. DSL - Assignment 11 (Linear, Sentinel, Binary, Fibonnaci Search) - _PENDING_ 11. [DSL - Assignment 11 (Linear, Sentinel, Binary, Fibonnaci Search)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-11.py)
14. [DSL - Assignment 14 (Selection, Bubble Sorting)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-14.py) 14. [DSL - Assignment 14 (Selection, Bubble Sorting)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-14.py)
16. [DSL - Assignment 16 (Quick sort)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-16.py)
19. [DSL - Assignment 19 (Pinnacle Club)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-19.cpp)
20. [DSL - Assignment 20 (Cinemax theater)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-20.cpp)
26. [DSL - Assignment 26 (Stack Expression)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-26.cpp)
27. [DSL - Assignment 27 (Infix to Postfix)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-27.cpp)
29. [DSL - Assignment 29 (Queue job)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-29.cpp)
31. [DSL - Assignment 31 (Double-ended queue)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-31.cpp)
32. [DSL - Assignment 32 (Circular queue)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-32.cpp)
### Write-ups ### Write-ups
1. [Assignment 1 - Cricket, Badminton, Football](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment%201%20%28cricket%2C%20badminton%2C%20football%29.pdf) 1. [Assignment 1 - Cricket, Badminton, Football](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment%201%20%28cricket%2C%20badminton%2C%20football%29.pdf)
2. Assignment 2 - Marks - _PENDING_ 2. [Assignment 2 - Marks](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-2%20%28marks%29.pdf)
5. [Assignment 5 - String](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-5%20%28string%29.pdf) 5. [Assignment 5 - String](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-5%20%28string%29.pdf)
11. Assignment 11 - Linear, Sentinel, Binary, Fibonnaci Search - _PENDING_ 11. [Assignment 11 - Linear, Sentinel, Binary, Fibonacci Search](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-11%20%28Linear%2C%20Sentinel%2C%20Binary%2C%20Fibonacci%20Search%29.pdf)
14. [Assignment 14 - Selection, Bubble Sorting](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-11%20%28selection%2C%20bubble%20sort%29.pdf) 14. [Assignment 14 - Selection, Bubble Sorting](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-14%20%28selection%2C%20bubble%20sort%29.pdf)
16. [Assignment 16 - Quick sort](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-16%20%28quick%20sort%29.pdf)
19. [Assignment 19 - Pinnacle Club](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-19%20%28singly%20linked%20list%29.pdf)
20. [Assignment 20 - Cinemax Theatre](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-20%20%28Cinemax%20Theatre%29.pdf)
26. [Assignment 26 - Stack Expression](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-26%20%28stack%20expression%29.pdf)
27. [Assignment 27 - Infix to Prefix](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-27%20%28Infix%20to%20Prefix%29.pdf)
29. [Assignment 29 - Queue job](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-29%20%28queue%29.pdf)
31. [Assignment 31 - Double-ended queue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-31%20%28double-ended%20queue%29.pdf)
32. [Assignment 32 - Circular queue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/write-ups/assignment-32%20%28circular%20queue%29.pdf)
### Lab Manuals ### Lab Manuals
- [DSL Index](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/DSL%20Index.pdf)
1. [Assignment 1 - Cricket, Badminton, Football](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20A_01.pdf) 1. [Assignment 1 - Cricket, Badminton, Football](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20A_01.pdf)
2. [Assignment 2 - Marks](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20A_02.pdf) 2. [Assignment 2 - Marks](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20A_02.pdf)
5. [Assignment 5 - String](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20A_05.pdf) 5. [Assignment 5 - String](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20A_05.pdf)
11. [Assignment 11 - Linear, Sentinel, Binary, Fibonnaci Search](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20B_11.pdf) 11. [Assignment 11 - Linear, Sentinel, Binary, Fibonnaci Search](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20B_11.pdf)
14. [Assignment 14 - Selection, Bubble Sorting](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20B_14.pdf) 14. [Assignment 14 - Selection, Bubble Sorting](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20B_14.pdf)
29. [Assignment 29 - Job queue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20E_29.pdf) 16. [Assignment 16 - Quick sort](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20B_16.pdf)
19. [Assignment 19 - Pinnacle Club](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20C_19.pdf)
20. [Assignment 20 - Cinemax theater](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20C_20.pdf)
26. [Assignment 26 - Stack (Expression)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20D_26.pdf)
27. [Assignment 27 - Stack (Infix to posfix)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20D_27.pdf)
29. [Assignment 29 - Queue job](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20E_29.pdf)
31. [Assignment 31 - Double-ended queue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20E_31.pdf) 31. [Assignment 31 - Double-ended queue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20E_31.pdf)
32. [Assignment 32 - Circular queue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20E_32.pdf) 32. [Assignment 32 - Circular queue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Lab%20Assignment%20E_32.pdf)
33. [Mini Project](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Miniproject.doc) 33. [Mini Project](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Miniproject.doc)
### Notes ### Notes
- [Endsem Important Notes (Unit 3->6)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/FDS%20Endsem%20Important%20Notes.pdf) (handwritten by [shh_itsourlittlesecret (Afan)](https://git.kska.io/shh_itsourlittlesecret))
1. [Unit 1 - Introduction to Algorithm and Data Structures](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%201) 1. [Unit 1 - Introduction to Algorithm and Data Structures](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%201)
2. [Unit 2 - Linear Data Structure Using Sequential Organization](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%202) 2. [Unit 2 - Linear Data Structure Using Sequential Organization](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%202)
3. [Unit 3 - Searching and Sorting](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%203) 3. [Unit 3 - Searching and Sorting](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%203)
- [Quick Sort](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%203/quicksort.ppt)
4. [Unit 4 - Linked List](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%204)
5. [Unit 5 - Stack](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%205)
6. [Unit 6 - Queue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%206/UNIT%20VI%20Queue.pptx)
- [Dequeue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%206/Dqueue.cpp)
- [Priority Queue](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%206/priorityQueue.cpp)
### [Question Bank](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Deore%27s%20QBank.docx)
### Question Papers
1. [IN-SEM](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/question-papers/IN-SEM)
2. [END-SEM](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/question-papers/END-SEM)
### Diwali work
1. [Assignment 1 - Questions](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/diwali-work/Assignment1_FDS.pdf)
- [Assignment 1 - Solutions](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/diwali-work/Assignment-1%20%28diwali%29.pdf)
2. [Assignment 2 - Questions](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/diwali-work/Assignment2_FDS.pdf)
- [Assignment 2 - Solutions](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/diwali-work/Assignment-2%20%28diwali%29.pdf)
--- ---
### Work in progress ### Work in progress
> These are the codes we're working on. They *may not work* the way intended. > These are the codes we're working on. They *may not work* the way intended.
> To view all the codes that are being built, checkout the [testing branch](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/testing).
[quicksortEarlyAccess.py](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/quicksortEarlyAccess.py) **ALL TESTING CODES MERGED IN MAIN BRANCH. NO CHANGES PENDING.**
--- ---
Maintained by [notkshitij](https://git.kska.io/notkshitij) and [TanmaySpamzzz](https://git.kska.io/TanmaySpamzzz) Maintained by:
- [notkshitij](https://git.kska.io/notkshitij)
- [TanmaySpamzzz](https://git.kska.io/TanmaySpamzzz)
- [shh_itsourlittlesecret (Afan)](https://git.kska.io/shh_itsourlittlesecret)
Contributor: [Kalaskar_admin03](https://git.kska.io/Kalaskar_admin03/)

View File

@ -1,117 +1,117 @@
# DSL Assignment - 1 '''
Problem Statement: In second year computer engineering class, group A student's play cricket, group B students play badminton and group C students play football.
Write a Python program using functions to compute following:
a) List of students who play both cricket and badminton
b) List of students who play either cricket or badminton but not both
c) Number of students who play neither cricket nor badminton
d) Number of students who play cricket and football but not badminton.
(Note- While realising the group, duplicate entries should be avoided, Do not use SET built-in functions)
# List of players Code from Data Structure Lab (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-codes/DSL
'''
cricket_players=[] # BEGINNING OF CODE
badminton_players=[] # List to store players
football_players=[] cricketPlayers = []
badmintonPlayers = []
footballPlayers = []
# Input values # Input cricket
def cricketInput():
## List for cricket players total = int(input("Total number of CRICKET players:\t"))
def cricket_in():
total=int(input("Total number of students playing cricket: \t"))
for i in range(total): for i in range(total):
players=int(input("Enter roll number: \t")) players = int(input(f"Roll number of player {i+1}:\t"))
cricket_players.append(players) cricketPlayers.append(players)
print("Roll numbers of", total, "students playing cricket: \t", cricket_players) print(f"\n----------\nStudents playing cricket:\t {cricketPlayers}\n----------\n")
cricket_in()
## List for badminton players # Input badminton
def badminton_in(): def badmintonInput():
total=int(input("Total number of students playing badminton: \t")) total = int(input("Total number of BADMINTON players:\t"))
for i in range(total): for i in range(total):
players=int(input("Enter roll number: \t")) players = int(input(f"Roll number of player {i+1}:\t"))
badminton_players.append(players) badmintonPlayers.append(players)
print("Roll numbers of", total, "students playing badminton: \t", badminton_players) print(f"\n----------\nStudents playing badminton:\t {badmintonPlayers}\n----------\n")
badminton_in()
## List for football players # Input football
def football_in(): def footballInput():
total=int(input("Total number of students playing football: \t")) total = int(input("Total number of FOOTBALL players:\t"))
for i in range(total): for i in range(total):
players=int(input("Enter roll number: \t")) players = int(input(f"Roll number of player {i+1}:\t"))
football_players.append(players) footballPlayers.append(players)
print("Roll numbers of", total, "students playing football: \t", football_players) print(f"\n----------\nStudents playing football:\t {footballPlayers}\n----------\n")
football_in()
# List of students playing cricket+badminton # Playing both cricket and badminton
def CricketAndBadminton():
listCricketAndBadminton = []
for i in cricketPlayers:
if i in badmintonPlayers:
listCricketAndBadminton.append(i)
print(f"\n----------\nStudents playing cricket and badminton:\t {listCricketAndBadminton}\n----------\n")
cricket_and_badminton=[] # Either cricket or badminton but not both
def CricketOrBadminton():
listCricketOrBadminton = []
for i in cricketPlayers:
if i not in badmintonPlayers:
listCricketOrBadminton.append(i)
for i in badmintonPlayers:
if i not in cricketPlayers:
listCricketOrBadminton.append(i)
print(f"\n----------\nStudents playing cricket or badminton (but not both):\t {listCricketOrBadminton}\n----------\n")
def cricket_and_badminton_fn(): # Neither cricket nor badminton, i.e. football only
for i in cricket_players: def FootballOnly():
if i in badminton_players: listCricketAndBadminton = []
cricket_and_badminton.append(i) listFootballOnly = []
print("Roll numbers of students playing cricket and badminton are: \t", cricket_and_badminton) for i in cricketPlayers:
listCricketAndBadminton.append(i)
for i in badmintonPlayers:
if i not in cricketPlayers:
listCricketAndBadminton.append(i)
for i in footballPlayers:
if i not in listCricketAndBadminton:
listFootballOnly.append(i)
print(f"\n----------\nTotal students playing football only are:\t{len(listFootballOnly)}\nList:\t{listFootballOnly}\n----------\n")
# List of students playing either cricket or badminton but not both # Cricket and football but not badminton
def notBadminton():
listNotBadminton = []
for i in cricketPlayers:
if i in footballPlayers:
if i not in badmintonPlayers:
listNotBadminton.append(i)
print(f"\n----------\nTotal students not playing badminton (but do play cricket and football):\t{len(listNotBadminton)}\nList:\t{listNotBadminton}\n----------\n")
cricket_or_badminton=[] # Main function with options
def main():
print("----- ENTER ROLL NUMBERS IN LIST -----")
cricketInput()
badmintonInput()
footballInput()
print("----- ROLL NUMBERS SAVED -----\n")
while (1):
print("\n----- MAIN MENU -----")
print("1 -> Students playing both cricket and badminton")
print("2 -> Students playing either cricket or badminton, but not both")
print("3 -> Students playing neither cricket nor badminton (i.e. football only)")
print("4 -> Students playing cricket and football, but not badminton")
print("5 -> Exit")
def cricket_or_badminton_fn(): optn = int(input("Choose an option (1-5):\t"))
for i in cricket_players:
if i not in badminton_players:
cricket_or_badminton.append(i)
for i in badminton_players:
if i not in cricket_players:
cricket_or_badminton.append(i)
print("Roll numbers of students playing either cricket or badminton are: \t", cricket_or_badminton)
# Number of students playing neither cricket nor badminton if (optn == 1):
CricketAndBadminton()
football_only=[] elif (optn == 2):
football_only_1=[] CricketOrBadminton()
elif (optn == 3):
def football_only_fn(): FootballOnly()
for i in cricket_players: elif (optn == 4):
football_only.append(i) notBadminton()
for i in badminton_players: elif (optn ==5):
if i not in cricket_players: print("\n\n## END OF CODE\n\n")
football_only.append(i)
for i in football_players:
if i not in football_only:
football_only_1.append(i)
print("Number of students playing neither cricket nor badminton: \t", len(football_only_1), "\n Roll numbers are:\t", football_only_1)
# Number of students playing cricket and football but not badminton
not_badminton=[]
def not_badminton_fn():
for i in badminton_players:
if i not in cricket_players:
not_badminton.append(i)
for i in badminton_players:
if i not in football_players:
not_badminton.append(i)
print("Number of students playing cricket and football but not badminton: \t", len(not_badminton), "\n Roll numbers are:\t", not_badminton)
# Choosing an option
def choose_optn():
while True:
print("Choose an operation to perform:")
print("1. List of students playing cricket and badminton both")
print("2. List of students playing either cricket or badminton")
print("3. List of students playing neither cricket nor badminton")
print("4. List of students playing cricket and football but not badminton")
print("5. Exit")
optn=int(input("Enter option number (1-5): \t"))
if optn==1:
cricket_and_badminton_fn()
if optn==2:
cricket_or_badminton_fn()
if optn==3:
football_only_fn()
if optn==4:
not_badminton_fn()
if optn==5:
print("## DESIGNED AND ENGINEERED BY KSHITIJ\n## END OF CODE")
quit() quit()
else: else:
print("\nPlease choose a valid option.\n") print("\n\nPlease choose a valid option (1-5)\n\n")
choose_optn()
choose_optn()
## END OF CODE
main()
# END OF CODE

141
assignment-11.py Normal file
View File

@ -0,0 +1,141 @@
# List to store roll numbers of students that attended the program
programRoll=[]
attendees=int(input("Enter the number of students attending the program:\t"))
# Function to take input for roll numbers in list
def attendInput():
for i in range(attendees):
roll=int(input(f"Enter roll number for student {i+1}:\t"))
programRoll.append(roll)
print(f"Roll numbers of {attendees} students that attended the program are:\t {programRoll}")
# Linear search
def linearSearch(roll_list, roll_search):
for i in roll_list:
if i==roll_search:
return 1
# Sentinel search
def sentinelSearch(roll_list, roll_search, n):
end=roll_list[n-1]
roll_list[n-1]=roll_search
i=0
while (roll_list[i] != roll_search):
i+=1
roll_list[n-1]=end
if ((i<n-1) or (roll_search==roll_list[n-1])):
return 1
else:
return -1
def binarySearch(arr, target):
arr.sort()
# Binary search on the sorted list
low, high = 0, len(arr) - 1
while low <= high:
mid = (low + high) // 2
mid_element = arr[mid]
if mid_element == target:
return mid # Target element found, return its index
elif mid_element < target:
low = mid + 1 # Target is in the right half
else:
high = mid - 1 # Target is in the left half
return -1 # Target element not found in the list
'''
# DOESN'T WORK THIS ONE
# Binary search
def binarySearch(roll_list, roll_search, begin, n):
if begin>n:
return -1
mid=(begin+n)//2
if roll_search==roll_list[mid]:
return mid
if roll_search<roll_list[mid]:
return binarySearch(roll_list, roll_search, begin, mid-1)
else:
return binarySearch(roll_list,roll_search,mid+1,n)
'''
# Fibonacci search
def fibonacciSearch(students_attend, search_element, n):
students_attend.sort()
fibMMm2 = 0
fibMMm1 = 1
fibM = fibMMm2 + fibMMm1
while (fibM<n):
fibMMm2=fibMMm1
fibMMm1=fibM
fibM=fibMMm2+fibMMm1
offset=-1;
while (fibM>1):
i=min(offset+fibMMm2, n-1)
if (students_attend[i]<search_element):
fibM=fibMMm1
fibMMm1=fibMMm2
fibMMm2=fibM-fibMMm1
offset=i
elif (students_attend[i]>search_element):
fibM=fibMMm2
fibMMm1=fibMMm1-fibMMm2
fibMMm2=fibM-fibMMm1
else:
return i
if(fibMMm1 and students_attend[offset+1]==search_element):
return offset+1;
else:
return -1
def main():
# Input for marks and search roll
attendInput()
searchAttendee=int(input("\nEnter the roll number you want to search:\t"))
# Options
while True:
print("\n----- CHOOSE SEARCH TYPE -----")
print("1 -> Linear search")
print("2 -> Sentinel search")
print("3 -> Binary search")
print("4 -> Fibonacci search")
print("5 -> Exit")
optn=int(input("\nChoose an option (1-5):\t"))
if (optn==1):
result=linearSearch(programRoll, searchAttendee)
if (result==1):
print(f"\nRoll number {searchAttendee} attended the program.\n")
else:
print(f"\nRoll number {searchAttendee} has either not been added to the list or was absent.\n")
elif (optn==2):
result=sentinelSearch(programRoll, searchAttendee, attendees)
if (result==1):
print(f"\nRoll number {searchAttendee} attended the program.\n")
else:
print(f"\nRoll number {searchAttendee} has either not been added to the list or was absent.\n")
elif (optn==3):
result=binarySearch(programRoll, searchAttendee)
if (result==-1):
print(f"\nRoll number {searchAttendee} has either not been added to the list or was absent.\n")
else:
print(f"\nRoll number {searchAttendee} attended the program.\n")
elif (optn==4):
result=fibonacciSearch(programRoll, searchAttendee, attendees)
if (result==-1):
print(f"\nRoll number {searchAttendee} has either not been added to the list or was absent.\n")
else:
print(f"\nRoll number {searchAttendee} attended the program.\n")
elif (optn==5):
print("\n## END OF CODE\n\n")
quit()
else:
print("\nPlease choose a valid option (1-5)\n")
main()
# Calling main function
main()

View File

@ -30,9 +30,9 @@ def bubble():
def top5(): def top5():
for i in range(len(marks)): for i in range(len(marks)):
for j in range(0, len(marks)-i-1): for j in range(0, len(marks)-i-1):
if marks[j]>marks[j+1]: if marks[j]<marks[j+1]:
marks[j], marks[j+1] = marks[j+1], marks[j] marks[j], marks[j+1] = marks[j+1], marks[j]
print("Top 5 marks using bubble sorting:\t", marks[::-1]) print("Top 5 marks using bubble sorting:\t", marks[0:5])
def choose_optn(): def choose_optn():
@ -54,9 +54,8 @@ def choose_optn():
elif optn==4: elif optn==4:
top5() top5()
elif optn==5: elif optn==5:
print("## DESIGNED AND ENGINEERED BY KSHITIJ\n## END OF CODE") print("\n## END OF CODE\n\n")
quit() quit()
else: else:
print("\nPlease choose a valid option (1-5).\n") print("\nPlease choose a valid option (1-5).\n")
choose_optn() choose_optn()
choose_optn()

48
assignment-16.py Normal file
View File

@ -0,0 +1,48 @@
# BEGINNING OF CODE
# Function for quick sort:
def quickSort(arr):
if len(arr) <= 1: # if array is empty array
return arr
pivot = arr[len(arr) // 2] # Set pivot element
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
'''
## ALTERNATIVE WAY OF WRITING THE UPPER 3 LINES (for easy understanding)
left = [] # Empty list to store left part
middle = [] # Empty list to store middle element
right = [] # Empty list to store right part
for i in arr:
if (i < pivot):
left.append(i)
elif (i == pivot):
middle.append(i)
else:
right.append(i)
'''
return quickSort(left) + middle + quickSort(right)
# Function for displaying top scores:
def top5(arr):
top_scores = quickSort(arr)
return top_scores[-1:-6:-1]
# Defining main function:
def main():
percent = [] # List to store percentages
total = int(input("Total number of students are:\t")) # Input for total students
for i in range(total):
percent_in = float(input(f"Enter percentage for student {i+1}:\t"))
percent.append(percent_in)
print(f"-----\nPercentages of students are:\t {percent}\n-----")
print(f"\n-----\nSorted marks (using quick sort algorithm):\t{quickSort(percent)}\n-----")
print(f"\n-----\nTop five scores are:\t{top5(percent)}\n-----")
# Calling main function:
main()
# END OF CODE

339
assignment-19.cpp Normal file
View File

@ -0,0 +1,339 @@
#include<iostream>
using namespace std;
class student
{
int roll;
string name;
student *next;
public:
student* create();
void display(student *head);
student* beg_add(student *head);
student* end_add(student *head);
student* btwn_add(student *head);
student* beg_del(student *head);
student* end_del(student *head);
student* btwn_del(student *head);
student* total(student *head);
student* con(student *head,student *head1);
};
student* student::create()
{
int n;
student *head,*p;
head = NULL;
cout<<"Enter number of members: ";
cin>>n;
for(int i = 0; i<n; i++)
{
if(head == NULL)
{
head = new student;
cout<<"\nEnter prn of president: ";
cin>>head->roll;
cout<<"Enter name of president: ";
cin>>head->name;
head->next = NULL;
p = head;
}
else
{
p->next = new student;
p = p->next;
cout<<"\nEnter prn of member: ";
cin>>p->roll;
cout<<"Enter name of member: ";
cin>>p->name;
p->next = NULL;
}
}
return head;
}
void student::display(student *head)
{
student *p;
for(p = head; p->next!= NULL; p = p->next)
{
cout<<p->roll<<" "<<p->name<<"->";
}
cout<<p->roll<<" "<<p->name<<endl;
}
student* student::beg_add(student *head)
{
student *p;
p = new student;
cout<<"\nEnter prn of new president: ";
cin>>p->roll;
cout<<"Enter name of new president: ";
cin>>p->name;
p->next = NULL;
p->next = head;
head = p;
return head;
}
student* student::end_add(student *head)
{
student *p,*q;
p = new student;
cout<<"\nEnter prn of secretary: ";
cin>>p->roll;
cout<<"Enter name of secretary: ";
cin>>p->name;
p->next = NULL;
for(q = head; q->next!=NULL; q = q->next);
q->next = p;
return head;
}
student* student::btwn_add(student *head)
{
int y;
student *p,*q;
p = new student;
cout<<"\nEnter prn of new member: ";
cin>>p->roll;
cout<<"Enter name of new member: ";
cin>>p->name;
cout<<"Enter prn after which new member is to be added: ";
cin>>y;
p->next = NULL;
q = head;
while(q!=NULL)
{
if(q == NULL)
{
cout<<"\nInvalid Data....."<<endl;
}
else if(q->roll == y)
{
p->next = q->next;
q->next = p;
}
q = q->next;
}
return head;
}
student* student::beg_del(student *head)
{
student *p;
p = head;
head = head->next;
delete p;
return head;
}
student* student::end_del(student *head)
{
student *p,*q;
for(q = head; q->next->next!=NULL; q = q->next);
p = q->next;
delete p;
q->next = NULL;
}
student* student::btwn_del(student *head)
{
int y;
student *p,*q;
cout<<"\nEnter prn of member which is to be deleted: ";
cin>>y;
if(head == NULL)
{
cout<<"\nLinked list is empty!!";
return head;
}
p = head;
while(p->next!=NULL)
{
if(p->next->roll==y)
{
q = p->next;
p->next = p->next->next;
delete q;
}
p = p->next;
}
return head;
}
student* student::total(student *head)
{
student *p;
int total = 0;
for(p = head; p!=NULL; p = p->next)
{
total++;
}
cout<<"\nTotal Number of students are: "<<total<<endl;
}
student* student::con(student *head,student *head1)
{
student *p;
for(p = head; p->next!=NULL; p = p->next);
p->next = head1;
return head;
}
int main()
{
int flag = 1;
int flag1 = 1;
int flag2 = 1;
int char0,char1,char2;
student *head,*head1;
student obj;
while(flag)
{
cout<<"\nYOUR CHOICES ARE: ";
cout<<"\n1. LINKED LIST1: \n2. LINKED LIST2: \n3. CONCATENATE LINKED LIST 1 & 2: \n4. EXIT";
cout<<"\nEnter choice: ";
cin>>char0;
switch(char0)
{
case 1:
while(flag1)
{
cout<<"\nWhat operations on list1 would you like to perform?";
cout<<"\n1. Enter prn, name of members: \n2. Add new president: \n3. Add secretary: \n4. Add new members: \n5. Remove president: \n6. Remove secretary: \n7. Remove members: \n8. Total members present: \n9. Exit ";
cout<<"\nEnter choice: ";
cin>>char1;
switch(char1)
{
case 1:
head = obj.create();
obj.display(head);
break;
case 2:
head = obj.beg_add(head);
obj.display(head);
break;
case 3:
head = obj.end_add(head);
obj.display(head);
break;
case 4:
head = obj.btwn_add(head);
obj.display(head);
break;
case 5:
cout<<"\nRemoved president: ";
head = obj.beg_del(head);
obj.display(head);
break;
case 6:
cout<<"\nRemoved secretary: ";
obj.end_del(head);
obj.display(head);
break;
case 7:
head = obj.btwn_del(head);
cout<<"\nMember removed: ";
obj.display(head);
break;
case 8:
obj.total(head);
break;
case 9:
flag1 = 0;
break;
default:
cout<<"\nEnter valid choice!!!";
break;
}
}
break;
case 2:
while(flag2)
{
cout<<"\nWhat operations on list1 would you like to perform?";
cout<<"\n1. Enter prn, name of members: \n2. Add new president: \n3. Add secretary: \n4. Add new members: \n5. Remove president: \n6. Remove secretary: \n7. Remove members: \n8. Total members present: \n9. Exit ";
cout<<"\nEnter choice: ";
cin>>char2;
switch(char2)
{
case 1:
head1 = obj.create();
obj.display(head1);
break;
case 2:
head1 = obj.beg_add(head1);
obj.display(head1);
break;
case 3:
head1 = obj.end_add(head1);
obj.display(head1);
break;
case 4:
head1 = obj.btwn_add(head1);
obj.display(head1);
break;
case 5:
cout<<"\nRemoved president: ";
head1 = obj.beg_del(head1);
obj.display(head1);
break;
case 6:
cout<<"\nRemoved secretary: ";
obj.end_del(head1);
obj.display(head1);
break;
case 7:
head1 = obj.btwn_del(head1);
cout<<"\nMember removed: ";
obj.display(head1);
break;
case 8:
obj.total(head1);
break;
case 9:
flag2 = 0;
break;
default:
cout<<"\nEnter valid choice!!!";
break;
}
}
break;
case 3:
head = obj.con(head,head1);
obj.display(head);
break;
case 4:
flag = 0;
break;
default:
cout<<"\nEnter valid choice: ";
break;
}
}
return 0;
}

View File

@ -1,92 +1,97 @@
# DSL - Assignment 2 '''
Problem Statement: Write a Python program to store marks scored in subject Fundamental of Data Structure by N students in the class. Write functions to compute following:
a) The average score of class
b) Highest score and lowest score of class
c) Count of students who were absent for the test
d) Display mark with highest frequency
students=[] Code from Data Structure Lab (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-codes/DSL
'''
# BEGINNING OF CODE
# List for storing marks
marks = [] marks = []
total_students_in=int(input("Total number of students are: \t")) total = int(input("Total number of students are:\t"))
# Entering marks # Input marks
def total_students_fn(): def marksInput():
for i in range(total_students_in): print("\n----------\nNOTE: PLEASE ENTER MARKS OUT OF 50. ENTER '-1' FOR ABSENT STUDENTS.\n----------\n")
marks_in=int(input("Enter marks for DSA subject for each student (out of 50) (enter -1 for absent students): \t")) for i in range(total):
marks.append(marks_in) enterMarks = int(input(f"Enter marks for student {i+1}:\t"))
print("Marks of", total_students_in, "students in DSA subject are:", marks) marks.append(enterMarks)
print(f"\n-----\nMarks of {total} students are:\t{marks}\n-----")
total_students_fn() # Option 1 = Average score
# Option 1 = Average
def average_marks(): def average_marks():
marks_withoutAbsent = []
for i in marks: for i in marks:
if i<0: if (i >= 0):
break marks_withoutAbsent.append(i)
else: else:
average_calc=sum(marks)/total_students_in continue
print("Average score of", total_students_in, "is: \t", average_calc) average_calc = sum(marks_withoutAbsent) / total
print(f"\n------\nAverage score of {total} students is:\t{average_calc}\n-----")
# Option 2 = Highest and lowest # Option 2 = High and low marks
def high_low(): def high_low():
mini=marks[0] maxi = marks[0] # Initialise maxi with the first element of the marks list
maxi=marks[0] mini = marks[0] # Initialise mini with the first element of the marks list
for i in range(len(marks)): for i in range(len(marks)):
if (maxi < marks[i] and marks[i] > -1): if (maxi < marks[i] and marks[i] > -1):
maxi = marks[i] maxi = marks[i]
for j in range(len(marks)): for j in range(len(marks)):
if (mini > marks[j] and marks[j] > -1): if (mini > marks[j] and marks[j] > -1):
mini = marks[j] mini = marks[j]
print("Highest marks are: \t", maxi) print(f"\n-----\nHighest score is:\t{maxi}\nLowest score is:\t{mini}\n-----")
print("Lowest marks are: \t", mini)
# Option 3 = Absent # Option 3 = Absent count
def absent(): def absent():
absent_count=0 absent_count = 0;
for i in marks: for i in marks:
if i==-1: if (i < 0):
absent_count+=1 absent_count+=1
print("Total number of absent students out of", total_students_in, "are: \t", absent_count)
# Option 4 = Highest freq
def high_freq():
freq_count=0
for i in range(len(marks)):
if (i>=0):
count=0
for j in range(len(marks)):
if (marks[i]==marks[j]):
count+=1
if (freq_count<count):
freq_count=count
else: else:
break continue
print("Highest frequency is: \t", freq_count) print(f"\n-----\nTotal absent students are:\t{absent_count}\n-----")
# Choosing an option # Option 4 = Highest frequency
def choose_optn(): def high_freq():
while True: freq_count = 0 # Initialise frequency counter
print("Choose an operation to perform:") for i in range(len(marks)): # Iterate through marks list using i
print("1. Average score of all students") if (marks[i] >= 0): # Only consider non-negative marks (since -1 is absent)
print("2. Highest and lowest score out of all students") temp_count = 0 # Initialise temporary counter
print("3. Count of students absent for test") for j in range(len(marks)): # Iterate through marks list using j again
print("4. Display marks with highest frequency") if (marks[i] == marks[j]):
print("5. Exit") temp_count+=1
optn=int(input("Enter option number (1-5): \t")) if (freq_count < temp_count): # If temp_count is greater than freq_count value, then
if optn==1: freq_count = temp_count # Make freq_count equal to temp_count
print(f"\n-----\nHighest frequency is:\t{freq_count}\n-----")
def main():
marksInput()
while (1):
print("\n----- MAIN MENU -----")
print("1 -> Average score of class")
print("2 -> Highest and lowest score of class")
print("3 -> Total absent students")
print("4 -> Marks with highest frequency")
print("5 -> Exit")
optn = int(input("Choose an option (1-5):\t"))
if (optn == 1):
average_marks() average_marks()
print("Designed and Engineered by Kshitij") elif (optn == 2):
elif optn==2:
high_low() high_low()
print("Designed and Engineered by Kshitij") elif (optn == 3):
elif optn==3:
absent() absent()
print("Designed and Engineered by Kshitij") elif (optn == 4):
elif optn==4:
high_freq() high_freq()
print("Designed and Engineered by Kshitij") elif (optn == 5):
elif optn==5: print("\n\n## END OF CODE\n\n")
print("## Designed and Engineered by Kshitij\n## END OF CODE.")
quit() quit()
else: else:
print("\n Invalid option selected. Please choose from range 1 to 5. \n") print("\n\nPlease choose a valid option (1-5)\n\n")
choose_optn() main()
# END OF CODE
choose_optn()
## END OF CODE

240
assignment-20.cpp Executable file
View File

@ -0,0 +1,240 @@
/*
The ticket booking system of Cinemax theater has to
be implemented using C++ program.
There are 10 rows and 7 seats in each row. Doubly
circular linked list has to be maintained
to keep track of free seats at rows. Assume some
random booking to start with. Use array to store
pointers (Head pointer) to each row. On demand
a) The list of available seats is to be displayed
b) The seats are to be booked
c) The booking can be cancelled
*/
#include <iostream>
#include<stdlib.h>
using namespace std;
class node
{ public:
node* next;
node* prev;
int seat;
string id;
int status;
};
class cinemax
{
public:
node* head,* tail ,* temp;
cinemax()
{
head=NULL;
}
void create_list();
void display();
void book();
void cancel();
void avail();
};
void cinemax::create_list()
{
int i=1;
temp=new node;
temp->seat=1;
temp->status=0;
temp->id="null";
tail=head=temp;
for(int i=2;i<=70;i++)
{
node *p;
p= new node;
p->seat=i;
p->status=0;
p->id="null";
tail->next=p;
p->prev=tail;
tail=p;
tail->next=head;
head->prev=tail;
}
}
void cinemax::display()
{
{ int r=1;
node* temp;
temp=head;
int count=0;
cout<<"\n------------------------------------------------------------------------------------\n";
cout<<" Screen this way \n";
cout<<"------------------------------------------------------------------------------------\n";
while(temp->next!=head)
{
if(temp->seat/10==0)
cout<<"S0"<<temp->seat<<" :";
else
cout<<"S"<<temp->seat<<" :";
if(temp->status==0)
cout<<"|___| ";
else
cout<<"|_B_| ";
count++;
if(count%7==0)
{
cout<<endl;
r++;
}
temp=temp->next;
}
cout<<"S"<<temp->seat<<" :";
if(temp->status==0)
cout<<"|___| ";
else
cout<<"|_B_| ";
}
}
void cinemax::book()
{ int x;
string y;
label:
cout<<"\n\n\nEnter seat number to be booked\n";
cin>>x;
cout<<"Enter your ID number\n";
cin>>y;
if(x<1||x>70)
{
cout<<"Enter correct seat number to book (1-70)\n";
goto label;
}
node *temp;
//temp=new node;
temp=head;
while(temp->seat!=x)
{
temp=temp->next;
}
if(temp->status==1)
cout<<"Seat already booked!\n";
else{
temp->status=1;
temp->id=y;
cout<<"Seat "<<x<<" booked!\n";
}
}
void cinemax::cancel()
{
int x;
string y;
label1:
cout<<"Enter seat number to cancel booking\n";
cin>>x;
cout<<"Enter you ID\n";
cin>>y;
if(x<1||x>70)
{
cout<<"Enter correct seat number to cancel (1-70)\n";
goto label1;
}
node *temp;
//temp=new node;
temp=head;
while(temp->seat!=x)
{
temp=temp->next;
}
if(temp->status==0)
{
cout<<"Seat not booked yet!!\n";
}
else
{
if(temp->id==y)
{
temp->status=0;
cout<<"Seat Cancelled!\n";
}
else
cout<<"Wrong User ID !!! Seat cannot be cancelled!!!\n";
}
}
void cinemax::avail()
{
int r=1;
node* temp;
temp=head;
int count=0;
cout<<"\n\n\n\n";
cout<<"\n------------------------------------------------------------------------------------\n";
cout<<" Screen this way \n";
cout<<"------------------------------------------------------------------------------------\n";
while(temp->next!=head)
{
{
if(temp->seat/10==0)
cout<<"S0"<<temp->seat<<" :";
else
cout<<"S"<<temp->seat<<" :";
if(temp->status==0)
cout<<"|___| ";
else if(temp->status==1)
cout<<" ";
count++;
if(count%7==0)
{
cout<<endl;
}
}
temp=temp->next;
}
if(temp->status==0)
{
cout<<"S"<<temp->seat<<" :";
if(temp->status==0)
cout<<"|___| ";
}
}
int main()
{ cinemax obj;
obj.create_list();
int ch;
char c='y';
while(c=='y')
{ obj.display();
cout<<"\n*********************************************\n";
cout<<" CINEMAX MOVIE THEATRE\n";
cout<<"*********************************************\n";
cout<<"\nEnter Choice\n1.Current SeatStatus\n2.Book Seat \n3.Available Seat\n4.CancelSeat\n";
cin>>ch;
switch(ch)
{
case 1:obj.display();
break;
case 2: obj.book();
break;
case 3:obj.avail();
break;
case 4: obj.cancel();
break;
default: cout<<"Wrong choice input\n";
}
cout<<"\nDo you want to perform any other operation : (y/n)\n";
cin>>c;
}
return 0;
}

192
assignment-26.cpp Normal file
View File

@ -0,0 +1,192 @@
#include<iostream>
using namespace std;
class stack1
{
int top;
char stack2[100];
char infix[100];
public:
stack1()
{
top = -1;
}
void infix1();
void check();
int check1(char tkn);
void push(int x);
int pop();
bool isEmpty();
bool isFull();
void display();
};
bool stack1::isEmpty()
{
if(top == -1)
{
return true;
}
else
{
return false;
}
}
bool stack1::isFull()
{
if(top == 100 - 1)
{
return true;
}
else
{
return false;
}
}
void stack1::push(int x)
{
if(!isFull())
{
top++;
stack2[top] = x;
}
else
{
cout<<"Stack is full!!\n";
}
}
int stack1::pop()
{
int x;
if(!isEmpty())
{
x = stack2[top];
top--;
return x;
}
else
{
cout<<"Stack is empty!!\n";
}
}
int stack1::check1(char tkn)
{
if(isEmpty())
{
return 0;
}
if(stack2[top] == '(')
{
if(tkn == ')')
{
return 1;
}
else
{
return 0;
}
}
if(stack2[top] == '{')
{
if(tkn == '}')
{
return 1;
}
else
{
return 0;
}
}
if(stack2[top] == '[')
{
if(tkn == ']')
{
return 1;
}
else
{
return 0;
}
}
}
void stack1::check()
{
char tkn;
int x = 0;
for(int i = 0; infix[i]!='\0'; i++)
{
tkn = infix[i];
if(tkn == '('||tkn == ')'||tkn == '['||tkn == ']'||tkn == '{'||tkn == '}')
{
if(tkn == '('||tkn == '['||tkn == '{')
{
push(tkn);
}
if(tkn == '}'||tkn == ']'||tkn == ')')
{
x = check1(tkn);
if(x == 1)
{
pop();
}
else
{
push(tkn);
break;
}
}
}
}
if(!isEmpty())
{
cout<<"Equation is not paranthesized!!\n";
}
else
{
cout<<"Equation is paranthesized!!\n";
}
}
void stack1::infix1()
{
cout<<"\nEnter infix expression(end expression with '#'): ";
for(int i = 0; i < 100; i++)
{
cin>>infix[i];
if(infix[i] == '#')
{
infix[i] = '\0';
break;
}
}
}
void stack1::display()
{
for(int i = 0; infix[i]!= '\0'; i++)
{
cout<<infix[i];
}
cout<<"\n";
}
int main()
{
int ch = 0;
do
{
stack1 obj;
obj.infix1();
obj.display();
obj.check();
cout<<"\nDO YOU WANT TO CHECK ANOTHER EXPRESSION?\n";
cout<<"1. YES \n2. NO \n";
cin>>ch;
}while(ch == 1);
return 0;
}

111
assignment-27.cpp Normal file
View File

@ -0,0 +1,111 @@
#include<iostream>
#include<ctype.h>
using namespace std;
class stack
{
int top;
char data[20];
public:
stack()
{
top=-1;
}
void conversion(char infix[20],char postfix[20])
{
int j=0,i;
char e,token,x;
for(i=0;infix[i]!='\0';i++)
{
token=infix[i];
if(isalnum(token))
{
postfix[j]=token;
j++;
}
else
{
if(token=='(')
push(token);
else if(token==')')
{
while((x=pop())!='(')
{
postfix[j]=x;
j++;
}
}
else
{
e=topmost();
while(precedence(token)<=precedence(e) && !empty())
{
x=pop();
postfix[j]=x;
j++;
}
push(token);
}
}
}
while(!empty())
{
x=pop();
postfix[j]=x;
j++;
}
postfix[j]='\0';
}
void push(int x)
{
top++;
data[top]=x;
}
int pop()
{
char x;
x=data[top];
top--;
return x;
}
char topmost()
{
char e;
e=data[top];
return e;
}
int precedence(char x)
{
if(x=='(')
return 0;
if(x=='+'|| x=='-')
return 1;
if(x=='*'|| x=='/' ||x=='%')
return 2;
else
return 3;
}
int empty()
{
if(top==-1)
return 1;
else
return 0;
}
};
int main()
{
stack s;
char infix[20],postfix[20];
cout<<"Enter the infix expression: ";
cin>>infix;
s.conversion(infix,postfix);
cout<<"Post fix expression is: "<<postfix;
return 0;
}

View File

@ -1,190 +0,0 @@
#include <iostream>
using namespace std;
class queue
{
int data[20];
int f, r;
public:
queue()
{
f = -1;
r = -1;
}
int isempty()
{
if (f == -1)
{
return 1;
}
else
{
return 0;
}
}
int isfull()
{
if (r >= 20)
{
return 1;
}
else
{
return 0;
}
}
void enqueue(int x)
{
if (isfull() == 1)
{
cout << "job queue is full" << endl;
}
else
{
if (f == -1)
f++;
r++;
data[r] = x;
}
}
void dequeue()
{
int x;
if (isempty())
{
cout << "job queue is empty" << endl;
}
else
{
x = data[f];
f++;
cout << x << "Job deleted " << endl;
}
}
void disp()
{
cout << "job queue is as :" << endl;
for (int i = f; i <= r; i++)
{
cout << data[i] << " ";
}
cout << endl;
}
};
int main()
{
int ch, n, x, d;
queue q;
cout << "Enter the no. of jobs in queue. " << endl;
cin >> n;
cout << "Enter jobs " << endl;
for (int i = 0; i < n; i++)
{
cin >> d;
q.enqueue(d);
}
do
{
cout << "**********MENU**********" << endl;
cout << "1)Add job " << endl;
cout << "2)Delete job " << endl;
cout << "3)Display" << endl;
cout << endl;
cout << "Enter your choice " << endl;
cin >> ch;
switch (ch)
{
case 1:
cout << "Enter the job to be added " << endl;
cin >> d;
q.enqueue(d);
cout << "Job added" << endl;
q.disp();
break;
case 2:
q.dequeue();
q.disp();
break;
case 3:
q.disp();
break;
default:
cout << "Invalid choice" << endl;
break;
}
cout << "Do you want to continue" << endl;
cout << "1. YES" << endl;
cout << "2. NO" << endl;
cin >> x;
} while (x == 1);
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~ Output ~~~~~~~~~~~~~~~~~~~~~~~~~
Enter the no. of jobs in queue.
10
Enter jobs
1
2
3
4
5
6
7
8
9
10
**********MENU**********
1)Add job
2)Delete job
3)Display
Enter your choice
3
job queue is as :
1 2 3 4 5 6 7 8 9 10
Do you want to continue
1. YES
2. NO
1
**********MENU**********
1)Add job
2)Delete job
3)Display
Enter your choice
11
Invalid choice
Do you want to continue
1. YES
2. NO
1
**********MENU**********
1)Add job
2)Delete job
3)Display
Enter your choice
2
1Job deleted
job queue is as :
2 3 4 5 6 7 8 9 10
Do you want to continue
1. YES
2. NO
2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

132
assignment-29.cpp Normal file
View File

@ -0,0 +1,132 @@
#include <iostream>
using namespace std;
class queue {
// Class for queue.
int data[30];
int front,rear;
public:
queue() {
// Constructor that initialises values for front and rear.
front=-1;
rear=-1;
}
int emptyCheck() {
// Check if it's empty
if (front==-1 || front>rear) {
return 1;
}
else {
return 0;
}
}
int fullCheck() {
// Check if it's full
if (rear>=30) {
return 1;
}
else {
return 0;
}
}
void enqueue(int x) {
// Add job to queue
if (fullCheck()==1) {
cout<<endl<<"Job queue is full."<<endl;
}
else {
if (front==-1) {
front++;
}
rear++;
data[rear]=x;
}
}
void dequeue() {
// Remove job from queue.
int x;
if (emptyCheck()) {
cout<<endl<<"Job queue is empty."<<endl;
}
else {
x=data[front];
front++;
cout<<endl<<"Job ["<<x<<"] has been deleted.";
}
}
void display() {
// Displaying job queue.
cout<<"Job queue is:\t[ ";
for (int i=front; i<=rear; i++) {
cout<<data[i]<<" | ";
}
cout<<"]"<<endl;
}
};
int main() {
// Main function
int choice, job, totalJobs;
queue jobQueue;
//Input inital jobs
cout<<"Enter number of jobs:\t";
cin>>totalJobs;
for (int i=0; i<totalJobs; i++) {
cout<<endl<<"Enter job number "<<i+1<<":\t";
cin>>job;
jobQueue.enqueue(job);
}
while (1) {
cout<<endl<<"----- JOB QUEUE MENU -----"<<endl;
cout<<endl<<"1 -> Add job to queue"<<endl;
cout<<endl<<"2 -> Delete a job from queue"<<endl;
cout<<endl<<"3 -> Display queue"<<endl;
cout<<endl<<"4 -> Exit"<<endl;
cout<<endl<<endl<<"Choose an option (1-4):\t";
cin>>choice;
switch (choice) {
case 1:
cout<<"Add additional job:\t";
cin>>job;
jobQueue.enqueue(job);
cout<<"\n==============\n";
jobQueue.display();
cout<<"=============\n";
break;
case 2:
jobQueue.dequeue();
cout<<"\n==============\n";
jobQueue.display();
cout<<"=============\n";
break;
case 3:
cout<<"\n==============\n";
jobQueue.display();
cout<<"=============\n";
break;
case 4:
cout<<"\n## DESIGNED AND ENGINEERED BY KSHITIJ\n## END OF CODE\n\n";
exit(0);
default:
cout<<endl<<"Please choose a valid option (1-4)."<<endl;
}
}
return 0;
}

172
assignment-31.cpp Normal file
View File

@ -0,0 +1,172 @@
#include<iostream>
using namespace std;
class deque1
{
public:
int f,r,data[100],n;
deque1()
{
f = r = -1;
cout<<"Enter number of elements: ";
cin>>n;
}
void enqueuef();
void enqueuer();
void dequeuef();
void dequeuer();
bool isEmpty();
bool isFull();
void display();
};
void deque1::enqueuef()
{
int id;
cout<<"\nEnter element: ";
cin>>id;
if(!isFull())
{
if(f == -1)
f = r = 0;
else if(f == 0)
f = n - 1;
else
f--;
data[f] = id;
}
else
cout<<"\nQueue is full....\n";
}
void deque1::enqueuer()
{
int id;
cout<<"\nEnter element: ";
cin>>id;
if(!isFull())
{
if(f == -1)
f = r = 0;
else if(r == n - 1)
r = 0;
else
r++;
data[r] = id;
}
else
cout<<"\nQueue is full....\n";
}
void deque1::dequeuef()
{
if(!isEmpty())
{
if(f == r)
f = r = -1;
else if(f == n-1)
f = 0;
else
f++;
}
else
cout<<"\nQueue is empty....\n";
}
void deque1::dequeuer()
{
if(!isEmpty())
{
if(f == r)
f = r = -1;
else if(r == 0)
r = n-1;
else
r--;
}
else
cout<<"\nQueue is empty....\n";
}
void deque1::display()
{
int i;
cout<<"\nDeque: ";
if(!isEmpty())
{
i = f;
do
{
cout<<data[i]<<" ";
i = (i+1)%n;
}while(i != (r+1)%n);
}
else
cout<<"\nQueue is empty....\n";
cout<<"\n";
}
bool deque1::isFull()
{
if((f==0 && r >= n - 1)|| f==r+1)
return true;
else
return false;
}
bool deque1::isEmpty()
{
if(r == -1)
return true;
else
return false;
}
int main()
{
deque1 obj;
int ch;
bool flag = true;
while(flag)
{
cout<<"\n****YOUR CHOICES ARE****\n";
cout<<"\n1. Enqueue(at front) \n2. Enqueue(at rear) \n3. Dequeue(at front) \n4. Dequeue(at rear) \n5. Display queue \n6. Exit";
cout<<"\nEnter your choice: ";
cin>>ch;
switch(ch)
{
case 1:
obj.enqueuef();
obj.display();
break;
case 2:
obj.enqueuer();
obj.display();
break;
case 3:
obj.dequeuef();
obj.display();
break;
case 4:
obj.dequeuer();
obj.display();
break;
case 5:
obj.display();
break;
case 6:
flag = false;
break;
default:
cout<<"\nEnter valid choice!!!\n";
break;
}
}
return 0;
}

125
assignment-32.cpp Normal file
View File

@ -0,0 +1,125 @@
#include <iostream>
using namespace std;
#define size 5
class pizza
{
int porder[size];
int front, rear;
public:
pizza()
{
front = rear = -1;
}
int qfull()
{
if (front == (rear + 1) % size)
return 1;
else
return 0;
}
int qempty()
{
if (front == -1)
return 1;
else
return 0;
}
void accept_order(int item)
{
if (qfull())
cout << "\nVery Sorry !!!! No more orders....\n";
else
{
if (front == -1)
{
front = rear = 0;
}
else
{
rear = (rear + 1) % size;
}
porder[rear] = item;
}
}
void make_payment(int n)
{
int item;
char ans;
if (qempty())
cout << "\nSorry !!! order is not there...\n";
else
{
cout << "\nDeliverd orders as follows...\n";
for (int i = 0; i < n; i++)
{
item = porder[front];
if (front == rear)
{
front = rear = -1;
}
else
{
front = (front + 1) % size;
}
cout << "\t" << item;
}
cout << "\nTotal amount to pay : " << n * 100;
cout << "\nThank you visit Again....\n";
}
}
void order_in_queue()
{
int temp;
if (qempty())
{
cout << "\nSorry !! There is no pending order...\n";
}
else
{
temp = front;
cout << "\nPending Order as follows..\n";
while (temp != rear)
{
cout << "\t" << porder[temp];
temp = (temp + 1) % size;
}
cout << "\t" << porder[temp];
}
}
};
int main()
{
pizza p1;
int ch, k, n;
do
{
cout << "\n\t***** Welcome To Pizza Parlor *******\n";
cout << "\n1.Accept order\n2.Make_payment\n3.Pending Orders\nEnter u r choice:";
cin >> ch;
switch (ch)
{
case 1:
cout << "\nWhich Pizza would do u like to have today\n";
cout << "\n1.Veg Soya Pizza\n2.Veg butter Pizza\n3.Egg_Pizza";
cout << "\nPlease enter your order: ";
cin >> k;
p1.accept_order(k);
break;
case 2:
cout << "\nHow many Pizza ?";
cin >> n;
p1.make_payment(n);
break;
case 3:
cout << "\n Following orders are in queue to deliver....as follows..\n";
p1.order_in_queue();
break;
}
} while (ch != 4);
return 0;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
notes/Deore's QBank.docx Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
notes/Unit 3/quicksort.ppt Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

133
notes/Unit 6/Dqueue.cpp Normal file
View File

@ -0,0 +1,133 @@
#include<iostream>
using namespace std;
#define SIZE 20
class dequeue
{
int a[20],f,r;
public:
dequeue();
void insert_at_beg(int);
void insert_at_end(int);
void delete_fr_front();
void delete_fr_rear();
void show();
};
dequeue::dequeue()
{
f=-1;
r=-1;
}
void dequeue::insert_at_end(int i)
{
if(r>=SIZE-1)
cout<<"insertion is not possible, overflow!!!!";
else
{
if(f==-1)
{
f++;
r++;
}
else
r=r+1;
a[r]=i;
cout<<"Inserted item is"<<a[r];
}
}
void dequeue::insert_at_beg(int i) {
if(f==-1) {
f=0;
a[++r]=i;
cout<<" inserted element is:"<<i;
}
else if(f!=0)
{
a[--f]=i;
cout<<" inserted element is:"<<i;
}
else {
cout<<" insertion is not possible, overflow!!!";
}
}
void dequeue::delete_fr_front() {
if(f==-1) {
cout<<"deletion is not possible::dequeue is empty";
return;
}
else {
cout<<"the deleted element is:"<<a[f];
if(f==r) {
f=r=-1;
return;
} else
f=f+1;
}
}
void dequeue::delete_fr_rear() {
if(f==-1) {
cout<<"deletion is not possible::dequeue is empty";
return;
}
else {
cout<<"the deleted element is:"<<a[r];
if(f==r) {
f=r=-1;
} else
r=r-1;
}
}
void dequeue::show() {
if(f==-1) {
cout<<"Dequeue is empty";
} else {
for(int i=f;i<=r;i++) {
cout<<a[i]<<" ";
}
}
}
int main()
{
int c,i;
dequeue d;
do//perform switch opeartion
{
cout<<" 1.insert at beginning";
cout<<" 2.insert at end";
cout<<" 3.show";
cout<<" 4.deletion from front";
cout<<" 5.deletion from rear";
cout<<" 6.exit";
cout<<" enter your choice:";
cin>>c;
switch(c)
{
case 1:
cout<<"enter the element to be inserted";
cin>>i;
d.insert_at_beg(i);
break;
case 2:
cout<<"enter the element to be inserted";
cin>>i;
d.insert_at_end(i);
break;
case 3:
d.show();
break;
case 4:
d.delete_fr_front();
break;
case 5:
d.delete_fr_rear();
break;
default:
cout<<"invalid choice";
break;
}
}while(c!=7);
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,158 @@
#include<iostream>
#include<string>
#define N 20
#define SERIOUS 10
#define NONSERIOUS 5
#define CHECKUP 1
using namespace std;
string Q[N];
int Pr[N];
int r = -1,f = -1;
void enqueue(string data,int p)//Enqueue function to insert data and its priority in queue
{
int i;
if((f==0)&&(r==N-1)) //Check if Queue is full
cout<<"Queue is full";
else
{
if(f==-1)
{ //if Queue is empty
f = r = 0;
Q[r] = data;
Pr[r] = p;
}
else if(r == N-1)
{ //if there there is some elemets in Queue
for(i=f;i<=r;i++)
{
Q[i-f] = Q[i];
Pr[i-f] = Pr[i];
r = r-f;
f = 0;
for(i = r;i>f;i--)
{
if(p>Pr[i])
{
Q[i+1] = Q[i];
Pr[i+1] = Pr[i];
}
else break;
Q[i+1] = data;
Pr[i+1] = p;
r++;
}
}
}
else
{
for(i = r;i>=f;i--)
{
if(p>Pr[i])
{
Q[i+1] = Q[i];
Pr[i+1] = Pr[i];
}
else break;
}
Q[i+1] = data;
Pr[i+1] = p;
r++;
}
}
}
void print() { //print the data of Queue
int i;
for(i=f;i<=r;i++) {
cout << "Patient's Name - "<<Q[i];
switch(Pr[i]) {
case 1:
cout << " Priority - 'Checkup' " << endl;
break;
case 5:
cout << " Priority - 'Non-serious' " << endl;
break;
case 10:
cout << " Priority - 'Serious' " << endl;
break;
default:
cout << "Priority not found" << endl;
}
}
}
void dequeue() { //remove the data from front
if(f == -1)
{
cout<<"Queue is Empty";
}
else
{
cout<<"deleted Element ="<<Q[f]<<endl;
cout<<"Its Priority = "<<Pr[f]<<endl;
if(f==r) f = r = -1;
else f++;
}
}
int main()
{
string data;
int opt,n,i,p;
cout<<"Enter Your Choice:-"<<endl;
do {
cout << "\n 1 : Insert the Data in Queue" << endl << "2: Display the Queue " << endl << "3: Delete the data from the Queue"
<< endl << "0 for Exit"<< endl;
cin >> opt;
switch(opt) {
case 1:
cout << "Enter the number of Patient" << endl;
cin >> n;
i = 0;
while(i < n) {
cout << "Enter your name of the patient : ";
cin >> data;
ifnotdoagain:
cout << "Enter your Priority (0: serious, 1: non-serious, 2: general checkup) : ";
cin >> p;
switch(p) {
case 0:
enqueue(data,SERIOUS);
break;
case 1:
enqueue(data,NONSERIOUS);
break;
case 2:
enqueue(data,CHECKUP);
break;
default:
goto ifnotdoagain;
}
i++;
}
break;
case 2:
print();
break;
case 3:
dequeue();
break;
case 0:
cout << "Bye Bye !" << endl;
break;
default:
cout<<"Incorrect Choice"<<endl;
}
}while(opt!=0);
return 0;
}

Binary file not shown.

Binary file not shown.

View File

@ -1,38 +0,0 @@
no = int(input("Enter number of students: "))
list2 = []
#list1 = []
for i in range(0,no):
n = float(input("Enter % of student: "))
list2.append(n)
print(list2)
d = len(list2)
def partition(list3,a,b):
v = list3[a]
i = a
j = b-1
temp = 0
while(i<j):
while(list3[i]<=v and i<=j):
i = i + 1
while(list3[j] > v):
j = j - 1
if(i<j):
temp = list3[i]
list3[i] = list3[j]
list3[j] = temp
list3[a] = list3[j]
list3[j] = v
return j
def quicksort(list1, l, u):
j = 0
if(l<u):
j = partition(list1,l,u)
quicksort(list1,l,j - 1)
quicksort(list1,j+1,u)
list2 = list1
return list2
o = quicksort(list2,0,d)
print("Sorted list is: ",o)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
write-ups/assignment-5 (string).pdf Executable file → Normal file
View File