0% found this document useful (0 votes)
16 views9 pages

Amandeep Daa

The document outlines a practical assignment for students to implement the quick sort algorithm using Python libraries such as Numpy, Pandas, and Matplotlib. The assignment includes data generation, manipulation, statistical analysis, and visualization, with a focus on understanding the efficiency of the quick sort method. Students are expected to measure performance, plot results, and analyze the outcomes of their experiments.

Uploaded by

nikhiljha121151
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views9 pages

Amandeep Daa

The document outlines a practical assignment for students to implement the quick sort algorithm using Python libraries such as Numpy, Pandas, and Matplotlib. The assignment includes data generation, manipulation, statistical analysis, and visualization, with a focus on understanding the efficiency of the quick sort method. Students are expected to measure performance, plot results, and analyze the outcomes of their experiments.

Uploaded by

nikhiljha121151
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Worksheet 1

Student Name:Nikhil Kumar Jha UID:24MCA20295


Branch:MCA Section/Group: 6(B)
Semester: 1ST Date of Performance:15-08-2024
Subject Name: DAA LAB Subject Code:24CAT-611

Q1. Implement following:


Question of Worksheet-1 (DAA)

Q. Sort a given set of elements using quick sort method


and determine the time required to sort the elements.
Repeat the experiment for different values of n, the
number of elements in the list to be sorted and plot the
graph of time taken vs n. The element can be read number
generator from a file or can be generated using a random
number generator.

1. Aim/Overview of the practical:

The aim of this project is to demonstrate the use of various Python libraries such as
Numpy, Seaborn, Pandas, Math, Statistical, and Matplotlib. These libraries are
essential for handling data, performing mathematical operations, statistical
analysis, and visualizing data. The goal is to provide a comprehensive
understanding of these libraries and how they can be combined for data analysis.

2. Task to be done:
1. Data Generation and Processing: Use Numpy for creating sample data.
2. Data Manipulation: Use Pandas for data handling and manipulation.
3. Statistical Analysis: Use the Statistics library for basic statistics.
4. Mathematical Operations: Use the Math library for performing various
mathematical operations.
5. Data Visualization: Use Matplotlib for creating visual plots and
Seaborn for advanced visualizations.

3. Algorithm/Flowchart:
# Importing Libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import math
import statistics as stats

# Step 1: Data Generation using Numpy


data = np.random.normal(loc=50, scale=10, size=1000)

# Step 2: Data Manipulation using Pandas


df = pd.DataFrame(data, columns=['Value'])
df['Square'] = df['Value']**2
df['Log'] = np.log(df['Value'])
df['Sin'] = np.sin(df['Value'])

# Step 3: Perform Statistical Analysis using Statistics


mean = stats.mean(df['Value'])
median = stats.median(df['Value'])
std_dev = stats.stdev(df['Value'])
variance = stats.variance(df['Value'])

# Print out some statistics


print(f"Mean: {mean}")
print(f"Median: {median}")
print(f"Standard Deviation: {std_dev}")
print(f"Variance: {variance}")
# Step 4: Mathematical Operations using Math
sqrt_of_mean = math.sqrt(mean)
log_of_mean = math.log(mean)

print(f"Square Root of Mean: {sqrt_of_mean}")


print(f"Logarithm of Mean: {log_of_mean}")

# Step 5: Data Visualization using Matplotlib and Seaborn


# 5.1: Histogram of Data
plt.figure(figsize=(10, 6))
plt.hist(df['Value'], bins=30, color='blue', edgecolor='black')
plt.title('Histogram of Values')
plt.xlabel('Value')
plt.ylabel('Frequency')
plt.show()

# 5.2: Boxplot using Seaborn


plt.figure(figsize=(10, 6))
sns.boxplot(x=df['Value'], color='orange')
plt.title('Boxplot of Values')
plt.show()

# 5.3: Pairplot using Seaborn to visualize the relationship between columns


sns.pairplot(df)
plt.show()

# 5.4: Correlation Heatmap using Seaborn


corr_matrix = df.corr()
plt.figure(figsize=(8, 6))
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt='.2f')
plt.title('Correlation Heatmap')
plt.show()


4. Code for experiment/practical:

# Importing Libraries

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

import seaborn as sns

import math

import statistics as stats

# Step 1: Data Generation using Numpy

data = np.random.normal(loc=50, scale=10, size=1000)

# Step 2: Data Manipulation using Pandas

df = pd.DataFrame(data, columns=['Value'])

df['Square'] = df['Value']**2

df['Log'] = np.log(df['Value'])

df['Sin'] = np.sin(df['Value'])

# Step 3: Perform Statistical Analysis using Statistics

mean = stats.mean(df['Value'])

median = stats.median(df['Value'])
std_dev = stats.stdev(df['Value'])

variance = stats.variance(df['Value'])

# Print out some statistics

print(f"Mean: {mean}")

print(f"Median: {median}")

print(f"Standard Deviation: {std_dev}")

print(f"Variance: {variance}")

# Step 4: Mathematical Operations using Math

sqrt_of_mean = math.sqrt(mean)

log_of_mean = math.log(mean)

print(f"Square Root of Mean: {sqrt_of_mean}")

print(f"Logarithm of Mean: {log_of_mean}")

# Step 5: Data Visualization using Matplotlib and Seaborn

# 5.1: Histogram of Data

plt.figure(figsize=(10, 6))

plt.hist(df['Value'], bins=30, color='blue', edgecolor='black')

plt.title('Histogram of Values')
plt.xlabel('Value')

plt.ylabel('Frequency')

plt.show()

# 5.2: Boxplot using Seaborn

plt.figure(figsize=(10, 6))

sns.boxplot(x=df['Value'], color='orange')

plt.title('Boxplot of Values')

plt.show()

# 5.3: Pairplot using Seaborn to visualize the relationship between columns

sns.pairplot(df)

plt.show()

# 5.4: Correlation Heatmap using Seaborn

corr_matrix = df.corr()

plt.figure(figsize=(8, 6))

sns.heatmap(corr_matrix, annot=True, cmap='coolwarm', fmt='.2f')

plt.title('Correlation Heatmap')

plt.show()plt.show()
5. Result/Output/Writing Summary:
Learning outcomes (What I have learnt):

 Understanding Quicksort: Learn how quicksort operates and its


efficiency compared to other sorting algorithms.
 Performance Measurement: Gain experience in measuring algorithm
performance and understanding time complexity.
 Data Visualization: Develop skills in plotting and interpreting
performance data.
 Experimentation: Experience designing and conducting experiments to
evaluate algorithm efficiency.
 Analysis and Interpretation: Improve the ability to analyze
experimental results and draw meaningful conclusions from them.

Evaluation Grid:

Sr. No. Parameters Marks Obtained Maximum Marks


1. Demonstration and 5
Performance (Pre Lab Quiz)
2. Worksheet 10
3. Post Lab Quiz 5

You might also like