0% found this document useful (0 votes)
9 views10 pages

Assignment1 Writeup

Uploaded by

ayushjagtap761
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)
9 views10 pages

Assignment1 Writeup

Uploaded by

ayushjagtap761
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/ 10

Assignment No.

: 1

Title: Creating Student Database


Course Outcome: CO1, CO2,
CO3, CO5
Date of Completion:
Assessment Grade / Marks:
Assessor’s Sign with Date:
Assignment No: 1
Title: Creating Student Database of SE IT Class

Aim: : To study data structures and their implementations and applications.

Objective: To study data structures and their implementations and applications.

Problem Statement: Create a Database containing different fields of every student like Roll No,
Name and SGPA.

Course Outcome: CO Number: Applicable CO : Blooms Taxonomy Category

1. Analyze algorithms and to determine algorithm correctness and time efficiency class.
2. Implement abstract data type (ADT) and data structures for given application.
3. Design algorithms based on techniques like brute -force, divide and conquer, greedy, etc.).
4. Analyze of algorithms with respect to time and space complexity.

Requirements: (Components / Digital Kits / Platform / Software / Hardware)


 Platform :- Online GDB Compiler

Theory / Procedure / Diagrams / Circuits:


Class:- A class in C++ is the building block, that leads to Object-Oriented programming. It is a
user-defined data type, which holds its own data members and member functions, which
can be accessed and used by creating an instance of that class. A C++ class is like a
blueprint for an object. Data members are the data variables and member functions are the
functions used to manipulate these variables and together these data members and member
functions defines the properties and behavior of the objects in a Class.
Member Functions in Classes
There are 2 ways to define a member function in class:
• Inside class definition
• Outside class definition

Object:- An object is an instance of a Class. When a class is defined, no memory is allocated but
when it is instantiated (i.e. an object is created) memory is allocated. We declare objects
of a class with exactly the same sort of declaration that we declare variables of basic
types.
As we can see, we can create objects of a class in any function of the program. We can also
create objects of a class within the class itself, or in other classes. Also, we can create as
many objects as we want from a single class.
Array Of Object :- Like array of other user-defined data types, an array of type class can also be
created. The array of type class contains the objects of the class as its individual
elements. Thus, an array of a class type is also known as an array of objects. An
array of objects is declared in the same way as an array of any built-in data type.
The syntax for declaring an array of objects is:

class_name array_name [size] ;

Bubble Sort :- Bubble sort works on the repeatedly swapping of adjacent elements until they are not
in the intended order. It is called bubble sort because the movement of array elements
is just like the movement of air bubbles in the water. Bubbles in water rise up to the
surface; similarly, the array elements in bubble sort move to the end in each iteration.
Although it is simple to use, it is primarily used as an educational tool because the
performance of bubble sort is poor in the real world. It is not suitable for large data
sets. The average and worst-case complexity of Bubble sort is O(n2), where n is a
number of items.

Insertion Sort :- Insertion sort is a simple sorting algorithm that works similar to the way you sort
playing cards in your hands. The array is virtually split into a sorted and an unsorted
part. Values from the unsorted part are picked and placed at the correct position in the
sorted part.

Quick Sort :- QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and
partitions the given array around the picked pivot. There are many different versions
of quickSort that pick pivot in different ways.
a. Always pick first element as pivot.
b. Always pick last element as pivot (implemented below)
c. Pick a random element as pivot.
d. Pick median as pivot.

Linear search :- Linear search is the simplest search algorithm and often called sequential search. In
this type of searching, we simply traverse the list completely and match each element
of the list with the item whose location is to be found. If the match found then location
of the item is returned otherwise the algorithm return NULL.Linear search is mostly
used to search an unordered list in which the items are not sorted.

Binary search :- Binary search is the search technique which works efficiently on the sorted lists.
Hence, in order to search an element into some list by using binary search technique,
we must ensure that the list is sorted.Binary search follows divide and conquer
approach in which, the list is divided into two halves and the item is compared with the
middle element of the list. If the match is found then, the location of middle element is
returned otherwise, we search into either of the halves depending upon the result
produced through the match.
Algorithm / Methods / Steps: (if applicable) :

