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 19.5, Problem 19.5.2CP
Program Plan Intro
Sort method in “Listing 19.4”:
The sort method in “Listing 19.4” used sort the values of generic type “E[]” as parameter and returns the sorted values.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
You will reverse your student ID by the linked list of Struct in C!!!!
Input: 1->2->3->4->5->NULL
Output: 5->4->3->2->1->NULL
Create a linked list and insert your student ID elementwise to the list.
Reverse the linked list and printout the result.
Hint: You can use additional pointers to reverse the linked list. You can also use a stack and then simply assign the element to the stack and it will be reversed. Linked list, Stack, Queue example source code is available on week 7 resources section.
You only need to write a Java method as described, not a complete program or class.
Q1. Write the following method that returns thesmallest element in an ArrayList:public static <E extends Comparable<E>> E min(ArrayList<E> list).
Chapter 19 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 19.2 - Are there any compile errors in (a) and (b)?Ch. 19.2 - Prob. 19.2.2CPCh. 19.2 - Prob. 19.2.3CPCh. 19.3 - Prob. 19.3.1CPCh. 19.3 - Prob. 19.3.2CPCh. 19.3 - Prob. 19.3.3CPCh. 19.3 - Prob. 19.3.4CPCh. 19.4 - Prob. 19.4.1CPCh. 19.4 - Prob. 19.4.2CPCh. 19.5 - Prob. 19.5.1CP
Ch. 19.5 - Prob. 19.5.2CPCh. 19.6 - What is a raw type? Why is a raw type unsafe? Why...Ch. 19.6 - Prob. 19.6.2CPCh. 19.7 - Prob. 19.7.1CPCh. 19.7 - Prob. 19.7.2CPCh. 19.7 - Prob. 19.7.3CPCh. 19.7 - Prob. 19.7.4CPCh. 19.8 - Prob. 19.8.1CPCh. 19.8 - Prob. 19.8.2CPCh. 19.8 - Prob. 19.8.3CPCh. 19.8 - Prob. 19.8.4CPCh. 19.8 - Prob. 19.8.5CPCh. 19.9 - Prob. 19.9.1CPCh. 19.9 - How are the add, multiple, and zero methods...Ch. 19.9 - How are the add, multiple, and zero methods...Ch. 19.9 - What would be wrong if the printResult method is...Ch. 19 - (Revising Listing 19.1) Revise the GenericStack...Ch. 19 - Prob. 19.2PECh. 19 - (Distinct elements in ArrayList) Write the...Ch. 19 - Prob. 19.4PECh. 19 - (Maximum element in an array) Implement the...Ch. 19 - (Maximum element in a two-dimensional array) Write...Ch. 19 - Prob. 19.7PECh. 19 - (Shuffle ArrayList) Write the following method...Ch. 19 - (Sort ArrayList) Write the following method that...Ch. 19 - (Largest element in an ArrayList) Write the...Ch. 19 - Prob. 19.11PE
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
- def remove_occurences[T](xs:List[T], elem: T, n:Int) : List[A] = {} Using the function above, can you show me how to make a polymorphic function in scala where the program removes elem , n number of times from the list. If n > elem then remove all elem from the list For example: remove_occurences(List(4,5,6,7,4),4,1) -> List(5,6,7,4)remove_occurences(List(4,5,6,7,4),4,2) -> List(5,6,7)remove_occurences(List(4,5,6,7,4),2,2) -> List(4,5,6,7,4)arrow_forwardCan you help me please: Write a program to test various operations of the class doublyLinkedList. Your program should accept a list of integers from a user and use the doubleLinkedList class to output the following: The list in ascending order. The list in descending order. The list after deleting a number. A message indicating if a number is contained in the list. Output of the list after using the copy constructor. Output of the list after using the assignment operator. An example of the program is shown below: Enter a list of positive integers ending with -999: 83 121 98 23 57 33 -999 List in ascending order: 23 33 57 83 98 121 List in descending order: 121 98 83 57 33 23 Enter item to be deleted: 57 List after deleting 57 : 23 33 83 98 121 Enter item to be searched: 23 23 found in the list. ********Testing copy constructor*********** intList: 23 33 83 98 121 ********Testing assignment operator*********** temp: 23 33 83 98 121 Your program should use the value -999 to denote the…arrow_forwardAutomated testing is required Your solutions can use:• the [] operator to get and set list elements (e.g., lst[i] and lst[i] = a)• the in and not in operators (e.g., a in lst)• the list concatenation operator (e.g., lst1 + lst2)• the list replication operator (e.g., lst * n or n * lst)• Python's built-in len, min and max functions, unless otherwise noted.Your solutions cannot use:• list slicing (e.g., lst[i : j] or (lst[i : j] = t)• the del statement (e.g., del lst[0])• Python's built-in reversed and sorted functions.• any of the Python methods that provide list operations, e.g., sum, append, clear, copy, count, extend, index, insert, pop, remove, reverse and sort• list comprehensions using python language Use the function design recipe to develop a function named unique_list. The function takes a list of strings, which may be empty. The function returns a new list that includes the first occurrence of each value in a list and omits later repeats. The returned list should include the…arrow_forward
- Automated testing is required Your solutions can use:• the [] operator to get and set list elements (e.g., lst[i] and lst[i] = a)• the in and not in operators (e.g., a in lst)• the list concatenation operator (e.g., lst1 + lst2)• the list replication operator (e.g., lst * n or n * lst)• Python's built-in len, min and max functions, unless otherwise noted.Your solutions cannot use:• list slicing (e.g., lst[i : j] or (lst[i : j] = t)• the del statement (e.g., del lst[0])• Python's built-in reversed and sorted functions.• any of the Python methods that provide list operations, e.g., sum, append, clear, copy, count, extend, index, insert, pop, remove, reverse and sort• list comprehensions using python language Use the function design recipe to develop a function named sum_range. The function takes a list of integers, which may be empty, and two indices m, n what specify the start and end range. The function returns the sum of the numbers in the list between the indices of a specified…arrow_forwardAutomated testing is required Your solutions can use:• the [] operator to get and set list elements (e.g., lst[i] and lst[i] = a)• the in and not in operators (e.g., a in lst)• the list concatenation operator (e.g., lst1 + lst2)• the list replication operator (e.g., lst * n or n * lst)• Python's built-in len, min and max functions, unless otherwise noted.Your solutions cannot use:• list slicing (e.g., lst[i : j] or (lst[i : j] = t)• the del statement (e.g., del lst[0])• Python's built-in reversed and sorted functions.• any of the Python methods that provide list operations, e.g., sum, append, clear, copy, count, extend, index, insert, pop, remove, reverse and sort• list comprehensions using python language Use the function design recipe to develop a function named max_occurrences. The function takes a list of integers, which may be empty. The function returns value of the maximum occurrences in a given list. For example, when the function’s argument is [2, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1,…arrow_forwardAutomated testing is required Your solutions can use:• the [] operator to get and set list elements (e.g., lst[i] and lst[i] = a)• the in and not in operators (e.g., a in lst)• the list concatenation operator (e.g., lst1 + lst2)• the list replication operator (e.g., lst * n or n * lst)• Python's built-in len, min and max functions, unless otherwise noted.Your solutions cannot use:• list slicing (e.g., lst[i : j] or (lst[i : j] = t)• the del statement (e.g., del lst[0])• Python's built-in reversed and sorted functions.• any of the Python methods that provide list operations, e.g., sum, append, clear, copy, count, extend, index, insert, pop, remove, reverse and sort• list comprehensions using python language Use the function design recipe to develop a function named max_min. The function takes a list of integers. (Assume that the list has at least two integers). The function returns the largest and smallest elements in the list as a string. For example, when the function's argument is…arrow_forward
- Modify the quick sort implementation in the textbook to sort the array using pivot as the median of the first, last, and middle elements of the array. Add the modified quick sort implementation to the arrayListType class provided (arrayListType.h). Ask the user to enter a list of positive integers ending with -999, sort the integers, and display the pivots for each iteration and the sorted array. Main Function #include <iostream>#include "arrayListType.h"using namespace std; int main(){ arrayListType<int> list;int num;cout << "Line 8: Enter numbers ending with -999" << endl;cin >> num; while (num != -999){list.insert(num);cin >> num;} cout << "Line 15: The list before sorting:" << endl;list.print();cout << endl; list.selectionSort();cout << "Line 19: The list after sorting:" << endl;list.print();cout << endl; return 0;} Header File (arrayList.h) Including images #include <iostream>#include <cassert>…arrow_forwardAnswer and explain it whyarrow_forwardCan you help me solve this question with the code i have givenarrow_forward
- Please use java! Thanks :Darrow_forwardImplement a list of employees using a dynamic array of strings.Your solution should include functions for printing list, inserting and removingemployees, and sorting lists (use Bubble sort in C++ language).Keep list of employees sorted within the list after insertion.See the following example:How many employees do you expect to have?5 (Carriage Return)Menu :1 . Print full list of employees2 . Insert new employee3 . Remove employee from list0 . Exit2 (Carriage Return)Input name of new employee : MikeMenu :1 . Print full list of employees2 . Insert new employee3 . Remove employee from list0 . Exit1(Carriage Return)1 . MaryMenu :1 . Print full list of employees2 . Insert new employee3 . Remove employee from list0 . Exitarrow_forwardYou are going to implement a program that creates an unsorted list by using a linked list implemented by yourself. NOT allowed to use LinkedList class or any other classes that offers list functions. It is REQUIRED to use an ItemType class and a NodeType struct to solve this homework. The “data.txt” file has three lines of data 100, 110, 120, 130, 140, 150, 160 100, 130, 160 1@0, 2@3, 3@END You need to 1. create an empty unsorted list 2. add the numbers from the first line to list using putItem() function. Then print all the current keys to command line in one line using printAll(). 3. delete the numbers given by the second line in the list by using deleteItem() function. Then print all the current keys to command line in one line using printAll().. 4. putItem () the numbers in the third line of the data file to the corresponding location in the list. For example, 1@0 means adding number 1 at position 0 of the list. Then print all the current keys to command line in one…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