0% found this document useful (0 votes)
5 views6 pages

(CSE 246) Lab - Covered Topics

The document is a lab manual for the CSE246 Algorithms course at East West University, detailing various algorithm topics and corresponding lab exercises. It covers binary search, quick sort, greedy algorithms, number theory, string and pattern matching, and dynamic programming, providing sample inputs and expected outputs for each task. The manual serves as a guide for students to implement and understand key algorithms in computer science.

Uploaded by

2023-2-60-179
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

(CSE 246) Lab - Covered Topics

The document is a lab manual for the CSE246 Algorithms course at East West University, detailing various algorithm topics and corresponding lab exercises. It covers binary search, quick sort, greedy algorithms, number theory, string and pattern matching, and dynamic programming, providing sample inputs and expected outputs for each task. The manual serves as a guide for students to implement and understand key algorithms in computer science.

Uploaded by

2023-2-60-179
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Department of Computer Science and Engineering

Lab Manual: CSE245/246 Algorithms (Section: All)


East West University
Department of Computer Science and Engineering
Course: CSE246 Algorithm Topic: Divide and Conquer Lab: 01

1. Binary search: Given a sorted array of n integers and a target value, determine if the
target exists in the array in logarithmic time using the binary search algorithm. If target
exists in the array, print the index of it.
Sample input Sample output

Data: 2, 3, 5, 7, 9 Found at index: 3


Target: 7
Data: 6, 7, 12 Not found
Target: 15

2. Reverse Binary search: Given a reverse sorted array of n integers and a target value,
determine if the target exists in the array in logarithmic time using the binary search
algorithm. If the target exists in the array, print the index of it.

3. Quick Sort: Given an integer array, sort it using the merge sort algorithm.
Sample input Sample output

Data: 2, 3, 7,5 2357

Data: 12, 6, 7 6 7 12

4. Use Binary Search to find the square root of a number


East West University
Department of Computer Science and Engineering
Course: CSE246 Algorithm Topic: Greedy approach Lab: 02

1. Fractional knapsack: Given the weights and profits of N items, in the form of {profit,
weight} put these items in a knapsack of capacity W to get the maximum total profit in
the knapsack. In Fractional Knapsack, we can break items for maximizing the total value
of the knapsack.

Sample input Sample output

{60, 10} 240


{100, 20}
{120, 30}
W = 50

2. Activity selection problem: You are given n activities with their start and finish times.
Select the maximum number of activities that can be performed by a single person,
assuming that a person can only work on a single activity at a time.
Sample input Sample output

start = {10, 12, 20} 2


finish = {20, 25, 30}
East West University
Department of Computer Science and Engineering
Course: CSE246 Algorithm Topic: Number theory Lab: 03

1. GCD: Given two numbers a and b, the task is to find the GCD of the two numbers using
Euclid’s algorithm.
Sample input Sample output

a = 20 4
b = 28

2. Sieve method: Given a number n, print all primes smaller than or equal to n using sieve
method. It is also given that n is a small number.
Sample input Sample output

10 2357

3. LCM: Given two numbers a and b, the task is to find the LCMof the two numbers.
Sample input Sample output

a=4 12
b=6
East West University
Department of Computer Science and Engineering
Course: CSE246 Algorithm Topic: String and Pattern matching Lab: 04

1. Rabin-Karp: Implement a program to search for a pattern in a text using the Rabin-Karp
algorithm.

Sample input Sample output

Text: "The quick brown fox Pattern found at index 16.


jumps over the lazy dog."
Pattern: "fox"

2. Naive Matching: Implement a program to search for a pattern in a text by just naively
checking.

Sample input Sample output

Text: "The quick brown fox Pattern found at index 16.


jumps over the lazy dog."
Pattern: "fox"
East West University
Department of Computer Science and Engineering
Course: CSE246 Algorithm Topic: Dynamic Programming (Part-01) Lab: 05

1. 0-1 Knapsack: You are given a set of items, each with a weight and a value, and a
knapsack with a maximum weight capacity. Your task is to determine the maximum
value that can be obtained by selecting a subset of the items to fit into the knapsack
without exceeding its weight capacity.
Sample input Sample output

4 9
23
34
45
56
8

2. Coin change: You are given n types of coins and another number K. Your task is to
determine whether it is possible to generate K using those coins if
i. The number of each coin is infinite.
ii. The number of each coin is finite.

3. Coin change: You are given n types of coins and another number K. Your task is to find
the minimum number of coins required to make K if.
i. The number of each coin is infinite.
ii. The number of each coin is finite.

You might also like