Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 20, Problem 16TF
Program Description Answer
The index of an element to be removed from a list is same as the size of the list.
Hence, the given statement is “False”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Nearest smaller element
def nearest_smaller(items):
Given a list of integer items, create and return a new list of the same length but where each element has been replaced with the nearest element in the original list whose value is smaller. If no smaller elements exist because that element is the minimum of the original list, the element in the result list should remain as that same minimum element.If there exist smaller elements equidistant in both directions, you must resolve this by using the smaller of these two elements. This again makes the expected results unique for every possible value of items, which is necessary for the automated testing framework to work at all. Being permissive in what you accept while being restrictive in what you emit is a pretty good principle to follow in all walks of life, not just in programming.
items
Expected result
[42, 42, 42]
[42, 42, 42]
[42, 1, 17]
[1, 1, 1]
[42, 17, 1]
[17, 1, 1]
[6, 9, 3, 2]
[3, 3, 2, 2]
[5, 2, 10, 1, 13, 15,…
flip_matrix(mat:list)->list
You will be given a single parameter a 2D list (A list with lists within it) this will look like a 2D matrix when printed out, see examples below. Your job is to flip the matrix on its horizontal axis. In other words, flip the matrix horizontally so that the bottom is at top and the top is at the bottom. Return the flipped matrix.
To print the matrix to the console:
print('\n'.join([''.join(['{:4}'.format(item) for item in row]) for row in mat]))
Example:
Matrix:
W R I T X
H D R L G
L K F M V
G I S T C
W N M N F
Expected:
W N M N F
G I S T C
L K F M V
H D R L G
W R I T X
Matrix:
L C
S P
Expected:
S P
L C
Matrix:
A D J
A Q H
J C I
Expected:
J C I
A Q H
A D J
2.
ID: A
Name:
2. A list of numbers is considered increasing if each value after the first is greater than or equal to the preceding
value. The following procedure is intended to return true if numberList is increasing and return false
otherwise. Assume that numberList contains at least two elements.
Line 1:
PROCEDURE isIncreasing (numberList)
Line 2: {
Line 3:
count 2
Line 4:
REPEAT UNTIL(count > LENGTH(numberList))
Line 5:
Line 6:
IF(numberList[count] =.
YA198IC
Chapter 20 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 20.1 - Prob. 20.1CPCh. 20.1 - Prob. 20.2CPCh. 20.3 - Prob. 20.4CPCh. 20 - A list is a collection that _____. a. associates...Ch. 20 - Prob. 2MCCh. 20 - Prob. 3MCCh. 20 - Prob. 4MCCh. 20 - Prob. 5MCCh. 20 - Prob. 6MCCh. 20 - Prob. 7MC
Ch. 20 - Prob. 11TFCh. 20 - Prob. 12TFCh. 20 - Prob. 13TFCh. 20 - Prob. 14TFCh. 20 - Prob. 15TFCh. 20 - Prob. 16TFCh. 20 - Prob. 17TFCh. 20 - Prob. 18TFCh. 20 - Prob. 29TFCh. 20 - Prob. 20TFCh. 20 - Prob. 1FTECh. 20 - Prob. 2FTECh. 20 - Prob. 3FTECh. 20 - Prob. 4FTECh. 20 - Prob. 5FTECh. 20 - Prob. 1AWCh. 20 - Prob. 2AWCh. 20 - Prob. 3AWCh. 20 - Prob. 4AWCh. 20 - Prob. 3SACh. 20 - Prob. 4SACh. 20 - Prob. 5SACh. 20 - Consult the online Java documentation and...Ch. 20 - Prob. 1PCCh. 20 - Prob. 2PC
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
- True or False When you create a List object, you do not have to know the number of items that you intend to store in it.arrow_forwardpaython programing question Write a program that creates a list of N elements (Hint: use append() function), swaps the first and the last element and prints the list on the screen. N should be a dynamic number entered by the user. Sample output: How many numbers would you like to enter?: 5 Enter a number: 34 Enter a number: 67 Enter a number: 23 Enter a number: 90 Enter a number: 12 The list is: [12, 67,23, 90, 34]arrow_forwardNearest smaller element def nearest_smaller(items): Given a list of integer itema, create and return a new list of the same length but where each element has been replaced with the nearest element in the original list whose value is smaller. If no smaller elements exist because that element is the minimum of the original list, the element in the result list should remain as that same minimum element. If there exist smaller elements equidistant in both directions, you must resolve this by using the smaller of these two elements. This again makes the expected results unique for every possible value of items, which is necessary for the automated testing framework to work at all. Being permissive in what yvou accept while being restrictive in what you emit is a pretty good principle to follow in all walks of life, not just in programming. Expected result items [42, 42, 421 [42, 42, 42] [42, 1, 17] (1, 1, 1] [42, 17, 1] [17, 1, 1] [6, 9, 3, 2] [3, 3, 2, 2] [5, 2, 10, 1, 13, 15, 14, 5, 11,…arrow_forward
- java data structurearrow_forwardLottery number generator: Write a program that generates aseven-digit lottery number. The program should have a loopto generate seven random numbers, each in the range 0through 9 and assign each number to a list element.2. Write another loop to display the contents of the list.3. Tip: You will need to create/initialize your list before you canassign numbers to it.4. Use program 7-1 sales_list as an example. You will start witha seven-digit lottery number that contains all zeros. Then inyour loop, you will assign a random number instead ofgetting the data from the user.Turn in your program to the practice assignment link in coursecontent.arrow_forward++arrow_forward
- Assume that my_list references a list. Write a statement that converts it to a tuplearrow_forwardtails_same(number_list:list) -> bool This function should return true if the value at the beginning and the end of the list are equal. False otherwise. Example: number_list = [1, 239, 949, 0, 84, 0, 1] output: True number_list = [1, 239, 949, 0, 84, 0, 13] output: Falsearrow_forwardoperator is used to combine 2 or more lists.arrow_forward
- ID: A Name: Multiple Response Identify one or more choices that best complete the statement or answer the question. 10. The following code segment is intended to remove all duplicate elements in the list myList. The procedure does not work as intended. jt LENGTH(myList) REPEAT UNTIL(j = 1) %3D } IF(myList[j] = myList[j - 1]) %3D } REMOVE (myList, j) { j+j-1 { For which of the following contents of myList will the procedure NOT produce the intended results? a. [30, 30, 30, 10, 20, 20] b. [10, 10, 20, 20, 10, 10] c. [50, 50, 50, 50, 50, 50] d. [30, 50, 40, 10, 20, 40]arrow_forwardLab Goal : This lab was designed to teach you more about list processing and algorithms.Lab Description : Write a program that will search through a list to find the smallest number and the largest number. The program will return the average the largest and smallest numbers. You must combine variables, ifs, and a loop to create a working method. There will always be at least one item in the list.arrow_forwardLab Goal : This lab was designed to teach you more about list processing and algorithms.Lab Description : Write a program that will search a list to find the first odd number. If an odd number is found, then find the first even number following the odd number. Return the distance between the first odd number and the LAST even number. Return -1 if no odd numbers are found or there are no even numbers following an odd numberarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT