0% found this document useful (0 votes)
22 views

DSA Assignment-5

Uploaded by

Ankan Santra
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)
22 views

DSA Assignment-5

Uploaded by

Ankan Santra
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/ 2

Data Structures & Algorithms

Assignment-5

Marks - 100
Note: Attempt this assignment after studying pre-recorded content and after
attending live lectures of DSA

1. The school cafeteria offers circular and square sandwiches at lunch break, referred to by
numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers
square or circular sandwiches.
Implement Using Queue
1700. Number of Students Unable to Eat Lunch (15 marks)
Create A Custom class for implementing Queues on Leetcode Solution (5 marks)
Total - 20 marks

2. Given a binary tree, find its minimum depth.The minimum depth is the number of nodes
along the shortest path from the root node down to the nearest leaf node.
111. Minimum Depth of Binary Tree (20 marks)

3. Given the root of a binary tree, return the postorder traversal of its nodes' values.
145. Binary Tree Postorder Traversal (20 marks)

4. Given the root of a binary tree, return the preorder traversal of its nodes' values.
144. Binary Tree Preorder Traversal (20 marks)

5. Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from
left to right, level by level).
94. Binary Tree Inorder Traversal (20 marks)

Guidelines for submission: Create a LeetCode profile and solve the specified
questions there. Share the links to your solved questions with their time and space
complexities along with a description of explanations. Additionally, include
screenshots of your solutions in a PDF file when you submit your assignment.

Submit the optimized solution for all the questions

Example:

Question was https://leetcode.com/problems/concatenation-of-array/description/


Solution Link -
https://leetcode.com/problems/concatenation-of-array/submissions/1257621340/

Description:
Time Complexity: O(n)
Iterating to the entire n-sized array and for each array element performing O(1) operation of
push.
Space complexity: O(1)
No Extra space is required for the Program Execution, As we have only used an integer type
variable len.
Screenshot:

You might also like