Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

Algorithm Questions

Uploaded by

alyackerman6
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)
5 views

Algorithm Questions

Uploaded by

alyackerman6
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/ 3

Merge Sort

1. Sort the following array using Merge Sort: Array = [38, 27, 43, 3, 9, 82, 10]. Perform the

step-by-step merge process and provide the sorted array.

2. Calculate the number of comparisons made by Merge Sort for the array of size 7: Array = [12, 11,

13, 5, 6, 7]

3. Divide the array using Merge Sort and show the intermediate results: Array = [2, 8, 1, 7, 6, 3, 5, 4]

4. Merge two sorted arrays using the merge step of Merge Sort: Array 1 = [3, 7, 12, 18], Array 2 = [4,

10, 15, 19]

5. How many sub-arrays will be created at the first division of the array: Array = [19, 22, 3, 14, 5, 6,

28, 8]

Quick Sort
1. Sort the following array using Quick Sort (first element as the pivot): Array = [10, 80, 30, 90, 40,

50, 70]. Perform step-by-step partitioning and sorting.

2. Using Quick Sort, show the partitioning for the array with the last element as pivot: Array = [15, 3,

12, 10, 25, 7, 20]

3. Choose the median element as pivot and sort the array using Quick Sort: Array = [45, 67, 23, 89,

34, 15, 10, 2]

4. Perform Quick Sort on this array and count the number of swaps: Array = [29, 10, 14, 37, 13]

5. Find the pivot for the partitioning in the Quick Sort process and show the resulting arrays: Array =

[3, 6, 8, 10, 1, 2, 4]

Binary Search
1. Perform Binary Search to find the position of the number 42 in the sorted array: Array = [4, 8, 15,

16, 23, 42, 50]

2. What are the steps taken by Binary Search to find the number 27 in the array: Array = [2, 5, 12,

17, 25, 27, 33, 39]

3. Apply Binary Search on a sorted array to find 56: Array = [10, 22, 35, 48, 56, 64, 79, 83]
4. How many comparisons are made in Binary Search to find 13 in this array: Array = [1, 3, 5, 9, 13,

18, 20, 25]

5. Find the mid-point during each step of Binary Search to locate 89: Array = [12, 24, 37, 45, 58, 65,

72, 89]

Greedy Method
1. Apply a greedy algorithm to maximize profit for the following set of jobs: Jobs: [{Job 1: Profit =

100, Deadline = 2}, {Job 2: Profit = 19, Deadline = 1}, {Job 3: Profit = 27, Deadline = 2}, {Job 4:

Profit = 25, Deadline = 1}, {Job 5: Profit = 15, Deadline = 3}]

2. Select activities that maximize the number of non-overlapping intervals (Activity Selection

Problem): Activities: {(1, 3), (2, 5), (4, 6), (5, 8), (7, 9)}

3. Use a greedy approach to find the minimum number of coins required to make change for 87

units. Available denominations: 1, 5, 10, 25, 50

4. Given a set of items with weights and values, find the maximum value that can fit into a knapsack

of capacity 10: Items = [{Weight = 2, Value = 20}, {Weight = 3, Value = 30}, {Weight = 4, Value =

40}, {Weight = 5, Value = 50}]

5. Apply the greedy algorithm to solve the fractional knapsack problem: Items = [{Weight = 2, Value

= 40}, {Weight = 3, Value = 50}, {Weight = 5, Value = 100}], Capacity = 6

Job Sequencing
1. Schedule the jobs to maximize profit based on their deadlines and profits: Jobs = [{Profit = 100,

Deadline = 2}, {Profit = 50, Deadline = 1}, {Profit = 200, Deadline = 2}, {Profit = 150, Deadline = 1}]

2. Arrange the following jobs and assign slots to maximize profit: Jobs = [{J1: Profit = 20, Deadline =

1}, {J2: Profit = 15, Deadline = 3}, {J3: Profit = 10, Deadline = 2}, {J4: Profit = 5, Deadline = 3}]

3. For the job list below, find the optimal job sequence to maximize profit: Jobs = [{J1: Profit = 35,

Deadline = 2}, {J2: Profit = 30, Deadline = 1}, {J3: Profit = 25, Deadline = 2}, {J4: Profit = 50,

Deadline = 1}]

4. Schedule jobs for maximum profit and show the steps: Jobs = [{Profit = 60, Deadline = 3}, {Profit
= 20, Deadline = 1}, {Profit = 40, Deadline = 2}, {Profit = 30, Deadline = 1}]

5. Perform job sequencing on this set of jobs and calculate total profit: Jobs = [{Profit = 120,

Deadline = 2}, {Profit = 90, Deadline = 3}, {Profit = 80, Deadline = 1}, {Profit = 70, Deadline = 2}]

Knapsack
1. Find the maximum profit that can be obtained for a knapsack with capacity 15 using the 0/1

knapsack problem: Items = [{Weight = 3, Value = 40}, {Weight = 5, Value = 70}, {Weight = 8, Value

= 100}]

2. Apply the fractional knapsack method to maximize profit with a capacity of 7: Items = [{Weight =

2, Value = 30}, {Weight = 4, Value = 50}, {Weight = 5, Value = 60}]

3. Solve the knapsack problem using dynamic programming for a knapsack capacity of 8: Items =

[{Weight = 2, Value = 20}, {Weight = 4, Value = 40}, {Weight = 6, Value = 60}]

4. Given a knapsack capacity of 50, find the items to include to maximize the value: Items = [{Weight

= 10, Value = 60}, {Weight = 20, Value = 100}, {Weight = 30, Value = 120}]

5. Use the knapsack algorithm to solve for maximum value with capacity 10: Items = [{Weight = 1,

Value = 10}, {Weight = 3, Value = 40}, {Weight = 4, Value = 50}, {Weight = 6, Value = 70}]

You might also like