Module 1 Assignment
Module 1 Assignment
Q.No 3. What does the acronym SMART stand for in the context of setting goals during
problem-solving?
a) Simple, Manageable, Achievable, Relevant, Timely
b) Specific, Measurable, Achievable, Relevant, Time-bound
c) Strategic, Meaningful, Attainable, Realistic, Timeless
d) Structured, Motivating, Actionable, Reflective, Tangible
e) Answer: (b) Specific, Measurable, Achievable, Relevant, Time-bound
Q.No 4. During the problem-solving process, what does brainstorming primarily involve?
a) Criticizing ideas
b) Generating ideas
c) Implementing solutions
d) Ignoring alternatives
Answer: (b) Generating ideas
Q.No 10. What is a common pitfall to avoid when solving problems in a group setting?
a) Encouraging collaboration
b) Groupthink
c) Embracing diversity of thought
d) Open communication
Answer: (b) Groupthink
Module 1 – Worksheet 2
Fill in the blanks
Q.No.1. In top-down design, the problem is broken down into subproblems.
Answer: smaller
Q.No.2. The top-level module in top-down design represents the of the problem.
Answer: overall structure
Q.No.3. The process of breaking down a complex problem into manageable parts in top-down
design is often referred to as .
Answer: decomposition
Q.No 2: Write an algorithm for predicting house prices based on features like size,
location, and number of bedrooms
Hint :
1. Collect and Prepare Data
2. Define Features and Target
3. Initialize Model Parameters
4. Define the Hypothesis Function
5. Define the Cost Function – Mean Squared Error
6. Gradient Descent – minimizing the cost function
7. Training the Model
8. Make Predictions
9. Evaluate the Model
10. Deploy the Model
Solution:
Q. No 3 : Write the algorithm for Breadth First Search
Hint :
a. Traverse Breadth wise
b. Root Node : A
c. Output: A B C D E F G
Solution:
def fibonacci(n):
fib = [0] * (n+1)
fib[0] = 0
fib[1] = 1
return fib[n]
Hint : The algorithm uses a constant amount of space
Solution :
Q. No: 6. Calculate the Time Complexity of the following code
def quick_sort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr)//2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
1. Set maxElement to the first element of 1. Set maxElement to the first element of
the array (maxElement = arr[0]) the array (maxElement = arr[0])
2. For i from 1 to n-1: 2. For i from 1 to n-1:
a. If arr[i] is greater than maxElement: a. For j from i+1 to n:
i. Set maxElement to arr[i] i. If arr[j] is greater than maxElement:
3. Return maxElement - Set maxElement to arr[j]
3. Return maxElement
Hint:
The time complexity of Algorithm A is O(n), where 'n' is the size of the input array.
The time complexity of Algorithm B is O(n^2), where 'n' is the size of the input array.
Solution