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

Revised - APSyllabus

The document outlines the course structure for 'Advance Programming Lab – II', detailing its objectives, outcomes, and syllabus. Students will learn to apply algorithms to solve complex problems and improve their coding skills through various programming tasks. The course covers topics such as data structures, linked lists, and divide-and-conquer algorithms, with specific problem statements linked to practical coding exercises.

Uploaded by

Aashutosh Rao
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 views20 pages

Revised - APSyllabus

The document outlines the course structure for 'Advance Programming Lab – II', detailing its objectives, outcomes, and syllabus. Students will learn to apply algorithms to solve complex problems and improve their coding skills through various programming tasks. The course covers topics such as data structures, linked lists, and divide-and-conquer algorithms, with specific problem statements linked to practical coding exercises.

Uploaded by

Aashutosh Rao
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/ 20

Course Code TITLE OF THE COURSE L T P S C CH Course

Type*
Advance Programming Lab – II 0 0 4 0 2 2 EE

22CSP- Course Code(s)


351/22ITP- 22CSP-351/22IT
351 P-
351
PRE- C++, JAVA, Data Structure
REQUISITE
CO- Data Structure
REQUISITE

ANTI- -
REQUISITE

a. Course Description
Advance programming is the course in which students will learn how to apply algorithms in
order to solve complex problems. The goal of this course is to teach students how to apply
familiar algorithms to non-intuitive problems.

b. Course Objectives
● To give students the ability to write reliable codes.
● To provide skills to the students to write compact and efficient code in a quick manner
● To provide logic building capability to the student.
● To improve the logic building of students to tackle the complex problems.
● To implement the different approaches to get appropriate solutions.
c. Course Outcomes
CO1 Understand the problem statement and what makes for a correct solution to the
problem statement.
CO2 Apply foundational knowledge to implement algorithms for common problem patterns.

CO3 Analyze the algorithms based on their efficiency, correctness, and resource utilization.
CO4 Evaluate various problem patterns, compare different solutions and contrast their
resource trade-offs.
CO5 Formulate correct and efficient algorithms for novel problem statements.

Unit-1 Data Structures Contact Hours:15 CO

Full Stack 1. Problem Statement. Give understanding of Mongodb, CO1,


Development Nodejs, React, Express. CO2,
(MERN) 2. Problem Statement: Create a Frontend design of Login/ CO5
Signup pages and create a backend of it.
3. Problem Statement: Test the Backend API via POSTMAN
and integrate it with React Frontend.

d. Syllabus
Arrays, 1. Problem statement - Given an array of integers nums and an CO2,
Stacks, integer target, return indices of the two numbers such that they CO3
Queues add up to target.
You may assume that each input would have exactly one solution,
and you may not use the same element twice.
You can return the answer in any order.
Problem link- https://leetcode.com/problems/two-sum/

2. Problem statement - You are given a 0-indexed array of


integers nums of length n. You are initially positioned at
nums[0].
Each element nums[i] represents the maximum length of a
forward jump from index i. In other words, if you are at
nums[i], you can jump to any nums[i + j] where:
0 <= j <=
nums[i]
and i + j <
n
Return the minimum number of jumps to reach nums[n - 1]. The
test cases are generated such that you can reach nums[n - 1].
Problem link- https://leetcode.com/problems/jump-game-ii/

3.Problem statement - Given a string path, which is an


absolute path (starting with a slash '/') to a file or directory in a
Unix-style file system, convert it to the simplified canonical
path.
In a Unix-style file system, a period '.' refers to the current
directory, a double period '..' refers to the directory up a level,
and any multiple consecutive slashes (i.e. '//') are treated as a
single slash '/'. For this problem, any other format of periods
such as '...' are treated as file/directory names.
The canonical path should have the following format:
The path starts with a single slash '/'.
Any two directories are separated by a
single slash '/'. The path does not end
with a trailing '/'.
The path only contains the directories on the path from the root
directory to the target file or directory (i.e., no period '.' or double
period '..')
Return the simplified canonical path.
Problem link- https://leetcode.com/problems/simplify-path/

4. Problem statement - Implement a first in first out (FIFO)


queue using only two stacks. The implemented queue should
support all the functions of a normal queue (push, peek, pop,
and empty).
Implement the MyQueue class:
void push(int x) Pushes element x to the back of the queue.
int pop() Removes the element from the front of the queue
and returns it. int peek() Returns the element at the front of
the queue.
boolean empty() Returns true if the queue is empty, false
Linked 1. Problem statement - Print linked list CO1,
List Given a singly linked list, traverse and print each element in CO3,
order. A linked list consists of nodes, each containing a value and CO2
a pointer to the next node. Start from the head and iterate until
reaching NULL, printing each node’s value. Alternatively,
recursion can be used. Handle edge cases like an empty list or a
single-node list. This problem reinforces basic linked list
traversal and pointer manipulation. The time complexity is O(n),
where n is the number of nodes, and space complexity is O(1) for
iteration or O(n) for recursion.
Problem link- https://www.geeksforgeeks.org/problems/print-
linked-list-elements/0

