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 Note: if we use only inSort to add items to a list (dont use ins) then the list will be in increasing sorted order at all times */ *NOTE THAT THIS METHOD SHOULD NOT SORT THE LIST, RATHER WE ARE JUST INSORTING A NUMBER" LOOK AT EXAMPLE LISTS AND DESCRIPTION PLEASE AND THANK YOUI"

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

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

Note: if we use only inSort to add items to a list (dont use ins)
then the list will be in increasing sorted order at all times
*/

*NOTE THAT THIS METHOD SHOULD NOT SORT THE LIST, RATHER WE ARE JUST INSORTING A NUMBER" LOOK AT EXAMPLE LISTS AND DESCRIPTION PLEASE AND THANK YOUI"
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 7 images

Blurred answer
Knowledge Booster
Time complexity
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.
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education