Skip to main content

The Fundamentals of Digital Marketing Certification

The Fundamentals of Digital Marketing Certification
Trying to make use of some spare time during these endless lockdowns. I completed The Fundamentals of Digital Marketing course on Google Digital Garage and got certified. This is not a great victory, nevertheless, I celebrate every small step towards a greater goal. #googlegarage #fundamentalsofdigitalmarketing #digitalmarketing

FDS 6

 Practical No: -6

Experiment No. 6: Write a python program to store first year percentage of students in array. Write

function for sorting array of floating-point numbers in ascending order using quick sort and display

top five scores.

Code:

# Partition position

def top(arr):

 n=len(arr)-1

 for i in range(n,n-5,-1):

 print("top:",arr[i])


def partition(arr, low, high):

 pivotVal = arr[high] # arr[low]

 i = low - 1

 # compare each element with pivotVal

 for j in range(low, high):

 # partition Low and high

 if arr[j] <= pivotVal:

 i += 1 #i=0 intially

 # swapping data at index i with element at j

 arr[i], arr[j] = arr[j], arr[i]

 print(arr)

 # Exchange the pivotVal with the greater data item specified by i

 arr[i + 1], arr[high] = arr[high], arr[i + 1]

 return i + 1


# Quicksort

def quickSort(arr, low, high):

 if low < high:

 pi = partition(arr, low, high)

 print("Pivot val:",arr[pi])

 # recursive call left Sublist

 print("Left:",arr[0:pi])

 quickSort(arr, low, pi - 1)

 print("-"*50)

 # recursive call right Sublist

 print("Right:",arr[pi:high])

 quickSort(arr, pi + 1, high)

 print(arr)


#main proagram

array = [78.5, 67.2, 22.8, 31.9, 10.5, 39.4, 46.0]

print("Unsorted array Element")

print(array)

n = len(array)

quickSort(array, 0, n - 1)

print('Sorted array in Ascending Order:')

print(array)

top(array)





Output:

Unsorted array Element

[78.5, 67.2, 22.8, 31.9, 10.5, 39.4, 46.0]

[22.8, 67.2, 78.5, 31.9, 10.5, 39.4, 46.0]

Pivot val: 46.0

Left: [22.8]

--------------------------------------------------

Right: [46.0, 78.5, 31.9, 10.5, 39.4]

[22.8, 46.0, 31.9, 78.5, 10.5, 39.4, 67.2]

Pivot val: 67.2

Left: [22.8, 46.0, 31.9]

--------------------------------------------------

Right: [67.2, 10.5, 39.4]

[22.8, 46.0, 31.9, 67.2, 10.5, 39.4, 78.5]

Pivot val: 78.5

Left: [22.8, 46.0, 31.9, 67.2, 10.5]

--------------------------------------------------

Right: [78.5]

[22.8, 46.0, 31.9, 67.2, 10.5, 78.5, 39.4]

[22.8, 46.0, 31.9, 67.2, 10.5, 78.5, 39.4]

[22.8, 46.0, 31.9, 67.2, 10.5, 78.5, 39.4]

Sorted array in Ascending Order:

[22.8, 46.0, 31.9, 67.2, 10.5, 78.5, 39.4]

top: 39.4

top: 78.5

top: 10.5

top: 67.2

top: 31.9

GALLERY

GALLERY
photos

ABOUT

HTML CSS, VB.net Developer and Java, C programming. With Loves Problem Solving and to Unreval the Mysteries behind the Magic of Computer Programming

Followers

MY PROJECTS

Popular posts from this blog

FDS 5

 Practical No: -5 Experiment No. 6: Write a python program to store first year percentage of students in array. Write function for sorting array of floating-point numbers in ascending order using a) Selection Sort b) Bubble sort and display top five score Code: # Function for Selection Sort of elements def Selection_Sort(marks):  for i in range(len(marks)):  # Find the minimum element in remaining unsorted array  min_idx = i  for j in range(i + 1, len(marks)):  if marks[min_idx] > marks[j]:  min_idx = j  # Swap the minimum element with the first element  marks[i], marks[min_idx] = marks[min_idx], marks[i]  print("Marks of students after performing Selection Sort on the list : ")  for i in range(len(marks)):  print(marks[i]) #<---------------------------------------------------------------------------------------> # Function for Bubble Sort of elements def Bubble_Sort(marks):  n = len(marks)  # Traverse throug...

FDS 4

 Practical No: -4 Experiment No. 4: a) Write a python program to store roll numbers of student in array who attended training program in random order. Write function for searching whether particular student attended training program or not, using linear search and sentinel search. b) Write a Python program to store roll numbers of student array who attended training program in sorted order. Write function for searching whether particular student attended training program or not, using Binary search and Fibonacci search. Code: import array as arr # Accept the Roll Numbers of the students def accept_roll():  a = arr.array('I', [])  no_stud = int(input("Enter the number of Students : "))  for i in range(0, no_stud):  a.append(int(input("Enter the Roll Number : ")))  return a # Print the Roll Numbers of the Students def print_roll(a):  for i in range(0, len(a)):  print("\t", a[i], end=" ")  print() # Linear Search def linear_search(a, x):  f...

Contact us

Name

Email *

Message *