LinkedLongest Editor 1 string longest(node* head) ill in code here Problem Statement 4 This problem provides you with a linked list composed of node objects chained together via node pointers. Each node has a next pointer which points to the next node in the chain. The last node is identified by having a NULL (or nullptr) next pointer. The linked lists for this problem store string data. Your task is simple identify the longest string stored in the linked list. If two strings are of the same length, return the string that occurred earlier in the linked list. If the linked list is empty, return the empty string Create a function longest, which takes in a pointer to the head of the linked list, and returns the longest string in the linked list The linked lists for this problem use the following class declaration (this is already available to the autograder code; do not copy this into your solution) class node public: string data; node* next; J: Notes and Constraints . The linked list starting at head contains between 0 and 10 nodes, inclusive Test Submit

Question

example:
"apple->orange->banana->pear"->NULL
return "orange"

Thanks!

LinkedLongest
Editor
1 string longest(node* head)
ill in code here
Problem Statement
4
This problem provides you with a linked list composed of node objects
chained together via node pointers. Each node has a next pointer which
points to the next node in the chain. The last node is identified by having
a NULL (or nullptr) next pointer.
The linked lists for this problem store string data. Your task is simple
identify the longest string stored in the linked list. If two strings are of the
same length, return the string that occurred earlier in the linked list. If
the linked list is empty, return the empty string
Create a function longest, which takes in a pointer to the head of the
linked list, and returns the longest string in the linked list
The linked lists for this problem use the following class declaration (this is
already available to the autograder code; do not copy this into your
solution)
class node
public:
string data;
node* next;
J:
Notes and Constraints
. The linked list starting at head contains between 0 and 10 nodes,
inclusive
Test
Submit
Expand
Transcribed Image Text

LinkedLongest Editor 1 string longest(node* head) ill in code here Problem Statement 4 This problem provides you with a linked list composed of node objects chained together via node pointers. Each node has a next pointer which points to the next node in the chain. The last node is identified by having a NULL (or nullptr) next pointer. The linked lists for this problem store string data. Your task is simple identify the longest string stored in the linked list. If two strings are of the same length, return the string that occurred earlier in the linked list. If the linked list is empty, return the empty string Create a function longest, which takes in a pointer to the head of the linked list, and returns the longest string in the linked list The linked lists for this problem use the following class declaration (this is already available to the autograder code; do not copy this into your solution) class node public: string data; node* next; J: Notes and Constraints . The linked list starting at head contains between 0 and 10 nodes, inclusive Test Submit

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Object Oriented Programming

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Transform the grammar with productions S → baAB, A → bAB|λ, B → BAa |A| λ into Chomsky normal form.

A: A context free grammar is in Chomsky normal form if its productions are in the formA → a or A → BC o...

Q: What is notepad ++ or notebad ? How to use it and what for ?It's required for my class The Web Stand...

A: We are explaining here the concept of notepad and notepad ++ and how and for what purpose these are ...

Q: How do I call a function in Python from another module without using import *?

A: Statement used to call a function in python from another module without using import * statement is ...

Q: how to write a function in python 3 that take a tuple t = (7,8,4,20,11) and returns a list which inc...

A: Note: The below program has been complied and executed in “repl.it” online complier

Q: I now must create a physical Entity Relationship diagram from this list table. While, I feel more co...

A: The table has 9 columns and they can be grouped roughly under 3 entities as follows:Project – Projec...

Q: What are the internal components of a computer that make it function?

A: A computer system consists of multiple hardware devices which, with the help of software, perform co...

Q: I am struggling on storing numbers from the getChoice () function into an array and pulling it back ...

A: Click to see the answer

Q: Programming in C.

A: Note: The below program has been complied and executed in "repl.it" online complier

Q: AskForNumbers Declare an integer array locally with the size of 200. Create a program that asks the ...

A: In order to implement the question mentions a method called getChoice() information about which has ...

Q: Eliminate useless productions from S → a |aA| B|C, A → aB|λ, B → Aa, C → cCD, D → ddd|Cd.

A: Identifying non-generating variables:

