Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 23, Problem 23.2PE
Program Plan Intro
Generic merge sort
Program Plan:
- Import the required packages.
- Create a class “Sorting”:
- Method to sort the numbers gets defined.
- Call the method merge sort that implements the comparable interface.
- Method to sort the string given.
- Define the main method
- Initialize the list that needs to be sorted.
- Call the merge sort.
- Display the sorted list.
- Initialize list that contain strings.
- Call the method merge sort.
- Display the sorted list.
- Define the method “mergeSort()”
- Condition to validate the list contains more than one element.
- First half of the list is sorted by calling the merge1 method
- Loop that iterates to sort the values of the list.
- Second half of the list is sorted by calling the merge method
- Loop that iterates to sort the values of the list.
- Both the list gets merged.
- Define the method “merge1()”
- Perform swap operation by comparing the list.
- Return the value.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
- Give Java Code that finds the number of children using the sequential representation, Linked Implementations Using Array of Child Pointers implementation, linked implementation left-child/right-sibling.
Please code the following and pleace us Stack<T>
a. What is the efficient method for “array resizing” implementation of the stack in “push” and “pop” cases?
b. The following is the postfix evaluation code for your reference. Explain the stack status for evaluating the following postfix expression
3 4 5 + *
Chapter 23 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 23.2 - Prob. 23.2.1CPCh. 23.2 - Prob. 23.2.2CPCh. 23.2 - Prob. 23.2.3CPCh. 23.3 - Prob. 23.3.1CPCh. 23.3 - Prob. 23.3.2CPCh. 23.3 - Prob. 23.3.3CPCh. 23.4 - Prob. 23.4.1CPCh. 23.4 - Prob. 23.4.2CPCh. 23.4 - What is wrong if lines 615 in Listing 23.6,...Ch. 23.5 - Prob. 23.5.1CP
Ch. 23.5 - Prob. 23.5.2CPCh. 23.5 - Prob. 23.5.3CPCh. 23.5 - Prob. 23.5.4CPCh. 23.6 - Prob. 23.6.1CPCh. 23.6 - Prob. 23.6.2CPCh. 23.6 - Prob. 23.6.3CPCh. 23.6 - Prob. 23.6.4CPCh. 23.6 - Prob. 23.6.5CPCh. 23.6 - Prob. 23.6.6CPCh. 23.6 - Prob. 23.6.7CPCh. 23.6 - Prob. 23.6.8CPCh. 23.6 - Prob. 23.6.9CPCh. 23.7 - Prob. 23.7.1CPCh. 23.7 - Prob. 23.7.2CPCh. 23.8 - Prob. 23.8.1CPCh. 23 - Prob. 23.1PECh. 23 - Prob. 23.2PECh. 23 - Prob. 23.3PECh. 23 - (Improve quick sort) The quick-sort algorithm...Ch. 23 - (Check order) Write the following overloaded...Ch. 23 - Prob. 23.7PECh. 23 - Prob. 23.8PECh. 23 - Prob. 23.10PECh. 23 - Prob. 23.11PECh. 23 - Prob. 23.12PECh. 23 - Prob. 23.13PECh. 23 - (Selection-sort animation) Write a program that...Ch. 23 - (Bubble-sort animation) Write a program that...Ch. 23 - (Radix-sort animation) Write a program that...Ch. 23 - (Merge animation) Write a program that animates...Ch. 23 - (Quicksort partition animation) Write a program...Ch. 23 - (Modify merge sort) Rewrite the mergeSort method...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 1- Start by writing your choice from the list given above. Part a. Explain the important technical details about your choice. 2-(continued) Start by again writing your choice from the list given above. Part b. Most of the ADTs in this class were implemented using arrays and linked lists. If appropriate for the ADT you chose in part a., explain which one (an array or a linked list) you would choose to implement it and why. If it doesn’t make sense to implement your ADT using an array or a linked list, explain which other data structure you would use to implement your ADT.arrow_forwardCount word dominators def count_word_dominators(words): If you already solved the earlier count_dominators problem, you might notice that even though the problem was originally stated for lists of integers, the logic of domination did not depend on this fact in any way. As long as the individual elements can be compared with each other for order, the Pythonic spirit of duck typing allows the very same count_dominators function to handle a list of strings just as smoothly as it would handle a list of integers! For example, the function call count_dominators(['dog','emu','cat','bee']) would return 3, since 'emu', 'cat'and 'bee' dominate all words coming after them in the list when using the lexicographic order comparison. If your count_dominators function does not already pass this hurdle, try to rewrite it to contain no baked-in assumptions about elements being specifically integers. However, things become more interesting if we define domination between words of equal length with a…arrow_forwardWrite java code to do the following: Implement the Quicksort algorithm for both generic lists and generic arrays: Please note you cannot make any additional FUNCTIONS OR METHODS, Everything must be housed within the functions I have provided below: public static <T extends Comparable<T>> void quickSort(final List<T> list, final Comparator<T> comparator) {...} public static <T extends Comparable<T>> void quickSort(final T[] array, final Comparator<T> comparator) {...}arrow_forward
- Print the following List in the reversed order using lambda / arrow operator. var array = new List <int>{ 8,2,2,24,5,7,5,3,2,10};arrow_forwardRewrite the Binary search function in the textbook to use a generic type for the array elements. Test the function with arrays of int, double, and string values. *When using test arrays make sure elements are stored in ascending sorted order*arrow_forwardQ 4 Computer Science Write a Java generic Class with user-defined method(s) to exchange the positions of two different elements in an Array List.arrow_forward
- Title: Using Comparable in Singly Linked List I'm writing a singly linked list that can insert, remove, search, and count. When I try to implement generic so that the list can accept different types, the instruction requires the use of Comparable. How is Comparable used in this case (since I'm not sorting anything), and what exactly am I comparing? Do I need to "implements Comparable" or "extends Comparable"?arrow_forwardGo program using generics Output True Falsearrow_forwardcan someone help me with this in C++ (not Java) create a program that reads in two matrices from two different text files. Should use a singly or double linked list to store the two matrices and perform the following operations on them: - Add, Subtract, Mulitply, Transpose, and Determinant Requirements: Use singly or doubly linked list date structures only: - No other library methods or existing collection framework. - No use of Array, ArrayList, List, or Vectors for storing. - No two-dimensional arrays. - Input files can only be read Exactly Once for all operations. For the determinant operation, you may augment your linked list node to retain row/column id and employ recursion to directly implement the standard method for computing determinant of a matrix. You are encouraged to design your own node representation (e.g., each node element has two pointers: one to its next right and another to its next bottom element that facilitate both horizontal and vertical traversals like one gets…arrow_forward
- .“Dangling and wild pointers are known to be problems with pointers”. Justify the given statement with the helpof suitable examplearrow_forwardYou are required to demonstrate competency in any or all of 2D arrays, doubly linked lists, merging of sorted data structures and constructive and destructive programming techniques. Code your solution according to the requirements below. And add comments: Class Tester, method process: Modify the following(in particular method process in class Tester).arrow_forwardJava- The Insertion sort is efficient for large arrays. True or False?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education