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
Expert Solution & Answer
Chapter 20, Problem 15TF
Program Description Answer
The index of an element to be added to a list is same as the size of the list.
Hence, the given statement is “True”.
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
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_forward++arrow_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
- tails_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_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_forwardSubject-Object oriented programing Write a program which:• creates a new Array List• adds 5 decimal numbers to it• prints the list to the screen In the same program, use a 'for' loop to print each element of the Array List to the screen.arrow_forward
- operator is used to combine 2 or more lists.arrow_forwardAssume that my_list references a list. Write a statement that converts it to a tuplearrow_forwardOdd Even Number Using List CLOSE START Tags: List iterator Write a java program that read list of integer numbers from input user. If the number is even add it into evenList. Otherwise add to odd List. At the end of the code, display the elements of the odd and even numbers list respectively with ascending order. Display your output in the following format: (): [Note: The code must use list and iterator] Input: 230-15 8 22-11 6-7 18 Output: Odd List (4): -15-11-73 Even List (6): 0 2 6 8 18 22arrow_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