2. Problem statement - Remove duplicates from a sorted list.


Given a sorted singly linked list, remove duplicate values so each
element appears only once. Traverse the list, comparing each
node’s value with the next. If they match, update the next pointer
to skip the duplicate. This in-place modification ensures an O(n)
time complexity and O(1) space complexity. Edge cases include
an empty list, a single-node list, or all elements being identical.
This problem helps in understanding linked list traversal and
pointer updates while maintaining the order of elements.
Problem link- https://leetcode.com/problems/remove-
duplicates-from-sorted-list

3. Problem Statement: Reverse a linked list


Given a singly linked list, reverse it so that the last node becomes
the head. This can be done iteratively using three pointers (prev,
current, and next) or recursively by reversing the rest of the list
and adjusting pointers. The iterative approach runs in O(n) time
and uses O(1) space, while recursion takes O(n) space. Edge
cases include an empty list, a single-node list, or already reversed
lists. This problem strengthens understanding of pointer
manipulation and iterative vs. recursive approaches.
Problem Link - https://leetcode.com/problems/reverse-linked-
list/

4. Problem Statement: Delete middle node of a list


Given a singly linked list, delete its middle node. The middle is
defined as floor(n/2), where n is the length of the list. Use two
pointers: one moves twice as fast as the other. When the fast
pointer reaches the end, the slow pointer is at the middle. Modify
the next pointer to remove the middle node. The time complexity
is O(n), and space complexity is O(1). Edge cases include lists
with one or two nodes. This problem tests linked list traversal and
deletion techniques.
Problem link - https://leetcode.com/problems/delete-the-middle-
node-of-a-linked-list
Linked 5. Problem Statement: Merge two sorted linked lists CO1,
List Given two sorted singly linked lists, merge them into a single CO3,
sorted list. Use iteration or recursion to compare the node values CO2
and link them accordingly. The iterative approach maintains a
dummy head and builds the result list in O(n + m)time, where n
and m are the lengths of the lists. Space complexity is O(1) for
iteration and O(n + m) for recursion. Edge cases include one or
both empty lists and already merged lists. This problem reinforces
merging techniques and pointer manipulation in linked lists.
Problem link - https://leetcode.com/problems/merge-two-
sorted-lists

6. Problem Statement: Remove duplicates from sorted lists


2
Given a sorted linked list, remove all elements that appear more
than once, leaving only distinct values. Use a dummy head and
two-pointer traversal. If consecutive nodes have the same value,
skip them. This runs in O(n) time and O(1)space. Edge cases
include an empty list, all duplicates (resulting in an empty list), or
no duplicates. This problem strengthens linked list traversal and
deletion techniques.
Problem Link - https://leetcode.com/problems/remove-
duplicates-from-sorted-list-ii

7. Problem Statement: Detect a cycle in a linked list


Detect whether a given singly linked list contains a cycle. Use
Floyd’s Cycle Detection Algorithm (fast and slow pointers). If the
fast pointer catches up to the slow pointer, a cycle exists. This runs
in O(n) time and O(1) space. Edge cases include an empty list, a
single-node cycle, or no cycle. This problem tests ef cient cycle
detection in linked lists.
Problem Link - https://leetcode.com/problems/linked-list-cycle

8. Problem Statement:Reverse linked list 2


Reverse a portion of a singly linked list from position left to
right. Locate the left position, reverse nodes in the range,
and reconnect the segments. The approach runs in O(n) time and
O(1) space. Edge cases include reversing the entire list or only one
node. This problem helps in understanding selective reversal in
linked lists.
Problem Link - https://leetcode.com/problems/reverse-linked-
list-ii

9. Problem Statement: rotate a list


Given a singly linked list, rotate it right by k places. Convert k into
an effective shift using k % length, nd the new head, and
adjust pointers. This approach runs in O(n) time and O(1) space.
Edge cases include k = 0, k equal to the list’s length, and an
empty list. This problem tests linked list traversal and pointer
adjustments.
Problem Link - https://leetcode.com/problems/rotate-list
fi
fi
Linked 10. Problem Statement: Merge k sorted lists CO1,
List Merge k sorted linked lists into one sorted list. Use a min-heap CO3,
(priority queue) or divide-and-conquer. The heap-based approach CO2
runs in O(n log k) time, while divide-and-conquer has O(n log k)
complexity. Edge cases include k = 1, all empty lists, or already
merged lists. This problem helps in mastering merging techniques
and ef cient sorting strategies.
Problem Link - https://leetcode.com/problems/merge-k-sorted-
lists/

