You are on page 1of 2

PROGRAMS OUTPUT

Submitted by: Nidhi Shanbhag


211105036
Batch B

WEEK 11:

1. 0/1 Knapsack using Backtracking

OUTPUT

PS D:\SE SEM IV\MADF LAB> gcc knapsackb.c


PS D:\SE SEM IV\MADF LAB> ./a.exe
Enter the number of elements: 4
Enter the capacity of the knapsack: 8
Enter the weights of the elements: 2
3
4
5
Enter the profits of the elements: 3
5
6
10

The optimal solution is: 0 1 0 1

The optimal profit is: 15

The optimal weight is: 8


PS D:\SE SEM IV\MADF LAB>

Week 12:

1. 0/1 Knapsack using branch and bound

Output:

PS D:\SE SEM IV\MADF LAB> gcc knapsackbnb.c


PS D:\SE SEM IV\MADF LAB> ./a.exe
Enter knapsack cap: 12
Enter the number of items: 4
Enter the profit and weight for each item:
24 2
30 5
20 4
28 7
Knapsack Solution
Max Profit = 74
Items Included: 1 1 1 0
PS D:\SE SEM IV\MADF LAB>
Week 13:

1.KMP Pattern Matching Algorithm

Output:

PS D:\SE SEM IV\MADF LAB> gcc kmp.c


PS D:\SE SEM IV\MADF LAB> ./a.exe
Text is: aabbbaababbbabab
Pattern is: bbaba
Pattern bbaba found at index 10 in aabbbaababbbabab
PS D:\SE SEM IV\MADF LAB>

2. Boyer Moore Pattern Matching Algorithm

Output:

PS D:\SE SEM IV\MADF LAB> gcc bmp.c


PS D:\SE SEM IV\MADF LAB> ./a.exe
String 1 is: 1123114234112113
String 2 is: 4112113
Pattern 4112113 found at index 9 in 1123114234112113
PS D:\SE SEM IV\MADF LAB>

Week 14:

1.Huffman Encoding (Text Compression)

Output:

PS D:\SE SEM IV\MADF LAB> gcc huffman.c


PS D:\SE SEM IV\MADF LAB> ./a.exe
Huffman Codes
n 000
s 0010
p 0011
f 01000
a 01001
m 01010
r 010110
g 010111
e 011
i 100
t 101
110
o 1110
j 111100
l 111101
h 11111
PS D:\SE SEM IV\MADF LAB>

2. LCS (Text Similarity)

Output:

PS D:\SE SEM IV\MADF LAB> gcc lcs.c


PS D:\SE SEM IV\MADF LAB> ./a.exe
The string 1 is KLOKMKNKLOK
The string 2 is KLLKNKLLKNYY
Length of the longest common subsequence is: 7
The longest subsequence is: KLKNKLK
PS D:\SE SEM IV\MADF LAB>

You might also like