Q: Develop the ‘Shape’ application such that: Implement an array of objects of various types (all SIX ...

A: Program plan:Define a class called “ShapeTest”.Define a “main()” method.Create an array of six shape...

Q: Read in 5 numbers from the keyboard and, if any of the entered numbers is < 0, then print out “Ne...

A: Pseudo code is given below to read five numbers from the keyboard and print “Negative” if the number...

Q: For this program you need to use Eclipse. Carefully read the instructions and write a program that r...

A: The program has the following algorithm: Step 1: Create object for “Scanner” class to read the user ...

Q: I need help with understanding how to do the SQL code for the following question (attached is the CS...

A: As the table name is not shown in the picture, we are assuming the table name as Product. There are ...

Q: 11.7: Customer AccountsWrite a program that uses a structure to store the following data about a cus...

A: Program plan:Include the required header files.Define the structure “customerAccount”Declare the req...

Q: Which filenames would be a subsequent ls command display?$ lsabc abd abe abf abg abh$ rm abc ab*rm: ...

A: To describe which filenames the subsequent ls command display.

Q: Create a new file in c++.  In this lab, you will add some functionality to the table ofmenu. Your bo...

A: Program Instructions:Declare variables and write a welcome message.Always convert the user's choice ...

Q: Show that the following grammar is ambiguous: S→AB|aaaB,A→a|Aa,B→b.

A: A grammar is known as ambiguous when there is more than one derivation tree (right most derivation t...

Q: Write a GUI application that calculates a car’s gas mileage. The application should let the user ent...

A: Create the MPGCalculator class and declare the given fields along with two JPanel gallonsLabel and m...

Q: 5-1) (Count positive and negative numbers and compute the average of numbers) Write a program that r...

A: Java program to count posive and negative numbers and computing the total and average of numbers is ...

Q: Define a class called Player that implements Comparable <Player> with health and name attribut...

A: The question posed here is an extremely long and complex one, so we have judiciously attempted to pr...

Q: Try giving these 2 commands $ echo cat$ cat echoExplain the differences between the output of each c...

A: echo command:echo command is used to display the line of text passed as an argument. It is a built i...

Q: How do I get this flat list table into 1NF, 2NF and 3NF?

A: Normalization:Normalization is a process of dividing the tables by more than one idea into set of ta...

Q: What values will print? Use Eclipse to verify it but only after you write down youranswers based on ...

A: Description of the Java Math utilities used:-Math.sqrt() returns the square root of its paramter a d...

Q: how to write a function that takes an integer n and prints all of the integers between 1 and n which...

A: Since no programming language is specified we choose python as it is one of most popular programming...

Q: Note: Numbers greater then 3,999 require symbols with lines over letters. We can't use these, so use...

A: Note: The given python program has been compiled and executed in "repl.it" online complier.Screensho...

Q: I need help answering the following quetions I am not good with code. 1. Describe how you use TCP Du...

A: Use the keyword tcpdump with the TCP Dump flag –D.The flag –D will list all the interfaces that are ...

Q: How become a ggod programmer?

A: Good programmer:Becoming programmer is not a big thing; it is all about learning the logics of the p...

Q: Fill in the following table to show how the given integers are represented, assuming that 16 bits ar...

A: Convert the integer value to binary:For positive integer:Divide the integer number by 2. The integer...

Q: Analyze the following code: Code 1: int number = 45;boolean even; if (number % 2 == 0) even = true;e...

A: First lets discuss about the first question. 1) In the first code we are declaring two variables num...

Q: Use the worksheets to show, one path augmentation at a time, how to use the Ford-Fulkerson Algorithm...

A: For solving your problem first of all we define Ford-Fulkerson Algorithm.Ford-Fulkerson Algorithm fo...

Q: Find a regular grammar that generates the language L (aa∗ (ab + a)∗).

A: Solution: Given input,L(aa*(ab+a)*)Determine the regular grammar for L(aa*(ab+a)*):

Q: How would I write a C program to find the length of the longest substring of a given string without ...

A: The given program is to find the maximum length of the substring without repeating character. This i...

Q: Find an nfa that accepts the complement from L (ab∗aa + bba∗ab)?

A: Solution:The following graph indicates the NFA (Non-deterministic finite automata) is given below:M ...

Q: 2. What happens when you give the following commands if the file named done already exists?$ cp to_d...

A: The given two commands cp and mv are used in Linux and Unix. These commands are used for copying and...

Q: I have a HW that is asking me to draw on ERD diagram for a simple purchasing system that has order w...

A: ERD diagram for Purchasing System:The ERD diagram for the simple purchasing system is as follows:

Q: Convert the grammar S → aSb|Sab|ab into Chomsky normal form.

A: Solution:Chomsky Normal Form (CNF):The Chomsky normal form is a content-free grammar when each and e...

Q: steps to build up a new prodect brand?

A: Steps to build up a new product brand are as follows:

Q: I could use help with the following SQL questions (the fields ProductModelName, ProductCategory, Pro...

A: As the table name is not shown in the picture, we are assuming the table name as Product. There are ...

Q: Attached Files:  getRandomLib.h: // This library provides a few helpful functions to return rand...

A: Program Instructions:Include the necessary header files.Print hello message and as for a response.De...

Q: Show that there exists an algorithm to determine whether λ ∈ L for any regular language L.

A: DFA (Deterministic Finite Automation):For a given state on a given input, user reach to a determinis...

Q: (The Fan class) Design a class named Fan to represent a fan. The class contains:■ Three constants na...

A: Java program to create Fan class is as follows:

Q: 6. Write a class with a constructor that accepts a String object as its argument. The class should h...

A: Two java.util classes are used – Scanner and Arrays. Scanner is used to read input string and Arrays...

Q: Read in 5 letters from the keyboard, reverse the order of the second and next to last letters, and p...

A: Program to read 5 letters from the keyboards and reversing the order of the second and next to last ...

Q: How to use ProstgreSQL in my local Java IDE using SSH tunneling?

A: So here we have to do three things,1) first we need to create a SSH tunnel to the postgreSQL db but ...

Q: Create a list of 3 technologies that have gone from analog to digital. What was the reasoning for e...

A: Back in 1970s and earlier main technology in use was analog technology. Analog technology used vario...

Q: • Write a program in Eclipse that computes future investment value at a given interest rate for a sp...

A: Program plan:Import necessary packages.Define a class named “Investment”.Define a method named “comp...

Q: Please write Lisp code for the following problem. Write a function that computes the surface area of...

A: Instructions to create a function that computes the surface area of a cylinder:Define a function nam...

Q: How do I get values from a dictionary into a Python code when my values are in a .txt file?

A: Program instructions:Initialize a dictionary variable named "dictionary" and use open() function to ...

Q: How to implement a pluggable Adapter design pattern in Java?

A: Let’s say we have a client class called Client.java which calls method1( ) of an existing library cl...