
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question

Transcribed Image Text:Write a Java program that:
• Defines a string array with a length of 15.
• Populates the array with random strings of varying lengths.
• Sorts this array into lexicographical order using three sorting algorithms.
• Merge sort
• Quick sort
• Radix sort
• Tests these 3 sorting methods.
• Provides a big-Oh characterization, in terms of n, of the running time of these three
algorithms.
Improve the merge sort so that the time complexity of the best case is O(N).
Write a Java program that:
Defines an array of custom objects representing students, each with attributes like
name, age, and GPA.
Populates the array with random student data.
• Sorts this array based on GPA using three sorting algorithms.
Heap sort
Shell sort
Bucket sort
• Tests these 3 sorting methods.
• Gives a big-Oh characterization, in terms of n, of the running time of these three
algorithms.
Improve the bucket sort so that the time complexity of the average case is O(N).
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 12 images

Knowledge Booster
Similar questions
- Shell sort is an in-place comparison-based sorting algorithm which is based on insertion sort algorithm. It works as follow : It breaks the original list into a number of smaller sublists, each of which is sorted using an insertion sort. The unique way that these sublists are chosen is the key to the shell sort. Instead of breaking the list into sublists of contiguous items, the shell sort uses an increment i, sometimes called the gap, to create a sublist by choosing all items that are i items apart. n a) We say that the our initial gap is floor: when we divide our sequence into 2k n sublists where 2k k>0 be the number of passes that can be increment until the denominator not greater than n, n and then sorting the elements which are position away with insertion sort. We have three 2k passes for an array size of 8 to 15. Demonstrate the Shell algorithm on the input array A = [35,33,42,10,14,19,27,44] showing how even- %3D п tually the algorithm outputs the sorted array…arrow_forwardImplement the following algorithms in Java: A) A variant of QUICKSORT which returns without sorting subarrays with fewer than k elements and then uses INSERTION-SORT to sort the entire nearly-sorted array (slide 24).B) A variant of QUICKSORT using the median-of-three partitioning scheme.Slide 24:•Cutoff to INSERTION-SORT (as in MERGE-SORT). Alternatively: −When calling QUICKSORT on a subarray with fewer than k elements, return without sorting the subarray −After the top-level call to QUICKSORT returns, run INSERTION-SORT on the entire array to finish the sorting process −Taking advantage of the fast running time of INSERTION-SORT when its input is “nearly” sorted •Tail call optimisation convert the code so that it makes only one recursive call −Usually good compilers do that for us • Iterative version with the help of an auxiliary stackarrow_forwardWrite a C program that gets a positive integer number, n, from the user, and generates n positive random integer values and stores them in a one-dimensional array. Then it starts the timer and sorts the numbers in ascending order using bubble sort technique and display the sorted array on the screen along with the elapsed time. • Bubble Sort is a simple sorting algorithm that works by continually swapping the adjacent elements in an unsorted array if they are not in a right order. Please explain each step as I would like to understand and not copy. Thank you!arrow_forward
- In Python: Code two versions of Quicksort algorithms, one using the Lomuto method and one using the Hoare method. Clearly document your code so that it is clear how and why your algorithms are correct. For each of the two algorithms the output must be the following three items: the total numberof comparisons, the total number of swaps, and the total running time. Demonstrate your two Quicksort algorithms on the input array A= [2, 8, 7, 1, 3, 5, 6, 4].arrow_forwardWrite a version of the bubble sort algorithm that sorts a list of integers in descending order. Namely, change the bubble sort method to sort the parameter array in descending order. Hint: Bubble sort: void bubbleSort(int array(1) { int size = array.length; boolean isChanged = false; for (int i = 0; i < size - 1; i++) isChanged = false; for (int j = 0; j < size . 1 . 1; j++) if (array(s) > array() + 1]) { int temp = array(s); array[3] . arrays + 1); array() + 1] = temp; is Changed = true; } if (isChanged) break;arrow_forwarddef sorting(x, i, j) if j+1-i < 10 then Mergesort(x, i, j); t1 = i + (j+1-i)/3 t2 = i + 2*(j+1-i)/3 Sorting(x, i, t2) Sorting(x, i, j) Sorting(x, i, t2) // x is an array, I and j are first and last indices of this part of the array // on k elements, takes O(k log k) time worst case analysis?arrow_forward
- Answer the given question with a proper explanation and step-by-step solution. javaarrow_forwardIn Python: Let n be a (large) positive integer of your choice. We want to know which of the two Quicksort algorithms methods (he Lomuto method and the Hoare method) is superior when sorting arrays containing n elements. To answer this question, you will run Quicksort on 10000 random permutations of [1,2,3, . . . , n], on each of your two Quicksort algorithms.arrow_forwardJava Quick Sort but make it read the data 10, 7, 8, 9, 1, 5 from a file not an array // Java implementation of QuickSort import java.io.*; class GFG { // A utility function to swap two elements static void swap(int[] arr, int i, int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } /* This function takes last element as pivot, places the pivot element at its correct position in sorted array, and places all smaller (smaller than pivot) to left of pivot and all greater elements to right of pivot */ static int partition(int[] arr, int low, int high) { // pivot int pivot = arr[high]; // Index of smaller element and // indicates the right position // of pivot found so far int i = (low - 1); for (int j = low; j <= high - 1; j++) { // If current element is smaller // than the pivot if…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY