Concept explainers
Explanation of Solution
Complete executable code:
Filename: “Node.java”
Refer “Node.java” from chapter 19 in the textbook
Filename: “Example1LinkedList.java”
//Define "Example1LinkedList" class
public class Example1LinkedList
{
//Define main function
public static void main(String[] args)
{
/* Create a linked list with two string values */
Node colorList = new Node("Yellow", new Node("Purple"));
/* Add a string value to the beginning of the list */
colorList = new Node("Brown", colorList);
/* Display a first string value of "colorList" linked list */
System.out.print(colorList.value);
/* Display a next string value of "colorList" linked list */
System.out.print(colorList.next.value);
/* Display a another next string value of "colorList" linked list */
System.out.print(colorList.next.next.value);
System.out...
Want to see the full answer?
Check out a sample textbook solutionChapter 19 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
- Programming Language: C++ Create a pseudocode (if you not familiar with this, you can create a program) that check if "directed graph" is actually circle graph. The meaning of circle is that let's say there is 1~6 nodes. The graph start with 1 and only can move to 2, and 2 can only move to 3....etc and after you hit 6, you move back to 1. so 1=>2=>3=>4=>5=>6=>1 this is example of circle directd graph. Please create a pseudocode/program to check if graph is circle or not. Also, include the time complexity of your pseudocode by [Worst case time complexity / Best case time complexity]arrow_forwardprivate OnlineStudent readOnlineStudent(Scanner pIn) { String id = pIn.next(); String lname = pIn.next(); String fname = pIn.next(); OnlineStudent student = new OnlineStudent(id, fname, lname); String fee = pIn.next(); int credits = pIn.nextInt(); if (fee.equals("T")) { student.setTechFee(true); else { student.setTechFee(false); } student.setCredits(credits); return student; keep getting class, interface,enum or record expected. I need helparrow_forwardthis is an android app with android studio . package com.example.myapplication;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import android.widget.ListView;public class PlayerActivity2 extends AppCompatActivity {ListView simpleList;String SerialNo[] = {"1", "2", "3", "4", "5", "6","7","8","9","10"};int flags[] = {R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4, R.drawable.image5, R.drawable.image6, R.drawable.image7, R.drawable.image8, R.drawable.image9, R.drawable.image10};String Names[] = {"mmm", "nnn", "aaa.", "bbb", "ccc", "ddd","eee jk"," ijk","Virgil jk","gil jklk"};String Score[] = {"1", "2","3", "5", "4", "3","5","5","5","5"};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity2);simpleList = (ListView)findViewById(R.id.simpleListView);//ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.activity_listview,…arrow_forward
- using namespace std; class SinglyLinkedListNode { // INSERT YOUR CODE HERE }; class SinglyLinkedList { public: SinglyLinkedListNode *head; SinglyLinkedListNode *tail; SinglyLinkedList() { this->head = nullptr; this->tail = nullptr; } voidinsert_node(intnode_data) { // INSERT YOUR CODE HERE } }; void free_singly_linked_list(SinglyLinkedListNode* node) { // INSERT YOUR CODE HERE } // Complete the has_cycle function below. /* * For your reference: * * SinglyLinkedListNode { * int data; * SinglyLinkedListNode* next; * }; * */ bool has_cycle(SinglyLinkedListNode* head) { SinglyLinkedListNode* temp = head; bool isCycle = false; while (temp != nullptr) { // INSERT YOUR CODE HERE } } int main() { // INSERT YOUR CODE HERE TO TEST YOUR CODE return0; }arrow_forwardusing namespace std; class SinglyLinkedListNode { // INSERT YOUR CODE HERE }; class SinglyLinkedList { public: SinglyLinkedListNode *head; SinglyLinkedListNode *tail; SinglyLinkedList() { this->head = nullptr; this->tail = nullptr; } voidinsert_node(intnode_data) { // INSERT YOUR CODE HERE } }; void free_singly_linked_list(SinglyLinkedListNode* node) { // INSERT YOUR CODE HERE } // Complete the has_cycle function below. /* * For your reference: * * SinglyLinkedListNode { * int data; * SinglyLinkedListNode* next; * }; * */ bool has_cycle(SinglyLinkedListNode* head) { SinglyLinkedListNode* temp = head; bool isCycle = false; while (temp != nullptr) { // INSERT YOUR CODE HERE } } int main() { // INSERT YOUR CODE HERE TO TEST YOUR CODE return0; }arrow_forwardLook at the code.arrow_forward
- public class DLList { public DLLNode front; public DLLNode back; public DLList(String name) { this.front = new DLLNode(); this.front.name = name; this.front.nextnode = null; this.front.prevnode = null; this.back = front; } public void addNode(DLLNode newNode) { newNode.nextnode = this.front; this.front.prevnode = newNode; this.front = newNode; } public void reverseListv1() { DLLNode current = this.back; //set iterator to the back node DLLNode prevBuffer = this.back.nextnode; //record (old) nextnode DLLNode prev; this.front = this.back; // set the list's "back" as the "front" while (current != null) { current.nextnode = current.prevnode; // set current node's nextnode as its previous prev = current; //record last node processed current = current.prevnode; //move iterator prev.prevnode = prevBuffer; //set last processed node's prevnode to its (old) nextnode prevBuffer = current; //record last processed node's (old) nextnode this.back = prev; // set the list's "back" point to…arrow_forward@return index of the point that is closest to the origin, which is (0, 0) * In case of a tie, return the lowest index */ public int closestToOriginIndex() { return 0; }arrow_forwardPls make the layout of the game! it is gui based! you do not neet to make the code all the way just what ever you can to get started! In java pls thank you!arrow_forward
- Java Given main(), complete the SongNode class to include the printSongInfo() method. Then write the Playlist class' printPlaylist() method to print all songs in the playlist. DO NOT print the dummy head node.arrow_forwardbool validPassword=true; cin >> passPhrase;} if (passPhrase.length() <= 4) { validPassword = false; } else { int digitCount=0; for (int i = 0; i < passPhrase.length(); i++) { if (isdigit(passPhrase.at(i))) digitCount++; } if (digitCount > 4) { validPassword=false; } if (validPassword) { cout << "Valid" << endl; } else { cout << "Invalid" << endl; } return 0;} // it still comes up with these errors. Not sure what it is telling me. main.cpp:9:7: error: expected unqualified-id before ‘if’ 9 | if (passPhrase.length() <= 4) { | ^~ main.cpp:13:7: error: expected unqualified-id before ‘else’ 13 | else { | ^~~~arrow_forwardclass DoublyLinkedList: def __init__(self): self.head = None def is_empty(self): if self.head == None: return True else: return False def enqueue_front(self, data): new_node = Node(data) new_node.next = self.head if self.head is not None: self.head.prev = new_node self.head = new_node def enqueue_rear(self, data): new_node = Node(data) new_node.next = None if self.head is None: new_node.prev = None self.head = new_node return last = self.head while(last.next is not None): last = last.next last.next = new_node new_node.prev = last return def peek(self): return self.head.data def dequeue_front(self): if self.head is None: return temp = self.head self.head = self.head.next self.head.prev = None return temp.data…arrow_forward
- 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