11. Problem Statement: Sort List


Sort a singly linked list in O(n log n) time using merge sort. The
list is divided into halves, sorted, and merged. This approach is
ef cient since merge sort works well with linked lists. The space
complexity is O(log n) for recursion. Edge cases include an empty
list, a single-node list, or an already sorted list. This problem
reinforces sorting algorithms and linked list manipulation.
Problem Link - https://leetcode.com/problems/sort-list/
description/
fi
fi
Divide and 1. Problem statement - Longest Nice Substring CO2,
Conquer A substring is "nice" if for every character, both its uppercase and CO3,
lowercase forms exist in the substring. Given a string, nd the CO5
longest nice substring. Use a divide-and-conquer approach by
identifying characters that break the "nice" condition and splitting
the string at those points. This results in O(n²) time complexity in
the worst case. Edge cases include strings with all unique
characters or all letters in both cases.
Problem link- https://leetcode.com/problems/longest-nice-
substring/description
2. Problem statement - Reverse Bits
Given a 32-bit unsigned integer, reverse its bits and return the new
number. Process each bit using bitwise operations: shift and OR to
construct the reversed number. The solution runs in O(1) time since
a xed 32-bit number is processed. Edge cases include 0, 1, and
numbers with only leading or trailing 1s. This problem strengthens
understanding of bit manipulation techniques.
Problem link- https://leetcode.com/problems/reverse-bits/
3. Problem statement - Number of 1 bits
Given a 32-bit unsigned integer, count the number of 1 bits in its
binary representation. Use bitwise AND (n & (n - 1)) to
clear the least signi cant 1 bit iteratively, running in O(k) time,
where k is the number of 1s. Alternatively, iterate through all 32
bits. Edge cases include 0 (output 0) and 2^31 (output 1). This
problem builds bitwise manipulation skills.
Problem link- https://leetcode.com/problems/number-of-1-bits/
4. Problem statement - Max Subarray
Find the contiguous subarray with the largest sum. Use Kadane’s
Algorithm: maintain a running sum and reset if it becomes
negative. This runs in O(n) time and O(1) space. Edge cases
include all negative numbers (take the largest) and an array of size
one. This problem reinforces dynamic programming concepts.
Problem link- https://leetcode.com/problems/maximum-subarray/
5. Problem statement - Search 2d matrix
Given a m x n matrix where rows and columns are sorted,
determine if a target exists. Treat the matrix as a 1D sorted array
and apply binary search in O(log(mn)) time. Edge cases include an
empty matrix and the target at the start or end. This problem builds
ef cient searching techniques in sorted structures.
Problem link- https://leetcode.com/problems/search-a-2d-matrix/
6. Problem statement - Super Pow
Compute (a^b) % 1337, where b is a large number. Use
modular exponentiation and divide-and-conquer to break b into
smaller exponents. This approach runs in O(log b) time. Edge
cases include a = 1, b = 0, and a being a multiple of 1337.
This problem strengthens modular arithmetic and power
computation concepts.
Problem link- https://leetcode.com/problems/super-pow/
description/
fi
fi
fi
fi
Divide and 7. Problem statement - Beautiful Array CO2,
Conquer Construct an array where no triplet satis es A[k] * 2 = CO3,
A[i] + A[j]. Use divide-and-conquer to build an array CO5
recursively. The approach runs in O(n log n) time. Edge cases
include n = 1 (output [1]) and n = 2 (output [1,2]). This
problem focuses on mathematical pattern formation and recursion.
Problem link- https://leetcode.com/problems/beautiful-array/
description/?envType=problem-list-v2&envId=divide-and-
conquer
8. Problem statement - The Skyline Problem
Given buildings in a city, determine the skyline by identifying key
points. Use a divide-and-conquer or heap-based approach to
process building start and end points ef ciently. The best approach
runs in O(n log n) time. Edge cases include overlapping buildings
and single-building cases. This problem enhances understanding of
computational geometry and sorting techniques.
Problem link- https://leetcode.com/problems/the-skyline-
problem/description/?envType=problem-list-v2&envId=divide-
and-conquer
9. Problem statement - Reverse Pairs
Count the number of reverse pairs (i, j) where i < j and
nums[i] > 2 * nums[j]. Use merge sort to ef ciently
count such pairs, running in O(n log n) time. Edge cases include
all increasing elements (zero pairs) and all decreasing elements
(maximum pairs). This problem strengthens understanding of
modi ed merge sort and inversion counting.
Problem link- https://leetcode.com/problems/reverse-pairs/
description/?envType=problem-list-v2&envId=divide-and-
conquer
10. Problem statement - Longest increasing subsequence 2
Find the longest increasing subsequence within a given range of
allowed jumps. Use segment trees or dynamic programming to
ef ciently update and query subsequence lengths. The optimal
approach runs in O(n log n) time. Edge cases include all elements
being the same and a fully sorted input. This problem tests ef cient
range-based sequence optimization techniques.
Problem link- https://leetcode.com/problems/longest-
increasing-subsequence-ii/description/?envType=problem-list-
v2&envId=divide-and-conquer
fi
fi
fi
fi
fi
fi
Unit-2 Advance Data Structures Contact Hours:15 CO

