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 12

 Practical No: -12 Experiment No. 12: A double-ended queue(deque) is a linear list in which additions and deletions may be made at either end. Obtain a data representation mapping a deque into a one-dimensional array. Write C++ program to simulate deque with functions to add and delete elements from either end of the deque. Code: using namespace std; #include<iostream> #include<stdio.h> #include<process.h> #define MAX 30 typedef struct dequeue {  int data[MAX];  int rear,front; }dequeue; void initialize(dequeue *p); int isEmpty(dequeue *p); int isFull(dequeue *p); void enqueueRear(dequeue *p,int x); void enqueueFront(dequeue *p,int x); int dequeueFront(dequeue *p); int dequeueRear(dequeue *p); void display(dequeue *p); main() {  int i,x,choice,n;  dequeue q;  initialize(&q);  do  {  cout<<"\n 1.Create \n 2.Insert(rear) \n 3.Insert(front) \n 4.Delete(rear) \n 5.Delete(front)";  cout<<"\n 6.Display \n 7.Ex...

dsa

 https://drive.google.com/drive/folders/1xaWUPlioGjpK0WAmAD-mvlxAuA8eTK1c https://github.com/khan0003-py/SPPU-Computer-4th-Sem-Lab-Codes/tree/master/DSAL

FDS 11

 Practical No: -11 Experiment No. 11: Queues are frequently used in computer programming, and a typical example is the creation of a job queue by an operating system. If the operating system does not use priorities, then the jobs are processed in the order they enter the system. Write C++ program for simulating job queue. Write functions add job and delete job from queue. Code: using namespace std; #include<iostream> #include<stdio.h> #include<conio.h> #include<stdlib.h> #define SIZE 5 void enqueue(int x); void dequeue(); void display(); int FRONT=-1; int REAR=-1; int QUEUE[SIZE]; main() {  int x,ch;  while(1)  {  cout<<"\n 1:Add Job";  cout<<"\n 2:Delete Job";  cout<<"\n 3:Display";  cout<<"\n 4:Exit";  cout<<"\n Enter Your Choice:";  cin>>ch;  switch(ch)  {  case 1:  cout<<"Enter Job:";  cin>>x;  enqueue(x);  break;  case 2: ...

Contact us

Name

Email *

Message *