Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 23.4, Problem 23.4.3CP

What is wrong if lines 6–15 in Listing 23.6, MergeSort.java, are replaced by the following code?

// Merge sort the first half

int[] firstHalf = new int[list.length / 2 + 1];

System.arraycopy(list, 0, firstHalf, 0, list.length / 2 + 1);

mergeSort(firstHalf);

// Merge sort the second half

int secondHalfLength = list.length - list. length / 2 - 1;

int[] secondHalf = new int[secondHalfLength];

System.arraycopy(list, list.length / 2 + 1,

 secondHalf, 0, secondHalfLength);

mergeSort(secondHalf);

Blurred answer
Students have asked these similar questions
Direction: Continue the code below and add case 4, case 5, and case 6. Add 3 more functions aside from insert, getValue, and clear from List ADT import java.util.LinkedList; import java.util.Scanner; class SampleLL { } public static void main(String[] args) { LinkedList 11s = new LinkedList(); String msg = "Choose a function: \n [1] Insert, [2]Get Value, [3]Clear, [0] Exit"; System.out.println(msg); Scanner scan= new Scanner(System.in); int choice scan.nextInt (); while(true) { } if (choice =0) { } System.exit(0); switch(choice) { } case 1: System.out.println("Enter a word/symbol:"); break; case 2: System.out.println("Enter a number: "); break; 11s.add(scan.next()); break; case 3 11s.clear(); default: System.out.println("Invalid input!"); break; System.out.println(11s.get (scan.nextInt())); System.out.println(msg); choice scan.nextInt ();
see the image and answer the 2 questions. Thanks
int binarySearch (const int list(), int listLength, int searchitem) int first - 0: int last - listLength - 1; int mid; bool found - false; while (first searchItem) last - mid - 1; else first - mid + 1 if (found) return mid; else return -1, //end binarysearch Consider using the Binary Search Algorithm, shown above, to find if 75 belongs to the following list: 4 8 25 | 34 | 45 48 | 66 | 75 | 89 95 |19 39 At iteration-1 inside the algorithm, What will be the value of the variables: first, mid, last? O1. First= 1, Mid=6, and Last=12 OI. First= 1, Mid=6, and Last=11 O II. First= 0, Mid=5, and Last=11 O V. First= 0, Mid=5, and Last=12
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
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
Introduction to Linked List; Author: Neso Academy;https://www.youtube.com/watch?v=R9PTBwOzceo;License: Standard YouTube License, CC-BY
Linked list | Single, Double & Circular | Data Structures | Lec-23 | Bhanu Priya; Author: Education 4u;https://www.youtube.com/watch?v=IiL_wwFIuaA;License: Standard Youtube License