Step 1: CREATE CLASS STUDENT


Step 2: DECLARE VARIABLES roll as integer, name as string , Sgpa as float
Step 3: DECLARE FUNCTION GETDATA()

Sub Function BubbleSort():

Step 1: FUNCTION START


Step 2:I DECLARE VARIABLE n as integer
Step 3: INITIALIZE n=size
Step 3:INITIALIZE i=0
Step 4:FOR (i<n),i++
Step 5: INITIALIZE j=0
Step 6:FOR (j<n-1),j++
Step 7:IF (ARR[j]>ARR[j+1])
Step 8:SWAP ARR[j] AND ARR[j+1]
Step 9:END FOR
Step 10:DISPLAY The following is list of Student according to Roll No in ascending order

Sub Function InsertionSort():

Step 1: FUNCTION START


Step 2:DECLARE VARIABLE key as string,j as integer,n as integer
Step 3:INITIALIZE n=size
Step 4: INITIALIZE i=1
Step 5:FOR (i<n),i++
Step 6:SET key=ARR[i]
Step 7:SET j=i-1
Step 8:WHILE j>=0 AND ARR[j]>key
Step 9:SET ARR[j+1]=ARR[j]
Step 10:SET j=j-1
Step 11:END
WHILE
Step 12:SET ARR[j+1]=key
Step 13:END FOR
Step 14:DISPLAY The following is the list of the students alphabetically

Sub Function QuickSort():


Step 1: FUNCTION START
Step 2:DECLARE VARIABLE l,r,p as double
Step 3:SWAP(float sgpa[],int i,int j)
Step 4:SWAP ARR[i] AND ARR[j]
Step 5: PARTITION(float sgpa[],int l,int r)
Step 6:SET p=ARR[r]
Step 7:SET i=l-1
Step 8:INITIALIZE j=1
Step 9:FOR(j<r),j++
Step 10:IF(ARR[j]>P),i+
+
Step 11:SWAP(sgpa,i,j)
Step 12:END FOR
Step 13:SWAP(sgpa,i+1,r)
Step 14:RETURN (i+1)
Step 15:QUICKSORT(int l,int r)
Step 16:IF(l<r)
Step 17:SET p=partition(sgpa,l,r)
Step 18: QUICKSORT(l,p-1)
Step 19: QUICKSORT(p+1, r)
Sub Function LinearSearch():
Step 1: FUNCTION START
Step 2:DECLARE VARIABLE flag,b,size as integer
Step 3:DISPLAY Enter the SGPA you want to search
Step 4:READ b
Step 5:INITIALIZE i=0
Step 6:FOR (i<size),i++
Step 7:IF(ARR[i]==b)
Step 8:DISPLAY Student name is:
Step 9:SET flag=1
Step 10:IF(flag==0)
Step 11:DISPLAY Student not found

Sub Function Binarysearch():


Step 1: FUNCTION START
Step 2:DISPLAY Enter the Student Name you want to search
Step 3:READ a
Step 4:DECLARE VARIABLE I,n,min,max,mid as integer
Step 5:WHILE (min<=max)
Step 6:SET mid=min+max/2
Step 7:IF (ARR[mid]<a)
Step 8:SET min=mid + 1
Step 9:ELSE IF (ARR[mid]>a)
Step 10:SET max=mid - 1
Step 11:IF
(ARR[mid]==a)
Step 12:DISPLAY The Student Name
Step 13:BREAK
Step 14:END WHILE
Step 15:IF (min>max)
Step 16:DISPLAY The Student is not found

Input: (Test Cases / Data sets / Database Links) :

****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice 1
.............................................
Enter number of student 6
.............................................

Enter data for students 1


Enter Name of Student : mujeeb
Enter Roll no of Student : 36
Enter Student SGPA : 9.11

