Assignment1 Writeup
Assignment1 Writeup
: 1
Problem Statement: Create a Database containing different fields of every student like Roll No,
Name and SGPA.
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.
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:
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) :
****************************************
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 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
.............................................
Studemt Found
do you want to see its data (y/n) y
****************************************
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
Inference:
Learn concept of array class and some sorting algorithm .