Sorting and 1. Problem statement- Merge Sorted Array CO2,


Searching Given two sorted arrays nums1 and nums2, merge nums2 into CO3,
nums1 in sorted order. Use a two-pointer approach from the back to CO4,
avoid extra space. Iterate from the largest elements, placing them in CO5
the correct position. This approach runs in O(m + n) time and O(1)
space. Edge cases include an empty nums2 or nums1 having extra
zeroes at the end.
Problem link- https://leetcode.com/problems/merge-sorted-
array/

2. Problem statement- First Bad Version


Find the rst bad version in a sequence of versions using an API
isBadVersion(version). Apply binary search to ef ciently
locate the rst bad version in O(log n) time. Edge cases include all
versions being good or the rst version being bad. This problem
reinforces binary search concepts.
Problem link- https://leetcode.com/problems/first-bad-version/

3. Problem statement- Sort Colors


Sort an array containing only 0s, 1s, and 2s (Dutch National Flag
Problem). Use a three-pointer approach to partition elements in O(n)
time and O(1) space. Edge cases include already sorted arrays and
arrays containing only one type of element.
Problem link- https://leetcode.com/problems/sort-colors/

4. Problem statement- Top K frequent elements


Find the k most frequent elements in an array. Use a hash map to
count frequencies, then use a min-heap or bucket sort to extract the
top k elements. The heap approach runs in O(n log k) time. Edge
cases include k = 1 or all elements being unique.
Problem link- https://leetcode.com/problems/top-k-frequent-
elements/

5. Problem statement- Kth Largest element in an array


Find the kth largest element in an array using a min-heap or
Quickselect. The heap approach runs in O(n log k) time, while
Quickselect runs in O(n) on average. Edge cases include k = 1
(max element) and k = n (min element).
Problem link- https://leetcode.com/problems/kth-largest-
element-in-an-array/

6. Problem statement- Find Peak Element


Find an index where nums[i] > nums[i-1] and nums[i]
> nums[i+1]. Use binary search to nd a peak in O(log n)time.
Edge cases include a single-element array and peaks at the
boundaries.
Problem link- https://leetcode.com/problems/find-peak-
element/
fi
fi
fi
fi
fi
Sorting and 7. Problem statement- Search For a range CO2,
Searching Find the rst and last occurrence of a target in a sorted array. Use CO3,
binary search twice to locate both positions in O(log n)time. Edge
CO4,
cases include a target not in the array or all elements being the same.
Problem link- https://leetcode.com/problems/search-for-a- CO5
range/
8. Problem statement- Merge Intervals
Given overlapping intervals, merge them into non-overlapping ones.
Sort intervals by start time, then iterate and merge overlapping
intervals in O(n log n) time. Edge cases include no overlapping
intervals and all intervals merging into one.
Problem link- https://leetcode.com/problems/merge-intervals/

9. Problem statement- Search in Rotated Sorted Array


Find a target in a sorted but rotated array using binary search. Identify
the sorted half and decide the search direction. The approach runs in
O(log n) time. Edge cases include rotation at 0 or n-1 and target at
pivot points.
Problem link- https://leetcode.com/problems/search-in-
rotated-sorted-array/

10. Problem statement- Search a 2D Matrix II


Find a target in a m x n matrix where rows and columns are sorted.
Start searching from the top-right or bottom-left corner, adjusting
position based on the target. This runs in O(m + n) time. Edge cases
include an empty matrix and the smallest/largest target values.
Problem link- https://leetcode.com/problems/search-a-2d-
matrix-ii/

11. Problem statement- Wiggle Sort 2


Rearrange an array so that nums[0] < nums[1] >
nums[2] < nums[3].... Use the median and three-way
partitioning for an O(n) solution. Edge cases include already wiggle-
sorted arrays and duplicate values.
Problem link- https://leetcode.com/problems/wiggle-sort-2/

12. Problem statement- Kth smallest element in a sorted matrix


Find the kth smallest element in a row- and column-sorted matrix.
Use a min-heap (O(k log n)) or binary search on values (O(n log
max-min)). Edge cases include k = 1 (smallest element) and k =
n^2 (largest element).
Problem link- https://leetcode.com/problems/kth-smallest-
element-in-a-sorted-matrix/

13. Problem statement- Median of Two Sorted Arrays


Find the median of two sorted arrays in O(log(min(m, n))) time using
binary search. Adjust partitioning until the correct median position is
found. Edge cases include one empty array and arrays of different
lengths.
Problem link- https://leetcode.com/problems/median-of-two-
sorted-arrays/
fi
Trees 1. Problem statement- Maximum Depth of Binary Tree CO2,
Find the maximum depth of a binary tree, de ned as the longest root- CO3,
to-leaf path. Use a recursive depth- rst search (DFS) or iterative
CO4
breadth- rst search (BFS). The DFS approach runs in O(n) time and
O(h) space, where h is the tree height. Edge cases include an empty
tree (depth 0) and a skewed tree (depth n).
Problem link- https://leetcode.com/problems/maximum-depth-
of-binary-tree/

2. Problem statement- Validate Binary Search Tree


Check if a binary tree follows the BST property: left subtree < root <
right subtree. Use DFS with a range (min, max) to validate
nodes recursively in O(n) time. Alternatively, an in-order traversal
should produce a strictly increasing sequence. Edge cases include a
single-node tree and duplicate values.
Problem link- https://leetcode.com/problems/validate-binary-
search-tree/

3. Problem statement- Symmetric Tree


Check if a binary tree is a mirror of itself. Use recursive DFS or
iterative BFS (queue) to compare corresponding nodes. The solution
runs in O(n) time and O(h) space. Edge cases include an empty tree
(symmetric) and a single-node tree.
Problem link- https://leetcode.com/problems/symmetric-tree/

4. Problem statement- Binary Tree Level Order Traversal


Return nodes level by level from a binary tree using BFS (queue).
This runs in O(n) time and O(n) space. Edge cases include an empty
tree (return []) and a single-node tree.
Problem link- https://leetcode.com/problems/binary-tree-level-
order-traversal/

5. Problem statement- Convert Sorted Array to Binary Search


Tree
Convert a sorted array into a height-balanced BST using a divide-and-
conquer approach. Recursively select the middle element as the root
and build left and right subtrees. This runs in O(n) time and O(log n)
space. Edge cases include arrays of length 1 and 2.
Problem link- https://leetcode.com/problems/convert-sorted-
array-to-binary-search-tree/

6. Problem statement- Binary Tree Inorder Traversal


Return the inorder (left-root-right) traversal of a binary tree using
recursion or an iterative stack-based approach. The solution runs in
O(n) time and O(h) space. Edge cases include an empty tree ([])
and a left-skewed or right-skewed tree.
Problem link- https://leetcode.com/problems/binary-tree-
inorder-traversal/
fi
fi
fi
Trees 7. Problem statement- Binary Zigzag Level Order Traversal CO2,
Perform a level order traversal but alternate directions at each level. CO3,
Use BFS with a deque or a ag to reverse levels. The approach runs
CO4
in O(n) time and O(n) space. Edge cases include a single-node tree
and a tree with all left or right children.
Problem link- https://leetcode.com/problems/binary-zigzag-
level-order-traversal/

8. Problem statement- Construct Binary Tree from Inorder and


Postorder Traversal
Reconstruct a binary tree from its inorder and postorder traversals.
Identify the root from postorder, nd it in inorder, and recursively
build left and right subtrees. This runs in O(n) time using a hashmap
to store inorder indices. Edge cases include a single-node tree and
completely unbalanced trees.
Problem link- https://leetcode.com/problems/construct-binary-
tree-from-inorder-and-postorder-traversal/

9. Problem statement- Kth Smallest element in a BST


Find the kth smallest element in a BST using an in-order traversal
(iterative or recursive). The approach runs in O(k) time and O(h)
space. Edge cases include k = 1 (smallest element) and k = n
(largest element).
Problem link- https://leetcode.com/problems/kth-smallest-
element-in-a-bst/

10. Problem statement- Populating Next Right Pointers in Each


Node
For a perfect binary tree, connect each node’s next pointer to its
right neighbor. Use BFS (queue) or a level-by-level pointer traversal
in O(n) time and O(1) space. Edge cases include a tree with only one
node.
Problem link- https://leetcode.com/problems/populating-next-
right-pointers-in-each-node/
fl
fi
Dynamic 1. Problem statement- Climbing Stairs CO2,
Programmin Find the number of ways to climb n stairs when you can take 1 or 2 CO3,
g steps at a time. This follows the Fibonacci sequence and can be CO4,
solved using dynamic programming (DP) in O(n) time and O(1)
CO5
space. Edge cases include n = 1 and n = 2.
Problem link- https://leetcode.com/problems/climbing-stairs/
2. Problem statement- Best Time to Buy and Sell a Stock
Find the maximum pro t from one stock transaction. Track the
minimum price while iterating through the prices. This runs in O(n)
time and O(1) space. Edge cases include decreasing prices (pro t =
0).
Problem link- https://leetcode.com/problems/best-time-to-buy-
and-sell-a-stock/
3. Problem statement- Maximum Subarray
Find the contiguous subarray with the maximum sum using Kadane’s
Algorithm. This runs in O(n) time and O(1) space. Edge cases
include an array of all negative numbers.
Problem link- https://leetcode.com/problems/maximum-
subarray/
4. Problem statement- House Robber
You are given an array representing the amount of money in each
house on a street. You cannot rob two adjacent houses. Determine the
maximum amount you can rob without alerting the police.
Problem link- https://leetcode.com/problems/house-robber/
description/
5. Problem statement- Jump Game
Given an array where each element represents the maximum jump
length from that position, determine if you can reach the last index
starting from the rst index.
Problem link- https://leetcode.com/problems/jump-game/
6. Problem statement- Unique Paths
You are given an m x n grid where a robot starts at the top-left and
can only move right or down. Determine the number of unique paths
the robot can take to reach the bottom-right corner.
Problem link- https://leetcode.com/problems/unique-paths/
7. Problem statement- Coin Change
Given an array of coin denominations and an amount, determine the
minimum number of coins needed to make up that amount. If it is
impossible, return -1.
Problem link- https://leetcode.com/problems/coin-change/
8. Problem statement- Longest Increasing Subsequence
Given an array of integers, nd the length of the longest subsequence
where the elements are strictly increasing.
Problem link- https://leetcode.com/problems/longest-
increasing-subsequence/
9. Problem statement- Maximum Product Subarray
Given an array of integers, nd the contiguous subarray (of at least
one element) that has the largest product and return its product.
Problem link- https://leetcode.com/problems/maximum-
product-subarray/
fi
fi
fi
fi
fi
Dynamic 10. Problem statement- Decode Ways CO2,
Programmin Given a string of digits representing encoded letters (1-26 → A-Z), CO3,
g determine the number of ways it can be decoded into valid letter CO4,
sequences.
CO5
Problem link- https://leetcode.com/problems/decode-ways/
11. Problem statement- Best time to buy and Sell a Stock with
Cooldown
Given an array where prices[i] represents the stock price on day
i, nd the maximum pro t if you can buy and sell multiple times but
must wait one day after selling before buying again.
Problem link- https://leetcode.com/problems/best-time-to-buy-
and-sell-a-stock-with-cooldown/
12. Problem statement- Perfect Squares
Given a positive integer n, determine the minimum number of perfect
square numbers whose sum equals n.
Problem link- https://leetcode.com/problems/perfect-squares/
13. Problem statement- Word Break
Given a string s and a dictionary of words, determine if s can be
segmented into one or more dictionary words.
Problem link- https://leetcode.com/problems/word-break/
14. Problem statement- Word Break 2
Given a string s and a dictionary of words, return all possible ways s
can be segmented into dictionary words.
Problem link- https://leetcode.com/problems/word-break-2/
fi
fi
Unit-3 Advance Data Structures Contact CO
Hours:15
Greedy 1. Problem statement- Max Units on a Truck CO3,
You are given an array where each element represents a type of box, CO4,
with a count and a number of units per box. A truck has a limited CO5
capacity. Determine the maximum total units that can be loaded onto
the truck.
Problem link- https://leetcode.com/problems/maximum-units-
o n - a - t r u c k / d e s c r i p t i o n / ? e n v Ty p e = p r o b l e m - l i s t -
v2&envId=greedy

2. Problem statement- Min Operations to make array incresing


Given an integer array, determine the minimum number of
operations needed to make it strictly increasing, where an operation
consists of incrementing an element by 1.
Problem link- https://leetcode.com/problems/minimum-
operations-to-make-the-array-increasing/description/?
envType=problem-list-v2&envId=greedy