.............................................
Enter data for students 2
Enter Name of Student : tejaswini
Enter Roll no of Student : 56
Enter Student SGPA : 9.12

.............................................
Enter data for students 3
Enter Name of Student : sanika
Enter Roll no of Student : 27
Enter Student SGPA : 9.05

.............................................
Enter data for students 4
Enter Name of Student : harshad
Enter Roll no of Student : 35
Enter Student SGPA : 9.6

.............................................
Enter data for students 5
Enter Name of Student : pravin
Enter Roll no of Student : 32
Enter Student SGPA : 9.45

.............................................
Enter data for students 6
Enter Name of Student : samrudhi
Enter Roll no of Student : 43
Enter Student SGPA : 9.23

.............................................
****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice 2
.............................................

NAME :mujeeb Roll no :36 SGPA :9.11


NAME :tejaswini Roll no :56 SGPA :9.12
NAME :sanika Roll no :27 SGPA :9.05
NAME :harshad Roll no :35 SGPA :9.60
NAME :pravin Roll no :32 SGPA :9.45
NAME :samrudhi Roll no :43 SGPA :9.23
****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice 3
.............................................

Enter sgpa to search 9.45

Studemt Found
do you want to see its data (y/n) y

NAME :pravin Roll no :32 SGPA :9.45


****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice 4
.............................................

Sorted Roll Call List

NAME :sanika Roll no :27 SGPA :9.05


NAME :pravin Roll no :32 SGPA :9.45
NAME :harshad Roll no :35 SGPA :9.60
NAME :mujeeb Roll no :36 SGPA :9.11
NAME :samrudhi Roll no :43 SGPA :9.23
NAME :tejaswini Roll no :56 SGPA :9.12

****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice 5
.............................................
Enter Name to search mujeeb

Studemt Found
do you want to see its data (y/n) y

NAME :mujeeb Roll no :36 SGPA :9.11


****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice 6
.............................................

NAME :harshad Roll no :35 SGPA :9.60


NAME :mujeeb Roll no :36 SGPA :9.11
NAME :pravin Roll no :32 SGPA :9.45
NAME :samrudhi Roll no :43 SGPA :9.23
NAME :sanika Roll no :27 SGPA :9.05
NAME :tejaswini Roll no :56 SGPA :9.12
****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice 7
.............................................

NAME :tejaswini Roll no :56 SGPA :9.12


NAME :sanika Roll no :27 SGPA :0.00
NAME :samrudhi Roll no :43 SGPA :9.05
NAME :pravin Roll no :32 SGPA :9.23
NAME :mujeeb Roll no :36 SGPA :9.45
NAME :harshad Roll no :35 SGPA :9.11
****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice
NAME :mujeeb Roll no :36 SGPA :9.11
****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice 6
.............................................

NAME :harshad Roll no :35 SGPA :9.60


NAME :mujeeb Roll no :36 SGPA :9.11
NAME :pravin Roll no :32 SGPA :9.45
NAME :samrudhi Roll no :43 SGPA :9.23
NAME :sanika Roll no :27 SGPA :9.05
NAME :tejaswini Roll no :56 SGPA :9.12
****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice 7
.............................................

NAME :tejaswini Roll no :56 SGPA :9.12


NAME :sanika Roll no :27 SGPA :0.00
NAME :samrudhi Roll no :43 SGPA :9.05
NAME :pravin Roll no :32 SGPA :9.23
NAME :mujeeb Roll no :36 SGPA :9.45
NAME :harshad Roll no :35 SGPA :9.11
****************************************
MAIN MENU
****************************************
| 1. Enter data |
| 2. Show Data |
| 3. Search Student by SGPA |
| 4. Show Roll List |
| 5. Search student by name |
| 6. Name List |
| 7. Topper List |
| 8. Exit |
****************************************
Enter your choice
EXIT

Inference:
Learn concept of array class and some sorting algorithm .

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy