Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a sentence stored as a singly linked list, where each node consists of a word (of type string). Eg, the sentence How are you

image text in transcribed

Consider a sentence stored as a singly linked list, where each node consists of a word (of type string). Eg, the sentence "How are you" is stored in three linked list nodes, each containing the words "How, are and "you". Node containing "How" is the head of the linked list with next pointing to the node containing "are" and so on. Node containing "you" is the tail node. 1. Write a pseudocode using recursion to reverse such a sentence word by word. E.., if the input sentence is "A quick brown fox jumps over the lazy dog", the output needs to be "dog lazy the over jumps fox brown quick A". Put your pseudocode, including all your sources, in a file called recursiveReversewords.pdf. You cannot make the linked list doubly linked. 2. Implement your pseudocode. You are provided a file called recursiveReversewords.cpp with a main function and the function declaration. Do not change the function declaration. The input parameter and return types must be as specified. You will need to include your implementation in this file. The main function includes some test cases. In a separate file called LinkedList.h, you will find the template declaration for a linked list with the basic functionalities implemented. For bonus points, implement a function that checks if the element you insert into the linked list is a word (ie., does not contain special characters or white spaces) Consider a sentence stored as a singly linked list, where each node consists of a word (of type string). Eg, the sentence "How are you" is stored in three linked list nodes, each containing the words "How, are and "you". Node containing "How" is the head of the linked list with next pointing to the node containing "are" and so on. Node containing "you" is the tail node. 1. Write a pseudocode using recursion to reverse such a sentence word by word. E.., if the input sentence is "A quick brown fox jumps over the lazy dog", the output needs to be "dog lazy the over jumps fox brown quick A". Put your pseudocode, including all your sources, in a file called recursiveReversewords.pdf. You cannot make the linked list doubly linked. 2. Implement your pseudocode. You are provided a file called recursiveReversewords.cpp with a main function and the function declaration. Do not change the function declaration. The input parameter and return types must be as specified. You will need to include your implementation in this file. The main function includes some test cases. In a separate file called LinkedList.h, you will find the template declaration for a linked list with the basic functionalities implemented. For bonus points, implement a function that checks if the element you insert into the linked list is a word (ie., does not contain special characters or white spaces)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How flying airoplane?

Answered: 1 week ago