0% found this document useful (0 votes)
7 views6 pages

MVR Python Question

The document outlines three problem statements involving tasks and arrays, each with specific constraints and expected time complexities. It includes examples for calculating minimum time units for task execution, maximum XOR of a subarray, and the length of the longest contiguous subarray with equal even and odd elements. Additionally, it describes a project on house price prediction and iris flower classification using exploratory data analysis and machine learning, emphasizing data cleaning, visualization, model building, and evaluation.

Uploaded by

krishnaitb4
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)
7 views6 pages

MVR Python Question

The document outlines three problem statements involving tasks and arrays, each with specific constraints and expected time complexities. It includes examples for calculating minimum time units for task execution, maximum XOR of a subarray, and the length of the longest contiguous subarray with equal even and odd elements. Additionally, it describes a project on house price prediction and iris flower classification using exploratory data analysis and machine learning, emphasizing data cleaning, visualization, model building, and evaluation.

Uploaded by

krishnaitb4
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

Date: 14-12-2025 SET-A

A. Problem statement
You are given a string consisting of uppercase English letters.
Each letter represents a task, and identical letters represent the same task type.
A CPU can execute one task per unit time, but the same task type must have a cooldown of
k units between two executions.
Your task is to compute the minimum number of time units required to complete all tasks.
Idle time is allowed.

Function Definition:

Example:

Input:
tasks = ["A","A","A","B","B","B"]
k=2
Output:
8

Explanation:
One optimal execution order:
A → B → idle → A → B → idle → A → B
Total time = 8 units

Constraints:

 1 <= len(tasks) <= 20,000


 tasks[i] is an uppercase English letter
 0 <= k <= 100
 Each task takes exactly 1 unit of time
 Optimal Time Complexity: O(n)
 Optimal Space Complexity: O(1) (fixed alphabet size)
B. House Price Prediction using EDA and Machine Learning Instructions

Use the given dataset for analysis.


Perform basic data cleaning, visualization, and model building.
Submit your work as a well-structured Jupyter Notebook or report.
Clearly show your code, charts, and final evaluation results.
Data Cleaning & Preparation
a. Perform basic cleaning of the dataset:
i. Handle missing values and duplicates.

ii. Provide a summary of the cleaned dataset.

Exploratory Data Analysis – Charts

b. Create any 2 meaningful charts (e.g., histogram, scatter plot, box plot, correlation
heatmap) to show:

i. The distribution of house prices.

ii. The relationship between house price and at least one key feature (e.g.,
area, bedrooms).

c. Provide a short interpretation of each chart.

Model Building

d. Build a predictive model for house prices using any suitable regression algorithm
e. Split the dataset into train and test sets before training.

Model Evaluation

f. Evaluate the model using at least two metrics (e.g., R², RMSE, MAE).
g. Briefly comment on the performance of your model.

Importing dataset:
from [Link] import fetch_california_housing

data = fetch_california_housing()
Date: 14-12-2025 SET-B

A. Problem Statement:

You are given an integer array nums. Find the maximum XOR of any subarray. A subarray is
contiguous.

Function Definition:

Input:
nums = [8, 1, 2, 12]
Output:
15

Explanation:
Subarray [1, 2, 12] → XOR = 1 ^ 2 ^ 12 = 15, which is maximum.

Constraints:

 1 ≤ len(nums) ≤ 20,000
 0 ≤ nums[i] ≤ 10⁵
 Expected Time Complexity: O(n)
 Expected Space Complexity: O(n)
B. Problem Title: Iris Flower Classification using EDA and Machine Learning

Use the provided Iris dataset for analysis.


Perform basic data cleaning, visualization, and model building. Submit your
work as a well-structured Jupyter Notebook or report. Clearly show your
code, charts, and final evaluation results.

Data Cleaning & Preparation


Perform basic cleaning of the dataset:
 Check for missing values or duplicates.
 Provide a summary of the dataset (features, target classes, sample counts).
Exploratory Data Analysis
Create any 2 meaningful charts (e.g., scatter plot, pair plot, box plot,
histogram) to show:
 The distribution of one numerical feature (e.g., sepal length).
 The relationship between two features (e.g., petal length vs petal width),
highlighting species differences.
Provide a short interpretation of each chart.
Model Building
Build a classification model to predict the species of Iris flowers using any suitable
algorithm (e.g., Logistic Regression, Decision Tree, Random Forest, KNN).
Split the dataset into train and test sets before training.
Model Evaluation
Evaluate the model using at least two metrics (e.g., Accuracy, Precision, Recall, F1-
score).
Briefly comment on the performance of your model.

Importing dataset:
from [Link] import load_iris

data = load_iris()
Date: 14-12-2025 SET-C

A. Problem Statement:

You are given an integer array nums.

Find the length of the longest contiguous subarray where the number of even elements equals
the number of odd elements.

Function Definition:

Input:

nums = [1, 2, 3, 4, 5, 6]

Output:

Explanation

 Even numbers: 2, 4, 6
 Odd numbers: 1, 3, 5
 Entire array has equal count → length = 6

