Skip to main content

DSL 16

Data Structure Lab :


Practical B16 : 

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.

The Code for above problem is as follows :

   
 # sppucseguru  
   
 arr=[]  
 n=int(input("Enter Total no. of Students "))  
 for i in range(n):  
   ele=float(input("Enter Percentage "))  
   arr.append(ele)  
     
 print("Before Sorting : ",arr)  
 def Partition(arr,low,high):  
     pivot=arr[high]  
     pindex=low  
     for i in range(low,high):  
       if arr[i]<pivot:  
         arr[i],arr[pindex]=arr[pindex],arr[i]  
         pindex+=1  
     arr[pindex],arr[high]=arr[high],arr[pindex]  
     return pindex  
   
 def QSort(arr,low,high):  
   if low<high:  
       
     pindexNew=Partition(arr, low, high)  
       
     QSort(arr,low,pindexNew-1)  
     QSort(arr,pindexNew+1,high)  
   
      
 QSort(arr,0,n-1)  
 print("After Sorting : ",arr)  
   

Comments

Popular posts from this blog

Bouncing Ball

Group B   Practical 4 a   Problem Statement :   Write a C++ program to implement bouncing ball using sine wave form. Apply the concept of polymorphism. Check Out Code Here  ðŸ‘‡ Outputs :  Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊

2D Object Transformations

  Group B   Practical 4 a   Problem Statement :    Write C++ program to draw 2-D object and perform following basic transformations a) Scaling b) Translation c) Rotation. Apply the concept of operator overloading. Check Out Code Here  ðŸ‘‡ Output : a) Scaling - b) Translation - c) Rotation - Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊

OOP 4

  Object Oriented Programming Group B - Practical : 4 Problem Statement :  Write a C++ program that creates an output file, writes information to it, closes the file, open it again as an input file and read the information from the file. Check Out Code Here  ðŸ‘‡ Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