Omkar Jadhav
Omkar Jadhav
CODE=
#include <iostream>
#define size 100
using namespace
std;
class Stack {
int top = -1;
char
array[size];
public:
void push(char
val); char pop();
void
display();
char pick();
bool
isempty();
};
}
}
}
els
c
o
u
t
<
<
"
S
t
a
c
k
E
m
p
t
y
"
<
<
e
n
d
l
;
r
e
t
u
r
n
-
1
;
{
return array[top--];
}
}
}
}
int main()
{
string
str;
Stack s1;
cout << "Enter a string with parentheses to check if balanced:
"; getline(cin, str); // To allow multi-character string input
{
if (s1.isempty())
{ // No matching opening
bracket flag = 0;
break;
}
last_st = s1.pick();
}
}
}
// Output the
result if (flag ==
1)
cout << "Parentheses are balanced." << endl;
else
cout << "Parentheses are not balanced." << endl;
return 0;
}
OUTPUT=
CODE=
#include<iostream
>
#include<string.h
> #define max 50
using namespace std;
class STACK {
private:
char
a[max];
int top;
public:
STACK()
{
top = -1;
}
void
push(char);
void
reverse();
void
convert(char[]);
void palindrome();
};
void STACK::push(char c) {
top++;
a[top] = c;
a[top + 1] = '\0';
}
void STACK::reverse()
{
char str[max];
cout << "\n\nReverse string is: ";
for (int i = top, j = 0; i >= 0; i--, j++)
{
cout << a[i];
str[j] = a[i];
}
cout << endl;
}
void STACK::convert(char
str[]) { int j, k, len =
strlen(str);
for (j = 0, k = 0; j < len; j++)
{
if ((str[j] >= 97 && str[j] <= 122) || (str[j] >= 65 && str[j] <=
90))
{
if (str[j] <= 90)
{
str[k] = (str[j] + 32); // Convert uppercase to lowercase
}
els
e
{ str[k] = str[j];
}
k+
+;
}
}
str[k] = '\0';
cout << endl << "After removing spaces and converting all characters to
lowercase: " << str << "\n";
}
void STACK::palindrome()
{
char
str[max];
int i, j;
for (i = top, j = 0; i >= 0; i--, j++)
{
str[j] = a[i];
}
str[j] = '\0';
if (strcmp(str, a) == 0)
cout << "\n\nString is palindrome...";
els
e cout << "\n\nString is not palindrome...";
int main()
{
STACK stack;
char
str[max];
int i = 0;
cout << "\nEnter string to be reversed and check if it is palindrome or
not: "; cin.getline(str, 50);
cout << "Original String is: " << str;
stack.convert(str);
while (str[i] != '\0')
{
stack.push(str[i]);
i++;
}
stack.palindrome();
stack.reverse();
}
OUTPUT=
String is palindrome...
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17
CODE=
#include<iostream>
using namespace
std; class cinemax
{
public: int booked;
cinemax *next,*prev;
cinemax()
{
next = prev =
NULL; booked=0;
}
}*head[10],*curr,*last;
void build_cinemax()
{
int i,j;
for(i=1;i<=10;i++)
{
for(j=1;j<=7;j++)
{
curr=new cinemax();
if(head[i] == NULL)
{
head[i]=curr;
last=curr;
}
els
e
{ last->next=curr;
last=curr;
last->next=head[i];
}
}
}
}
void display()
{
int i,j;
for(i=1;i<=10;i++)
{
curr = head[i];
cout<<"Row "<<i<<"- - ->";
for(j=1;j<=7;j++)
{
cout<<curr->booked<<"->";
curr= curr->next;
}
cout<<endl;
}
}
void booking()
{
int
row,col,count;
count=1;
cout<<"\n There are 10 rows and 7 cols are present";
cout<<"\n Enter row no...:";
cin>>row;
cout<<"\n Enter col no...:";
cin>>col;
curr=head[row];
while(curr->next != NULL && count <= 7)
{
if(count==col)
{
if(curr->booked!=1)
{
curr->booked=1;
cout<<"\n Seat is booked \n"<<curr-
>booked; display();
break;
}
els
e
{ cout<<"\n Seat is not available";
}
}
else
{
curr=curr->next;
}
count++;
}
}
void cancel()
{
int row,col,count;
count=1;
cout<<"\n Enter row no...:";
cin>>row;
cout<<"\n Enter col no...:";
cin>>col;
curr=head[row];
while(curr->next != NULL && count <= 7)
{
if(count==col)
{
if(curr->booked==1)
{
curr->booked = 0;
cout<<"Seat is cancel"<<curr-
>booked<<endl; cout<<"Current Seat
Status:"<<endl; display();
}
els
e
{ cout<<"\n Seat is not cancel as it is not booked";
} }
els
e curr=curr->next;
{
count+
+; }
}
}
int main()
{
int
i,ch;
char mt;
build_cinemax()
; do
{
cout<<"\n*****Welcome to Cinemax Booking System*****\
n"; cout<<"\n1)Booking";
cout<<"\n2) Booking
Cancel"; cout<<"\
n3)Display"; cout<<"\
nEnter your choice";
cin>>ch;
switch(ch)
{
case 1:
booking();
// display();
break;
case 2: cancel();
//
display();
break;
case 3:
display();
break;
}
}while(ch!=4);
return 0;
}
OUTPUT=
System***** 1)Booking
2) Booking Cancel
3)Display
Enter your choice1
Seat is booked
1Row 1------>0->0->0->0->0->0->0->
Row 2------>0->0->0->0->0->0->0->
Row 3------>0->0->0->0->0->0->0->
Row 4------>0->0->0->0->0->0->0->
Row 5------>0->0->1->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 7------>0->0->0->0->0->0->0->
Row 8------>0->0->0->0->0->0->0->
Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->
System***** 1)Booking
2) Booking Cancel
3)Display
Enter your
choice2 Enter
row no.....................5
Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->
1) Booking
2) Booking
Cancel
1)Booking
2) Booking Cancel
3)Display
Enter your choice3
Row 1------>0->0->0->0->0->0->0->
2) Booking Cancel
3)Display
Enter your choice3
Row 1------>0->0->0->0->0->0->0->
Row 2------>0->0->0->0->0->0->0->
Row 3------>0->0->0->0->0->0->0->
Enter your choice3
Row 1------>0->0->0->0->0->0->0->
Row 2------>0->0->0->0->0->0->0->
Row 3------>0->0->0->0->0->0->0->
Row 4------>0->0->0->0->0->0->0->
Row 5------>0->0->0->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 2------>0->0->0->0->0->0->0->
Row 3------>0->0->0->0->0->0->0->
Row 4------>0->0->0->0->0->0->0->
Row 5------>0->0->0->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 7------>0->0->0->0->0->0->0->
Row 8------>0->0->0->0->0->0->0->
Row 4------>0->0->0->0->0->0->0->
Row 5------>0->0->0->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 7------>0->0->0->0->0->0->0->
Row 8------>0->0->0->0->0->0->0->
Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->
Row 6------>0->0->0->0->0->0->0->
Row 7------>0->0->0->0->0->0->0->
Row 8------>0->0->0->0->0->0->0->
Row 9------>0->0->0->0->0->0->0->
Row 10------>0->0->0->0->0->0->0->
>0->
Row 10------>0->0->0->0->0->0->0->
System***** 1)Booking
1) Booking
2) Booking
Cancel
3)Display
1)Booking
2) Booking Cancel
3)Display
2) Booking
Cancel
3)Display
Enter your choice4
Name = Jadhav Omkar Pundlik
Branch = Artificial Intelligence & Data
Science Roll No. = 17
CODE=
#include<iostream>
#include<stdlib.h>
using namespace
std; struct node
{
char
prn[10];
char
name[20];
node *next;
}*precident,*secratory,*new1,*curr;
void creat_list()
{
int count,i;
cout<<"\n Enter total no of members in pinacal list...:";
cin>>count;
for(i=0;i<(count-1);i++)
{
if(precident==NULL && secratory==NULL)
{
precident=new node;
cout<<"\n Enter PRN no of precident...";
cin>>precident->prn;
cout<<"\n Enter name of precident. ";
cin>>precident-
>name; precident-
>next=NULL;
curr=precident;
secratory=new node;
cout<<"\n Enter PRN no of secratory...";
cin>>secratory->prn;
cout<<"\n Enter name of secratory. ";
cin>>secratory-
>name; secratory-
>next=NULL;
}
else
{
new1=new node;
cout<<"\n Enter PRN no of membor. . .";
cin>>new1->prn;
cout<<"\n Enter name of membor..";
cin>>new1-
>name; curr-
>next=new1;
new1->next=secratory;
curr=new1;
}
}
}
OUTPUT=
MENU
1)creat
2)display
3) add
mem
4)revers
e
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice........1
......................................................64738
......................................................Rancho
......................................................83765
......................................................87355
......................................................29834
MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......2
64738-Rancho->87355-siya->29834-trisha->83765-
shiv-> MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice........3
......................................................73647
MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......4
83765-shiv->73647-hetal->29834-trisha->87355-siya->64738-
Rancho-> MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......5
MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......6
MENU
1) creat
2)displa
y
3)add mem
4)reverse
5) delete secretory
6) delete
precident
7)countnodes
8)exit
Enter your choice.......7
CODE=
def
quick_sort(studMarks,lb,ub
): if lb<ub:
pivot_index=partition(studMarks,lb,u
b)
quick_sort(studMarks,lb,pivot_index-
1)
quick_sort(studMarks,pivot_index+1,u
b)
def insertion_sort(studMarks):
for i in range(1,
len(studMarks)): key =
studMarks[i]
j = i - 1
while j >= 0 and key <
studMarks[j]: studMarks[j +
1] = studMarks[j] j -= 1
studMarks[j + 1] = key
return studMarks
def print_menu():
print("\nSorting Algorithm
Menu") print("1. Insetion
Sort") print("2. Quick Sort")
print("3.
Exit") def main():
studMarks = []
n = int(input("Enter the number of
students: ")) for _ in range(n):
marks = int(input("Enter the marks:
")) studMarks.append(marks)
while True:
print_menu()
choice = input("Enter your choice (1-3): ")
print("Sorted array:",
sorted_array) else:
print("No valid numbers were entered.")
else:
print("Invalid choice. Please enter a number between 1 and 3.")
main()
INPUT=
OUTPUT=
CODE=
def selection_sort(arr):
for i in
range(len(arr)):
min_index = i
for j in range(i + 1,
len(arr)): if arr[j] <
arr[min_index]:
min_index = j
arr[i], arr[min_index] = arr[min_index],
arr[i] return arr
def
bubble_sort(arr
): n = len(arr)
for i in range(n):
for j in range(0, n-i-
1): if arr[j] >
arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
return arr
def topFive(arr):
print("Top five
students")
last_five=arr[-5:]
top_five=last_five[::-
1] for i in top_five:
print(i)
def
print_menu():
print("\nSorting Algorithm
Menu") print("1. Selection
Sort") print("2. Bubble
Sort") print("3. Exit")
def main():
array=[]
n=int(input("Enter the no. of
students")) for i in range(n):
marks=int(input("Enter your
marks")) array.append(marks)
while True:
print_menu()
choice = input("Enter your choice (1-3): ")
else:
print("Invalid choice. Please enter a number between 1 and 4.")
main()
INPUT=
OUTPUT=
CODE=
def fibonacci_search(roll_stud,
target): arr = sorted(roll_stud)
n = len(arr)
fib_2 = 0
fib_1 = 1
fib_3 = fib_1 + fib_2
fib_2 offset = -1
else:
return True
if fib_1 and offset + 1 < n and arr[offset + 1] ==
target: return True
return
False def
main():
roll_stud = []
n = int(input("Enter the number of
students: ")) for i in range(n):
roll = int(input("Enter the Roll number: "))
roll_stud.append(roll)
while True:
target = int(input("Enter the roll number to find out if that
student was present (0 to exit): "))
if target == 0:
print("Exiting.........."
)
break
if target > 0:
if binary_search(roll_stud, target):
print(f"Roll number {target} attended the training program
(Binary
Search)."
) else:
print(f"Roll number {target} did not attend the training
program
(Binary Search).")
if fibonacci_search(roll_stud, target):
print(f"Roll number {target} attended the training
program (Fibonacci Search).")
else:
print(f"Roll number {target} did not attend the training
program (Fibonacci Search).")
else:
print("Roll number not valid!")
main(
INPUT
=
Enter the number of
students: 4 Enter the Roll
number: 25 Enter the Roll
number: 63 Enter the Roll
number: 14
Enter the Roll number: 58
OUTPUT=
CODE=
return Max
def minimum(listofmarks):
# Initialize Min with a large
number Min = float('inf')
for mark in
listofmarks: if
mark != -999:
if mark < Min:
Min = mark
return Min
def
absentcount(listofmarks)
: count = 0
for mark in
listofmarks: if
mark == -999:
count += 1
return count
# Function for displaying marks with highest
frequency def maxFrequency(listofmarks):
i=0
Max=0
print("Marks |
Frequency") for j in
listofmarks:
if (listofmarks.index(j)==i):
#print(j," | ",listofmarks.count(j))
if
listofmarks.count(j)>M
ax:
Max=listofmarks.count(j
) mark=j
print(j," |
",listofmarks.count(j)) i=i+1
return(mark,Max
) # Main function
marksinFDS=[]
numberofstudents=int(input("Enter total number of students
: ")) for i in range(numberofstudents):
marks=int(input("Enter marks of student "+str(i+1)+" : "))
marksinFDS.append(marks)
flag=1
while flag==1:
print("\n\n MENU \
n") print("1. Total and Average Marks of the Class")
print("2. Highest and Lowest Marks in the Class")
print("3. Number of Students absent for the test")
print("4. Marks with Highest Frequency")
print("5. Exit\n")
ch=int(input("Enter your Choice (from 1 to 5) :"))
if ch==1:
average(marksinFDS)
a = input("Do you want to continue (yes/no)
:") if a == "yes":
flag = 1
else:
flag = 0
print("Thanks for using this program!")
elif ch==2:
print("Highest Score in Class : ",
maximum(marksinFDS)) print("Lowest Score in Class
: ", minimum(marksinFDS)) a = input("Do you want
to continue (yes/no) :")
if a == "yes":
flag = 1
else:
flag = 0
print("Thanks for using this program!")
elif ch==3:
print("Number of Students absent in the test : ",
absentcount(marksinFDS)) a = input("Do you want to continue
(yes/no) :")
if a == "yes":
flag = 1
else:
flag = 0
print("Thanks for using this program!")
elif ch==4:
mark,fr = maxFrequency(marksinFDS)
print("Highest frequency is of marks {0} that is {1}
".format(mark,fr)) a = input("Do you want to continue
(yes/no) :")
if a == "yes":
flag = 1
else:
flag = 0
print("Thanks for using this program!")
elif ch==5:
flag=0
print("Thanks for using this program!")
else:
print("!!Wrong Choice!! ")
a=input("Do you want to continue (yes/no)
:") if a=="yes":
flag=1
else:
flag=0
print("Thanks for using this program!")
INPUT=
OUTPUT=
MENU
MENU
MENU
MENU
CODE=
def get_student_details():
studentlist=[]
cric = []
badm =
[] foot
= []
n = int(input("Total Number of
students: ")) for i in range(n):
name = input("Enter Name of student: ")
studentlist.append(name)
c = input("Input y if you play cricket: ")
b = input("Input y if you play
badminton: ") f = input("Input y if you
play football: ") if c == 'y':
cric.append(name
) if b == 'y':
badm.append(name
) if f == 'y':
foot.append(name)
return studentlist, cric, badm, foot
INPUT=
OUTPUT=
CODE=
def delete(a):
ans = []
for i in
a:
if i not in
ans:
ans.append(i
)
return ans
def count(a):
flag = 0
less = []
for i in
a:
if int(i[1]) > 500:
flag += 1
else:
less.append(i)
return flag, less
def sort(a):
ans = a.copy()
for i in range(0, len(a)):
for j in range(0, len(a) - i - 1):
if ans[j][1] > ans[j + 1]
[1]: temp = ans[j]
ans[j] = ans[j +
1] ans[j + 1] =
temp
return ans
OUTPUT=
Original List : [['DSA', 550], ['OS', 400], ['CG', 600], ['DSA', 550],
['DM',
300], ['OS', 400], ['DSA', 550]]
Delete The Duplicate Entries : [['DSA', 550], ['OS', 400], ['CG', 600],
['DM', 300]]
Display Books In Ascending Order Based On Cost Of Books : [['DM', 300],
['OS', 400], ['DSA', 550], ['CG', 600]]
Count Number Of Books With Cost More Than 500 : 2
Copy Books In New List Which Has Cost Less Than 500 : [['OS', 400], ['DM',
300]]