0% found this document useful (0 votes)
19 views5 pages

Assignment 2

The document outlines several algorithmic problems including activity selection, train scheduling, job scheduling for maximum profit, fractional knapsack, and Huffman coding. It provides specific inputs and expected outputs for each problem, demonstrating the application of various algorithms. The problems focus on optimizing resource allocation and data compression techniques.

Uploaded by

amishra60be23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Assignment 2

The document outlines several algorithmic problems including activity selection, train scheduling, job scheduling for maximum profit, fractional knapsack, and Huffman coding. It provides specific inputs and expected outputs for each problem, demonstrating the application of various algorithms. The problems focus on optimizing resource allocation and data compression techniques.

Uploaded by

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

Name:Aadar Mishra

Roll No: 102367002


Sub-group:2Q21

Given the Input: start[] = {1, 3, 0, 5, 8, 5}, finish[] = {2, 4, 6, 7, 9, 9}; using Activity
selection. 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.
2. We are given two arrays that represent the arrival and departure times of trains, the
task is to find the minimum number of platforms required so that no train waits.
Input: arr[] = {9:00, 9:40, 9:50, 11:00, 15:00, 18:00}, dep[] = {9:10, 12:00, 11:20,
11:30, 19:00, 20:00}
Output: 3
Given an array of jobs where every job has a deadline and associated profit if the job
is finished before the deadline.
JobID Deadline Profit
a 4 20
b 1 10
c 1 40
d 1 30 Maximize the total profit if only one job can be scheduled at a time.
4. Given the weights and profits of N items, in the form of {profit, weight},
Input: arr[] = {{60, 10}, {100, 20}, {120, 30}}, put these items in a knapsack of
capacity W= 50 to get the maximum total profit in the knapsack. Use Fractional
Knapsack, and break items for maximizing the total value of the knapsack.
Huffman Coding is a lossless data compression algorithm. The algorithm assigns variable-length codes to input
characters, with shorter codes assigned to more frequent characters. Write a program to implement Huffman
Coding. Given a string as input, your task is to: 1. Build a Huffman Tree for the characters in the string. 2. Generate
the corresponding Huffman Codes for each character. 3. Encode the string using the generated Huffman Codes. 4.
Decode the encoded string back to its original form.

You might also like