public boolean inSort ( double element ) ; /* A form of ins operations, but here we do not insert based on index; rather we look through the list and find the first place where there are two element values that "straddle" the element we are adding... meaning we find a spot in the list where one element is <= to the item we are adding, and the next element (next higher index) is > the one we are adding. The new element goes between these two. If the head element is > the one we are adding, then the new element goes at the head; if all elements in the list are <= the one we are adding, the new element goes at the end. return true if the add succeeds (it will almost always succeed); return false if for some reason the insert cannot happen (such as in Array Implementation, the array has no room for another element). If the list is empty, just insert the element into the list. Example: list is 3.1, 5.5, 18.2, 23.01 inSort(7.0) makes this list: 3.1, 5.5, 7.0, 18.2, 23.01 Example: list is 3.1, 5.5, 18.2, 23.01 inSort(1.5) makes this list: 1.5, 3.1, 5.5, 18.2, 23.01 Example: list is 3.1, 5.5, 18.2, 23.01 inSort(55.2) makes this list: 3.1, 5.5, 18.2, 23.01, 55.2 Also note the we do not assume the list is sorted when we start looking for a "straddle" so here is a strange (but correct) example Example: list is 1.2, 5.5, 17.03, 12.8, 6.6 inSort(19.0) makes this list: 1.2, 5.5, 17.03, 12.8, 6.6, 19.0
public boolean inSort ( double element ) ; /* A form of ins operations, but here we do not insert based on index; rather we look through the list and find the first place where there are two element values that "straddle" the element we are adding... meaning we find a spot in the list where one element is <= to the item we are adding, and the next element (next higher index) is > the one we are adding. The new element goes between these two. If the head element is > the one we are adding, then the new element goes at the head; if all elements in the list are <= the one we are adding, the new element goes at the end. return true if the add succeeds (it will almost always succeed); return false if for some reason the insert cannot happen (such as in Array Implementation, the array has no room for another element). If the list is empty, just insert the element into the list. Example: list is 3.1, 5.5, 18.2, 23.01 inSort(7.0) makes this list: 3.1, 5.5, 7.0, 18.2, 23.01 Example: list is 3.1, 5.5, 18.2, 23.01 inSort(1.5) makes this list: 1.5, 3.1, 5.5, 18.2, 23.01 Example: list is 3.1, 5.5, 18.2, 23.01 inSort(55.2) makes this list: 3.1, 5.5, 18.2, 23.01, 55.2 Also note the we do not assume the list is sorted when we start looking for a "straddle" so here is a strange (but correct) example Example: list is 1.2, 5.5, 17.03, 12.8, 6.6 inSort(19.0) makes this list: 1.2, 5.5, 17.03, 12.8, 6.6, 19.0
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Java language
all descriptions and class in pictures
solve this method
**************
public boolean inSort (double element) {
//your code here
}
please and thank you!!!!
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images
Recommended textbooks for you
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
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