Constraints

 1 ≤ len(nums) ≤ 100,000
 -10⁵ ≤ nums[i] ≤ 10⁵
 Subarray must be contiguous
 Expected Time Complexity: O(n)
 Expected Space Complexity: O(n)
B. Problem Title: Iris Flower Classification using EDA and Machine Learning

Use the provided Iris dataset for analysis.

Perform basic data cleaning, visualization, and model building. Submit your
work as a well-structured Jupyter Notebook or report. Clearly show your
code, charts, and final evaluation results.

Data Cleaning & Preparation


Perform basic cleaning of the dataset:
 Check for missing values or duplicates.
 Provide a summary of the dataset (features, target classes, sample counts).
Exploratory Data Analysis
Create any 2 meaningful charts (e.g., scatter plot, pair plot, box plot,
histogram) to show:
 The distribution of one numerical feature (e.g., sepal length).
 The relationship between two features (e.g., petal length vs petal
width), highlighting species differences.
Provide a short interpretation of each chart.
Model Building
Build a classification model to predict the species of Iris flowers using any suitable
algorithm (e.g., Logistic Regression, Decision Tree, Random Forest, KNN).
Split the dataset into train and test sets before training.
Model Evaluation
Evaluate the model using at least two metrics (e.g., Accuracy, Precision, Recall, F1-
score).
Briefly comment on the performance of your model.

Importing dataset:
from [Link] import load_iris

data = load_iris()

Common questions

Powered by AI

To visualize house price data and understand key relationships, one can use a histogram to observe the distribution of house prices, which can highlight any skewness or outliers in the data. A scatter plot can be used to analyze the relationship between house prices and key features like the size of the house or number of bedrooms, which can reveal trends or correlations. These visualizations assist in forming hypotheses about the factors affecting house prices .

Building a predictive model for house prices involves data cleaning, exploratory data analysis, model building using regression algorithms, and splitting data into train and test sets. The model's effectiveness can be evaluated using metrics such as R², RMSE, and MAE. These metrics provide insights into the model’s predictive power and accuracy. The model's performance is typically commented upon in terms of its predictions against actual values .

Critical considerations for data cleaning in the Iris dataset include checking for missing values and duplicates to ensure data integrity. The exploratory analysis involves creating visuals such as scatter plots to observe the distribution of features (e.g., sepal length) and relationships between features (e.g., petal length vs petal width), highlighting differences among species. These insights help inform model building and feature selection .

Effective methods for cleaning and preparing a dataset for house price prediction include handling missing values and duplicates, which ensures the dataset's integrity. Once cleaned, a summary with descriptive statistics helps in understanding the dataset's structure and consistencies. Ensuring the dataset is void of errors and anomalies is crucial for accurate analysis and is typically the first step before model building and evaluation .

The method to find the longest contiguous subarray with an equal number of even and odd elements involves iterating through the array and maintaining a difference count (evens minus odds). Using a hashmap to store the first occurrence of each difference index enables checking for previously seen differences, indicating an equal number of even and odd numbers. This approach runs in O(n) time complexity, suitable for large arrays .

To calculate the maximum XOR of any subarray in an integer array, one needs to evaluate the XOR of contiguous elements. For example, in the array [8, 1, 2, 12], the subarray [1, 2, 12] gives a maximum XOR value of 15. This computation is significant because XOR operations leverage bitwise manipulation to find maximum value combinations in a computationally efficient manner, with a time complexity of O(n).

Practical considerations for balancing execution and idle times in CPU scheduling include identifying the task with the highest frequency and arranging tasks to minimize idle periods while respecting cooldown requirements. This involves scheduling alternative tasks or deliberate idle times when immediate task execution would violate the cooldown constraint. A greedy strategy that sequentially fills task slots while considering cooldowns ensures efficient use of CPU time .

To efficiently determine the minimum time needed to complete tasks with a cooldown period, the CPU should follow an optimal execution order that minimizes idle time. For example, given tasks ['A', 'A', 'A', 'B', 'B', 'B'] and a cooldown period k=2, one optimal order is A → B → idle → A → B → idle → A → B, which results in a total of 8 units of time. This problem can be solved using a greedy algorithm that balances the execution of tasks and idle periods efficiently. The constraints ensure tasks are distributed as evenly as possible while respecting the cooldown requirement, leading to a time complexity of O(n) and space complexity of O(1) due to a fixed alphabet size .

Managing computation time and space complexity in large datasets involves using efficient algorithms that leverage linear time complexity (O(n)) and constant space for processing. Techniques such as hashmaps for tracking occurrences or differences allow for space optimization, while avoiding nested loops reduces time complexity. With constraints set for each task, balancing these elements ensures optimal performance during data analysis .

Constructing a classification model for the Iris dataset involves data cleaning, exploratory data analysis, model selection (e.g., Logistic Regression, Decision Trees), and training/testing data splits. Model evaluation uses metrics such as accuracy, precision, recall, and the F1-score. High scores in these metrics indicate a model's success, reflecting its ability to accurately classify species and generalize across different data subsets .

You might also like