3. Problem statement- Remove stones to Maximize total


Given a set of piles of stones, you can remove stones from any pile
in each operation. Determine the maximum total number of stones
left after performing a given number of operations.
Problem link- https://leetcode.com/problems/remove-stones-
t o - m i n i m i z e - t h e - t o t a l / ? e n v Ty p e = p r o b l e m - l i s t -
v2&envId=greedy

4. Problem statement- Max Score from removing substrings


Given a string and two types of substring pairs, remove these
substrings in any order to maximize the score. Each removal adds a
speci c score to the total. Determine the maximum possible score.
Problem link- https://leetcode.com/problems/maximum-
score-from-removing-substrings/?envType=problem-list-
v2&envId=greedy

5. Problem statement- Min operations to make a subsequence


Given two integer arrays, nd the minimum number of operations
needed to make the rst array a subsequence of the second by
deleting elements from the rst.
Problem link- https://leetcode.com/problems/minimum-
operations-to-make-a-subsequence/?envType=problem-list-
v2&envId=greedy

6. Problem statement- Max number of tasks you can assign


Given tasks with speci c dif culty levels and workers with assigned
skill levels, determine the maximum number of tasks that can be
assigned while following speci c conditions, such as task limits per
worker and additional training.
Problem link- https://leetcode.com/problems/maximum-
number-of-tasks-you-can-assign/?envType=problem-list-
v2&envId=greedy
fi
fi
fi
fi
fi
fi
fi
Graphs 1. Problem statement- Number of Islands CO3,
Given a 2D grid of '1's (land) and '0's (water), determine the CO4,
number of distinct islands. An island is formed by connecting CO5
adjacent land cells horizontally or vertically.
Problem link- https://leetcode.com/problems/number-of-
islands/
2. Problem statement- Word Ladder
Given a start word, an end word, and a word list, transform the start
word into the end word by changing one letter at a time. Each
intermediate word must exist in the given word list. Determine the
shortest transformation sequence length.
Problem link- https://leetcode.com/problems/word-ladder/
3. Problem statement- Surrounded Regions
Given a 2D grid of 'X's and 'O's, capture all 'O' regions that
are completely surrounded by 'X'. Any 'O' connected to the
border should not be captured.
Problem link- https://leetcode.com/problems/surrounded-
regions/
4. Problem statement- Binary Tree Maximum Path sum
Given a binary tree, nd the maximum path sum. A path can start
and end at any node, but it must move only downward through
parent-child connections.
Problem link- https://leetcode.com/problems/binary-tree-
maximum-path-sum/
5. Problem statement- Friend Circles
Given an adjacency matrix representing friendships among n
people, determine the number of distinct friend circles (groups of
directly or indirectly connected friends).
Problem link- https://leetcode.com/problems/friend-circles/
6. Problem statement- Lowest Common Ancestor of a Binary
Tree
Given a binary tree and two nodes, nd the lowest common ancestor,
which is the lowest node in the tree that has both given nodes as
descendants.
Problem link- https://leetcode.com/problems/lowest-common-
ancestor-of-a-binary-tree/
7. Problem statement- Course Schedule
Given numCourses and a list of prerequisite pairs, determine if it
is possible to nish all courses without violating prerequisites.
Problem link- https://leetcode.com/problems/course-schedule/
8. Problem statement- Longest Increasing Path in a Matrix
Given a 2D matrix of integers, nd the length of the longest
increasing path where each step moves in one of four directions (up,
down, left, right) and must be strictly increasing.
Problem link- https://leetcode.com/problems/longest-
increasing-path-in-a-matrix/
9. Problem statement- Course Schedule 2
Given numCourses and a list of prerequisite pairs, return a valid
order to complete all courses. If no valid order exists, return an
empty list.
Problem link- https://leetcode.com/problems/course-
schedule-2/
fi
fi
fi
fi
Important 1. Problem statement- Find Celebrity CO3,
Miscellane Given n people at a party, determine if there is a celebrity. A CO4,
ous celebrity is de ned as someone who is known by everyone but does CO5
not know anyone else. You can only use a given knows(a, b)
API to check if one person knows another.
Problem link- https://leetcode.com/problems/find-celebrity/

2. Problem statement- Pascal's Triangle


Generate the rst numRows of Pascal’s Triangle, where each row
contains values that are the sum of the two numbers directly above
it.
Problem link- https://leetcode.com/problems/pascals-triangle/

3. Problem statement- Hamming distance


Given two integers, nd the Hamming distance, which is the number
of positions at which their binary representations differ.
Problem link- https://leetcode.com/problems/hamming-
distance/description/

