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 24.3, Problem 24.3.3CP
Program Plan Intro
Array list:
- Array list are being implemented using an array.
- An array is a data structure that is of fixed size.
- Once array is created, its size cannot be changed.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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]
Question 6
The default capacity of ArrayList object is:
10
50
Capacity must be specified by the user.
100
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
Chapter 24 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 24.2 - Prob. 24.2.1CPCh. 24.2 - Prob. 24.2.2CPCh. 24.2 - Prob. 24.2.3CPCh. 24.2 - Prob. 24.2.4CPCh. 24.3 - What are the limitations of the array data type?Ch. 24.3 - Prob. 24.3.2CPCh. 24.3 - Prob. 24.3.3CPCh. 24.3 - What is wrong if lines 11 and 12 in Listing 24.2,...Ch. 24.3 - If you change the code in line 33 in Listing 24.2,...Ch. 24.3 - Prob. 24.3.6CP
Ch. 24.3 - Prob. 24.3.7CPCh. 24.4 - Prob. 24.4.1CPCh. 24.4 - Prob. 24.4.2CPCh. 24.4 - Prob. 24.4.3CPCh. 24.4 - Prob. 24.4.4CPCh. 24.4 - Prob. 24.4.5CPCh. 24.4 - Prob. 24.4.7CPCh. 24.4 - Prob. 24.4.8CPCh. 24.4 - Prob. 24.4.9CPCh. 24.4 - Prob. 24.4.10CPCh. 24.5 - Prob. 24.5.1CPCh. 24.5 - Prob. 24.5.2CPCh. 24.5 - Prob. 24.5.3CPCh. 24.6 - What is a priority queue?Ch. 24.6 - Prob. 24.6.2CPCh. 24.6 - Which of the following statements are wrong?...Ch. 24 - (Implement set operations in MyList) The...Ch. 24 - (Implement MyLinkedList) The implementations of...Ch. 24 - (Use the GenericStack class) Write a program that...Ch. 24 - Prob. 24.5PECh. 24 - Prob. 24.6PECh. 24 - (Fibonacci number iterator) Define an iterator...Ch. 24 - (Prime number iterator) Define an iterator class...
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
- Topic: Linked List SHOW THE OUTPUT ONLYarrow_forward3. 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. PROCEDURE isIncreasing(numberList) Tue 61 Line 1: Line 2: { Line 3: count 2 Line 4: REPEAT UNTIL(count > LENGTH(numberList)) Line 5: } IF(numberList[count] =. a. b. Lines 10 and 11 should be interchanged. d. In line 3, 2 should be changed to 1. 3.arrow_forwardWhat criteria should be used to evaluate an ArrayList's performance?arrow_forward
- ion C Lons Employee -id: int -name String - dob : Date -staff : ArrayList +setid(int): void +getld() : int +setName(String): void +setDob(Date) : void +getDob(): Date +addStaff(Employee) : void +getStaff() : ArrayListarrow_forwardList<String> name = new List<string> { "Jane", "Sue", "Annie" };name.Add("Lisa");MessageBox.Show(name.Count.ToString()); 3 4 5arrow_forwarddef small_index(items: list[int]) -> int:"""Return the index of the first integer in items that is less than its index,or -1 if no such integer exists in items.>>> small_index([2, 5, 7, 99, 6])-1>>> small_index([-5, 8, 9, 16])0>>> small_index([5, 8, 9, 0, 1, 3])3"""arrow_forward
- Part 1: Add the code of the ArrayListType to your code. Part 2: Create an Ordered_List class derived from the ArrayListType then add the following function to this class: Constructor to create an array of the size specified by the parameter size. The default array size is 20. Sorted Insert this function takes an integer values then add it to the list this function should check whether the value exist in the list or not. If it is already exist then it will not be inserted to the list, this function should keep the list ordered. Remove function to remove an item from the list. The function takes a single parameter that specifies the number to be removed. • Sequential Search a function to search the list for an integer if exist return its location otherwise return -1. This function specifies the number we are looking for as a parameter. Part 3: Implement the following non-member functions to deal with the Ordered List objects: Load file: this function should read a text file consist an…arrow_forwardPart 1: Add the code of the ArrayListType to your code. Part 2: Create an Ordered_List class derived from the ArrayListType then add the following function to this class: Constructor to create an array of the size specified by the parameter size. The default array size is 20. Sorted Insert this function takes an integer values then add it to the list this function should check whether the value exist in the list or not. If it is already exist then it will not be inserted to the list, this function should keep the list ordered. Remove function to remove an item from the list. The function takes a single parameter that specifies the number to be removed. • Sequential Search a function to search the list for an integer if exist return its location otherwise return -1. This function specifies the number we are looking for as a parameter. Part 3: Implement the following non-member functions to deal with the Ordered List objects: Load file: this function should read a text file consist an…arrow_forwardIf the following is a pointer based list, give the correct commands that change the list from BEFORE to AFTER. BEFORE Plane Bike Pickup Caddy Truck Motorbike Van Ship AFTER Plane Bike Caddy Truck Motorbike Van Scooter Ship Select one: A.insert (5, "Scooter"); delete ("Pickup") B.insert (6, "Scooter"); delete ("Pickup") C.delete ("Scooter"); insert(2, "Pickup") D.delete ("Pickup"); insert (6, "Scooter")arrow_forward
- Problem Attachedarrow_forwardQ: Convert this to sorted array #include<iostream> #include"Student.cpp" class StudentList { private: struct ListNode { Student astudent; ListNode *next; }; ListNode *head; public: StudentList(); ~StudentList(); int IsEmpty(); void Add(Student newstudent); void Remove(); void DisplayList(); }; StudentList::StudentList() { head=NULL; }; StudentList::~StudentList() { cout <<"\nDestructing the objects..\n"; while(IsEmpty()!=0) Remove(); if(IsEmpty()==0) cout <<"All students have been deleted from a list\n"; }; int StudentList::IsEmpty() { if(head==NULL) return 0; else return 1; }; void StudentList::Add(Student newstudent) { ListNode *newPtr=new ListNode; if(newPtr==NULL) cout <<"Cannot allocate memory"; else { newPtr->astudent=newstudent; newPtr->next=head; head=newPtr; } }; void StudentList::Remove() { if(IsEmpty()==0) cout <<"List empty on remove"; else { ListNode *temp=head;…arrow_forwardAn array's index type may be any form of data. Do you think this is true or not?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT