BIG JAVA: LATE OBJECTS
BIG JAVA: LATE OBJECTS
2nd Edition
ISBN: 9781119626220
Author: Horstmann
Publisher: WILEY
Question
Book Icon
Chapter 14, Problem 4PE
Program Plan Intro

Sort strings in lexicographic order

Program plan:

Main.java

  • Create a class named “Main”. Inside the class,
    • Define the “main ()” method.
    • Declare and define array of strings
    • Instantiate the class
    • Call the method sort to array of strings.
    • Display the resultant after printing.

MergeSorter.java

  • Create a class named “MergeSorter”. Inside the class,
    • Declare the array of strings.
    • Define the constructor.
      • Initialize the array
    • Define the method “Sort()”.
      • Condition to compare the length of the string
      • Assign the first half of the string
      • Assign the second half of the string
      • Loop that for both first half and second half of the string.
      • Sort the first half of the string
      • Sort the second half of the string
      • Call the method merge to combine first and second half of the string.
    • Define the method “merge()”
      • Declare and define the required variables.
      • Loop that iterates to place the smallest element at its position.
      • Use appropriate conditions to place the values at the exact positions.
      • In the same way both first half and second half is sorted and placed at the exact locations.

Blurred answer

Chapter 14 Solutions

BIG JAVA: LATE OBJECTS

Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education