Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 19, Problem 2MC
Program Description Answer
The first element of a list in java is identified by “index 0”.
Hence, the correct answer is option “C”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Select all of the applicable choices. In which of the following situations is a vector more efficient than a list? O A program that needs to add a significant number of items to the container's beginning O A program that often accesses elements throughout the container O A program that adds a certain amount of elements and then repeatedly removes the initial element O A program that adds elements regularly, but only to the container's end
19Given that values is of type LLNode<Integer> and references a linked list (non-empty) of Integer objects, what does the following code do if invoked as mystery(values)?
int mystery(LLNode<Integer> list){ if (list.getLink() == null) return list.getInfo(); else return mystery(list.getLink());}
Group of answer choices
returns 0.
returns sum of the numbers on the values list.
returns how many numbers are on the values list.
returns the last number on the values list.
None of these is correct.
This is Java Programming
Linked List Basics ( insertFront, insertBack, deleteFront & deleteBack)Question: Given the following code in main and output, please write the Java program which allows main to work:
public static void main(String[] args) {LinkedList list = new LinkedList();
// Try to delete from an empty listlist.deleteFront();list.displayLL();list.deleteBack();list.displayLL();// insert 3 nodeslist.insert(18);list.insert(45);list.insert(12);list.displayLL();
// Here are the main “new” lines, not included in code I gave youlist.insertFront(1);list.displayLL();list.insertBack(999);list.displayLL();list.deleteFront();list.displayLL();list.deleteBack();list.displayLL();} // end of main
This is Java programming please
Chapter 19 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 19.1 - Prob. 19.1CPCh. 19.1 - Prob. 19.2CPCh. 19.3 - Prob. 19.4CPCh. 19 - A list is a collection that _____. a. associates...Ch. 19 - Prob. 2MCCh. 19 - Prob. 3MCCh. 19 - Prob. 4MCCh. 19 - Prob. 5MCCh. 19 - Prob. 6MCCh. 19 - Prob. 7MC
Ch. 19 - Prob. 11TFCh. 19 - Prob. 12TFCh. 19 - Prob. 13TFCh. 19 - Prob. 14TFCh. 19 - Prob. 15TFCh. 19 - Prob. 16TFCh. 19 - Prob. 17TFCh. 19 - Prob. 18TFCh. 19 - Prob. 19TFCh. 19 - Prob. 20TFCh. 19 - Prob. 1FTECh. 19 - Prob. 2FTECh. 19 - Prob. 3FTECh. 19 - Prob. 4FTECh. 19 - Prob. 5FTECh. 19 - Prob. 1AWCh. 19 - Prob. 2AWCh. 19 - Prob. 3AWCh. 19 - Prob. 4AWCh. 19 - Prob. 3SACh. 19 - Prob. 4SACh. 19 - Prob. 5SACh. 19 - Consult the online Java documentation and...Ch. 19 - Prob. 1PCCh. 19 - Prob. 2PC
Knowledge Booster
Similar questions
- 34Given that values is of type LLNode<Integer> and references a linked list (non-empty) of Integer objects, what does the following code do if invoked as mystery(values)? void mystery(LLNode<Integer> list){if (list != null){System.out.println(list.getInfo());mystery(list.getLink());}}Group of answer choicesprints the list from start to end.prints the first element on the list.prints the last element on the list.prints the list in reverse order.None of these is correct.arrow_forwardCreate a list of two vectors (dog, cat, mouse) and (True, True, False) called a.list. Name the vectors “animal” and “pet” respectively in your list. Access all the elements in the first vector of the list by name.arrow_forwardWhat is the functionality of the following piece of code? public int function(){Node temp = tail.getPrev();tail.setPrev(temp.getPrev());temp.getPrev().setNext(tail);size--;return temp.getItem();}a) Return the element at the tail of the list but do not remove itb) Return the element at the tail of the list and remove it from the listc) Return the last but one element from the list but do not remove itd) Return the last but one element at the tail of the list and remove it from the listarrow_forward
- A)Draw the linked node structure created by the following program and , B)List the output of program. struct node{ struct node *left; char letter; struct node *right; }; typedef struct node *NODEPTR; NODEPTR getnode(void); void displayList(NODEPTR); void main() { NODEPTR p , list , save; char one; p=getnode(); p->letter='A'; list=p; p->right=p; p->left=p; save=list; for(int i=2;i<8;i+=2) { one='A'+ i; p=getnode(); p->letter=one; p->left=save; save->right=p; save=p; printf("Letter= %c\n",p->letter); } list->left=save; save->right=list; list=p; displayList(list); } void displayList(NODEPTR head) {NODEPTR save; printf("\nLIST\n"); save=head; do {printf("%c ",save->letter); save=save->left; }while(save!=head); } NODEPTR getnode() { NODEPTR q; q = (NODEPTR) malloc(sizeof(struct node));…arrow_forwardSuppose, alist is a 2-dimensional list. Which of the following options gives you the last element of this list? Question options: a. alist[ len(alist) - 1, len(alist) - 1 ] b. alist[ len(alist), len(alist) ] c. alist[ len(alist) - 1]arrow_forwardUSING JAVA CODE: Given the following subjects: 1. Math 2. Science 3. English 4. History Make a singly linked list that will allow users to add and delete subjects.arrow_forward
- 1. What is lambda expression's return type? a. Stringb. Objectc. Functiond. void 2. Which method can randomly generate all elements in a list? a. randomize()b. rand()c. shuffle()d. reverse()e. swap()arrow_forwardA business that sells dog food keeps information about its dog food products in a linked list. The list is named dogFoodList. (This means dogFoodList points to the first node in the list.) A node in the list contains the name of the dog food (a String), a dog food ID (also a String) and the price (a double.) a.) Create a class for a node in the list. b.) Use this class to write pseudocode or Java for a public method that prints the name of all dog foods in the list where the price is more than $20.00.arrow_forward2. At the interactive prompt, define a list named L that contains four strings ornumbers (e.g., L=[0,1,2,3]).a. What happens when you try to index out of bounds (e.g., L[4])?b. What about slicing out of bounds (e.g., L[-1000:100])?c. Finally, how does Python handle it if you try to extract a sequence inreverse—with the lower bound greater than the higher bound (e.g.,L[3:1])? Hint: try assigning to this slice(L[3:1]=[‘?’]) and see where thevalue is putarrow_forward
- Choose all of the options that apply. In which of the following cases is it more efficient to use a vector rather than a list? O A program that frequently accesses elements throughout the container O A program that needs to add a large number of elements to the container's beginning O A program that adds a fixed number of elements and then removes the first element repeatedly O A program that frequently adds elements, but only to the container's endarrow_forwardC7 Write a program that will take an integer array(A) and an integer value(v)as input and do the following task - If the value is present in the list,delete all the elements present before the value- if The value is not present in the list, enqueue it after 1st even number.//Comment per condition Must and explained the enqueue and code part with screenshot.I will up vote your answer immediatly. Kindly provide correct answer.arrow_forwardIn pyton: In this lab, you will be building a software application that removes duplicate values from a list.The purpose of the assignment isto gain experience with user-defined functions, forloop and listmanipulation. Start Start of remove duplicate function (numbers: list of numbers) Initialize an empty list as new_list Loop over each of the number of the numbers list If number not in new_list Append number to new_list Return new_list End of remove duplicate functionStart main function Prompt user for list of numbers Call remove duplicate function Print the new list returned by the remove function End of main functionEndarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education