hpc_1-3
hpc_1-3
PRACTICAL NO-01
INTRODUCTION-
What is Google Colab?
Colab is a hosted Jupyter Notebook service that requires no setup to use and provides free
access to computing resources, including GPUs and TPUs. Colab is especially well suited to
machine learning, data science, and education.
Page | 1
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
2. Rename notebook.
Page | 2
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
7. Delete cell.
Page | 3
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
8. Change runtime.
9. Share notebook.
Page | 4
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
Page | 5
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
12. Cloud.
Colab notebooks execute code on Google’s Cloud servers, meaning you can leverage the
power of Google hardware , including GPUs and TPUs , regardless of the power of your
machine. All you need is a browser.
1. Limited resources
2. Session timeouts
3. Dependency management
4. Privacy and security
5. Limited customization
6. Performance variability
7. Storage limits
8. Learning curve
Page | 7
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
PRACTICAL-02
AIM: Execute 20 Linux commands on Google Colab and document their execution.
LIST OF 20 COMANDS:
1. Date - Displays the current date and time.
2. ls - Lists files and directories in the current directory.
3. pwd - Displays the current directory path.
4. whoami - Displays the current user.
5. cd - Changes the directory.
6. hostname - Prints the name of the machine (hostname).
7. mkdir - Creates a new directory.
8. du - Displays disk usage for files and directories.
9. top - Displays real-time system processes and resource usage
10. tree - Displays the structure of the directory as a tree
11. stat - Displays detailed information about the directory, including size
permissions and last modified time.
12. echo - Creates a file inside the directory and writes to it.
13. ls -R - list directories and their contents recursively.
14. ls -l - Lists files in a long format, displaying permissions, owner, size, and
modification time.
15. cat - Displays the contents of the file inside the directory.
16. grep - Searches for the word in the file.
17. mv - Renames the file inside the student directory.
18. zip - Compresses the directory into a zip file.
19. Unzip - Extracts the contents of the file back into the directory.
20. Find - Searches for the directory named in the current directory tree.
EXECUTION OF COMMANDS:
Command 1: date
• Description:
Displays the current date and time.
Page | 8
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
• Code:
!date
Command 2: ls
• Description:
The ls command lists all files and directories in the current working directory.
• Code:
!ls
Command 3: pwd
• Description:
The pwd command prints the absolute path of the current working directory.
• Code: !pwd
Command 4: whoami
• Description:
The whoami command displays the username of the current user.
• Code: !whoami
Page | 9
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
Command 5: cd
• Description:
The cd command is used to navigate between directories.
• Code:
!cd /content && ls
Command 6: hostname
• Description:
Prints the name of the machine (hostname).
• Code:
!hostname
Command 7: mkdir
• Description:
Creates a new directory.
• Code:
!mkdir student
Command 8: du
• Description:
Displays disk usage for files and directories.
• Code:
!du -h
Page | 10
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
Command 9: top
• Description:
Displays real-time system processes and resource usage (limited in Colab).
• Code:
!top -n
• Description:
Displays the structure of the directory as a tree (requires tree to be installed).
• Code:
!tree student
Page | 11
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
• Description:
Displays detailed information about the directory, including size, permissions, and
last modified time.
• Code:
!stat student
• Description:
Creates a file inside the directory and writes to it.
• Code:
!echo "Hello, Student!" > student/welcome.txt
Page | 12
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
Command 13: ls -R
• Description: Used to list directories and their contents recursively, meaning it will list
all files and subdirectories within a directory and continue to list the contents of any
subdirectories.
• Code:
!ls -R student
Command 14: ls -l
• Description:
The command !ls -l student is used in Linux to list the contents of the student
directory in a detailed format.
• Code:
!ls -l student
Page | 13
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
• Description:
Displays the total disk usage of the student directory in a human-readable format.
• Code:
!du -sh student
• Description:
Displays the contents of the file welcome.txt inside the student directory.
• Code:
!cat student/welcome.txt
• Description:
Searches for the word "Student" in the welcome.txt file.
• Code:
Page | 14
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
Command 18: mv
• Description:
Renames the file welcome.txt to hello.txt inside the student directory.
• Code:
!mv student/welcome.txt student/hello.txt
Command19: zip -r
• Description:
Compresses the student directory into a zip file named student.zip.
• Code:
!zip -r student.zip student
• Description:
Extracts the contents of the student.zip file back into the student directory.
• Code:
!unzip student.zip -d extracted_student
Page | 15
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
CONCLUSION:
By executing the above 20 Linux commands on Google Colab, we learned how to interact
with the underlying Linux environment. These commands are essential for managing files,
directories, and system resources in colab or any Linux based system.
Page | 16
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
PRACTICAL NO-03
AIM: Using Divide and Conquer strategies to design a class for Concurrent Quick Sort
using python
• Efficiency: Divide and conquer algorithms typically have a time complexity of O(n
logn), which is more efficient than many other algorithms for large datasets.
• Simplicity: Divide and conquer algorithms are often easy to understand and
implement.
QUICK SORT :
Quick Sort is a divide-and-conquer algorithm that works by selecting a 'pivot' element and
partitioning the array into two sub-arrays, such that:
1. All elements less than the pivot are moved to its left.
2. All elements greater than the pivot are moved to its right.
The process is then recursively applied to the sub-arrays on the left and right of the pivot until
the entire array is sorted.
Page | 17
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
1. Choose a Pivot: Select an element from the array. This element is called the "pivot".
There are different strategies for choosing the pivot, such as picking the first element,
last element, middle element, or a random element.
2. Partition the Array: Rearrange the array so that elements smaller than the pivot are on
its left, and elements greater than the pivot are on its right.
3. Recursively Sort Sub-arrays: Apply the same process to the left and right sub-arrays
(ignoring the pivot since it's already in its correct place).
4. Base Case: The recursion terminates when the sub-array has one or zero elements,
meaning it's already sorted.
def quick_sort(arr):
#Base case: if the array has one or zero elements its already sorted
if len(arr)<=1:
return arr
else:
pivot = arr[-1]
#Recursively sort the left and right parts , then concatenate the results
return quick_sort(left)+[pivot]+quick_sort(right)
if__name__== “__main__”:
#Example array
arr = [10,7,8,9,1,5]
Page | 18
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
FACULTY OF ENGINEERING AND TECHNOLOGY
HIGH PERFORMANCE COMPUTING (303105356)
ENROLLMENT NO-2203031241422
print(“Original Array:”,arr)
Sorted_arr = quick_sort(arr)
print(“Sorted Array:”,sorted_arr)
OUTPUT:
CONCLUSION:
Quick Sort’s average-case performance and efficiency have made it one of the most popular
sorting algorithms, especially for large datasets. It showcases the power of the Divide and
Conquer strategy, though careful consideration of pivot selection is important to avoid worst
case performance. Other sorting algorithms like Merge Sort or Heap Sort offer alternative
advantages, but Quick Sort continues to be a go-to solution for its combination of speed and
elegance in practical scenarios.
Page | 19