4. Problem statement- Task Scheduler


Given a list of tasks represented by letters and a cooldown interval
n, determine the minimum time required to complete all tasks while
following the cooldown constraints.
Problem link- https://leetcode.com/problems/task-scheduler/

5. Problem statement- Number of 1 bits


Given an unsigned integer, count the number of 1 bits in its binary
representation.
Problem link- https://leetcode.com/problems/number-of-1-
bits/

6. Problem statement- Valid Parenthesis


Given a string consisting of parentheses (()[]{}), determine if the
input string is valid. A string is valid if open brackets are closed in
the correct order and match their respective types.
Problem link- https://leetcode.com/problems/valid-
parenthesis/

7. Problem statement- Divide Two Integers


Given two integers, dividend and divisor, divide them
without using multiplication, division, or the modulus operator, and
return the quotient.
Problem link- https://leetcode.com/problems/divide-two-
integers/description/

8. Problem statement- Trapping Rain Water


Given an elevation map represented by an array, calculate the total
amount of rainwater that can be trapped between the bars after
raining.
Problem link- https://leetcode.com/problems/trapping-rain-
water/
fi
fi
fi
Important 9. Problem statement- Max number of tasks you can assign CO3,
Miscellane Given a list of task dif culties and a list of worker capabilities, CO4,
ous determine the maximum number of tasks that can be assigned while CO5
considering task limits per worker and potential training.
Problem link- https://leetcode.com/problems/maximum-
number-of-tasks-you-can-assign/?envType=problem-list-
v2&envId=greedy

10. Problem statement- Serialize and Deserialize Binary Tree


Design an algorithm to encode a binary tree into a string
(serialization) and then decode it back into the original tree structure
(deserialization).
Problem link- https://leetcode.com/problems/serialize-and-
deserialize-binary-tree/

11. Problem statement- LRU Cache


Design a data structure that implements a Least Recently Used
(LRU) cache with a given capacity, supporting get and put
operations ef ciently.
Problem link- https://leetcode.com/problems/lru-cache/

e. References
1. “Introduction to Algorithms” by Thomas H. Cormen,
Charles E. Leiserson,Ronald L.Rivest, and Clifford
Stein.
2. Algorithms Unlocked” by Thomas H. Cormen
3. “Data Structures and Algorithms Made Easy:
Data Structures and AlgorithmicPuzzles”by
Narasimha Karumanchi.
4. “Grokking Algorithms: An illustrated guide
for programmers and othercurious people”by
Aditya Bhargava
fi
fi
f. Assessment Pattern -Internal and External

The performance of students is evaluated as follows:

g. Internal Evaluation Component

Sr. Type of Weightage of Frequency Final Remarks


No. Assessme actual conduct of Task Weightage in
nt Internal
Assessment
1 Conduct 10 Marks 1 per 60 Marks per
per Practical practical course
2 Report 10 Marks 1 per
per Practical practical
3. Viva- Voce 20 Marks per 1 per Course
Course

h. Relationship between the Course Outcomes (COs) and Program Outcomes (POs)

SN Course Outcome (CO) Mapped Programme Outcome (PO)

1 CO1 PO1, PO2, PO3, PO4, PO5, PO9, PO10, PO12, PSO1

2 CO2 PO1, PO2, PO3, PO4, PO5,PO9, PSO1, PSO2

3 CO3 PO1, PO2, PO3, PO4, PO5,PO9,PSO1

4 CO4 PO2, PO4, PO5, PO10, PO11, PSO1

5 CO5 PO2,PO3, PO4, PO5, PO8, PO9, PO10, PO11, PO12, PSO2
i. CO-PO Mapping

Course PO1 PO1 PSO PSO


Outcome PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 0 PO11 2 1 2

CO1 3 3 3 3 3 - - - 2 1 - 2 2 -

CO2 3 3 2 2 3 - - - 2 - - - 2 3

CO3 3 3 1 3 2 - - - 2 - - - 2 -

CO4 - 3 - 2 3 - - - - 2 2 - 1 -

CO5 - 2 3 2 3 - - 2 3 3 2 1 - 2

Average 3 2.8 2.25 2.4 2.8 - - 2 2.25 2 2 1.5 1.75 2.5

Course Course Name PO PO PO PO PO5 PO PO PO PO PO1 PO11 PO1 PSO1 PSO2


Code 1 3 3 4 6 7 8 9 0 2

22CSP- Advance
351/22IT Programming
P- Lab – II
351 2.2
3 2.8 2.25 2.4 2.8 - - 2 5 2 2 1.5 1.75 2.5

You might also like