New branch, testing

This commit is contained in:
K 2023-09-29 15:48:26 +05:30
parent 2593f83785
commit 1861b31953
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F
23 changed files with 0 additions and 38480 deletions

View File

@ -1,55 +0,0 @@
# DSL
Explore our Data Structure Lab repo: codes, lab manuals, write-ups. Ace your assignments with practical examples and clear guidance.
---
In this repository, you'll find codes for Data Structure Lab.
## Index
### Codes
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)
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_
14. [DSL - Assignment 14 (Selection, Bubble Sorting)](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/assignment-14.py)
### 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)
2. Assignment 2 - Marks - _PENDING_
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_
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)
### Lab Manuals
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)
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)
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)
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)
33. [Mini Project](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/lab-manuals/Miniproject.doc)
### Notes
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)
3. [Unit 3 - Searching and Sorting](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/notes/Unit%203)
---
### Work in progress
> These are the codes we're working on. They *may not work* the way intended.
[quicksortEarlyAccess.py](https://git.kska.io/sppu-se-comp-codes/DSL/src/branch/main/quicksortEarlyAccess.py)
---
Maintained by [notkshitij](https://git.kska.io/notkshitij) and [TanmaySpamzzz](https://git.kska.io/TanmaySpamzzz)

View File

@ -1,117 +0,0 @@
# DSL Assignment - 1
# List of players
cricket_players=[]
badminton_players=[]
football_players=[]
# Input values
## List for cricket players
def cricket_in():
total=int(input("Total number of students playing cricket: \t"))
for i in range(total):
players=int(input("Enter roll number: \t"))
cricket_players.append(players)
print("Roll numbers of", total, "students playing cricket: \t", cricket_players)
cricket_in()
## List for badminton players
def badminton_in():
total=int(input("Total number of students playing badminton: \t"))
for i in range(total):
players=int(input("Enter roll number: \t"))
badminton_players.append(players)
print("Roll numbers of", total, "students playing badminton: \t", badminton_players)
badminton_in()
## List for football players
def football_in():
total=int(input("Total number of students playing football: \t"))
for i in range(total):
players=int(input("Enter roll number: \t"))
football_players.append(players)
print("Roll numbers of", total, "students playing football: \t", football_players)
football_in()
# List of students playing cricket+badminton
cricket_and_badminton=[]
def cricket_and_badminton_fn():
for i in cricket_players:
if i in badminton_players:
cricket_and_badminton.append(i)
print("Roll numbers of students playing cricket and badminton are: \t", cricket_and_badminton)
# List of students playing either cricket or badminton but not both
cricket_or_badminton=[]
def cricket_or_badminton_fn():
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
football_only=[]
football_only_1=[]
def football_only_fn():
for i in cricket_players:
football_only.append(i)
for i in badminton_players:
if i not in cricket_players:
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()
else:
print("\nPlease choose a valid option.\n")
choose_optn()
choose_optn()
## END OF CODE

View File

@ -1,62 +0,0 @@
# Sorting (Selection+Bubble) and Top 5
marks=[]
# Function to enter marks of students
def input_marks():
students=int(input("Enter the number of students:\t"))
for i in range(students):
marks_in=float(input("Enter the marks (out of 50):\t"))
marks.append(marks_in)
print("\nThe marks you've entered for ", students, "students are: ", marks, "\n")
# Function for selection sort
def selection():
for i in range(len(marks)):
min_index=i
for j in range(i+1, len(marks)):
if marks[j] < marks[min_index]:
min_index=j
marks[i], marks[min_index] = marks[min_index], marks[i]
print("Marks sorted in ascending order using selection sort:\t", marks)
def bubble():
for i in range(len(marks)):
for j in range(0, len(marks)-i-1):
if marks[j]>marks[j+1]:
marks[j], marks[j+1] = marks[j+1], marks[j]
print("Marks sorted in ascending order using bubble sort:\t", marks)
def top5():
for i in range(len(marks)):
for j in range(0, len(marks)-i-1):
if marks[j]>marks[j+1]:
marks[j], marks[j+1] = marks[j+1], marks[j]
print("Top 5 marks using bubble sorting:\t", marks[::-1])
def choose_optn():
while True:
print("Choose an option from the menu below:")
print("1 -> Input marks")
print("2 -> Selection Sorting")
print("3 -> Bubble Sorting")
print("4 -> Display top 5")
print("5 -> Exit")
optn=int(input("Choose an option (1-5):\t"))
if optn==1:
input_marks()
elif optn==2:
selection()
elif optn==3:
bubble()
elif optn==4:
top5()
elif optn==5:
print("## DESIGNED AND ENGINEERED BY KSHITIJ\n## END OF CODE")
quit()
else:
print("\nPlease choose a valid option (1-5).\n")
choose_optn()
choose_optn()

View File

@ -1,92 +0,0 @@
# DSL - Assignment 2
students=[]
marks=[]
total_students_in=int(input("Total number of students are: \t"))
# Entering marks
def total_students_fn():
for i in range(total_students_in):
marks_in=int(input("Enter marks for DSA subject for each student (out of 50) (enter -1 for absent students): \t"))
marks.append(marks_in)
print("Marks of", total_students_in, "students in DSA subject are:", marks)
total_students_fn()
# Option 1 = Average
def average_marks():
for i in marks:
if i<0:
break
else:
average_calc=sum(marks)/total_students_in
print("Average score of", total_students_in, "is: \t", average_calc)
# Option 2 = Highest and lowest
def high_low():
mini=marks[0]
maxi=marks[0]
for i in range (len(marks)):
if (maxi<marks[i] and marks[i]>-1):
maxi=marks[i]
for j in range (len(marks)):
if (mini>marks[j] and marks[j]>-1):
mini=marks[j]
print("Highest marks are: \t", maxi)
print("Lowest marks are: \t", mini)
# Option 3 = Absent
def absent():
absent_count=0
for i in marks:
if i==-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:
break
print("Highest frequency is: \t", freq_count)
# Choosing an option
def choose_optn():
while True:
print("Choose an operation to perform:")
print("1. Average score of all students")
print("2. Highest and lowest score out of all students")
print("3. Count of students absent for test")
print("4. Display marks with highest frequency")
print("5. Exit")
optn=int(input("Enter option number (1-5): \t"))
if optn==1:
average_marks()
print("Designed and Engineered by Kshitij")
elif optn==2:
high_low()
print("Designed and Engineered by Kshitij")
elif optn==3:
absent()
print("Designed and Engineered by Kshitij")
elif optn==4:
high_freq()
print("Designed and Engineered by Kshitij")
elif optn==5:
print("## Designed and Engineered by Kshitij\n## END OF CODE.")
quit()
else:
print("\n Invalid option selected. Please choose from range 1 to 5. \n")
choose_optn()
choose_optn()
## END OF CODE

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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

View File

@ -1,99 +0,0 @@
str1 = input("Enter string: ")
substr1 = input("Enter substring: ")
occur1 = input("Enter character whose occurence is to be calculated: ")
occur2 = str1.split()
index1 = []
for i in occur2:
for j in occur2:
if(i == j and j not in index1):
index1.append(i)
else:
continue
def longestWord():
globalMax = 0
currentMax = 0
list1 = []
for i in str1:
if (i != " "):
currentMax = currentMax + 1
list1.append(i)
else:
if (currentMax > globalMax):
globalMax = currentMax
temp = list1
currentMax = 0
list1 = []
if (i == str1[len(str1) - 1]):
if (currentMax > globalMax):
globalMax = currentMax
temp = list1
print("Longest word is: ", "".join(temp))
print("Length of largest word is: ", globalMax)
def palindrome():
rev1 = str1
if (str1[::-1] == rev1):
print("String is palindrome")
else:
print("String is not palindrome")
def charfrequency():
temp = 0
for i in str1:
max1 = 0
for j in range(0, len(str1)):
if (str1[j] != " " and str1[j] == occur1):
max1 = max1 + 1
else:
continue
if (max1 > temp):
temp = max1
else:
continue
print("Number of times the character '", occur1, "' occurs: ", temp)
def indexSubstring():
for i in range(len(str1) - len(substr1) + 1):
if str1[i:i + len(substr1)] == substr1:
print("Substring present in string at index: ", i)
break
else:
print('Substring not present')
def occurWord():
for i in index1:
max1 = 0
for j in occur2:
if(i == j):
max1 = max1 + 1
else:
continue
print("The number of times '",i,"' is repeated is: ",max1)
flag = 1
while flag == 1:
print("1. Display word with longest word: \n")
print("2. The occurence of '",occur1,"' in the string is: \n")
print("3. Check whether is string is palindrome or not: \n")
print("4. Display index of first appearance of the substring: \n")
print("5. Occurrence of each word in the given string: \n")
print("6. Exit")
ch = int(input("Enter your choice: "))
if(ch == 1):
longestWord()
elif(ch == 2):
charfrequency()
elif(ch == 3):
palindrome()
elif(ch == 4):
indexSubstring()
elif(ch == 5):
occurWord()
elif(ch>6 or ch<1):
print("Enter valid choice")
elif(ch == 6):
flag = 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.

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)

File diff suppressed because one or more lines are too long

Binary file not shown.