Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 Imagine we have a circular doubly - linked list with a sentinel node. The linked list node is a struct with three fields:
Question
Imagine we have a circular doublylinked list with a sentinel node. The linked list node is a struct with three fields: word, a string, and two pointers named forw and back. The CDList class has two data members: a pointer to the first node, named head, and a counter named cnt
Write a member function of the CDList class that checks if the list is a palindrome sentence. You may assume that all words are in lower case. See a calling statement below:
bool isPal list.checkPal;
For instance, the function returns true if the list contains:
SENTINEL, "king", "are", "you", "glad", "you", "are", "king".
Question
The purpose of the following algorithm is to display a queue:
loop que.isEmpty
item que.pop
print item
end loop
Now the queue is empty. The following algorithm intends to solve the "empty after printing the queue" problem, but it is incorrect. Why? How would you fix it
loop que.isEmpty
item que.pop
print item
que.pushitem
end loop
Question
What is wrong with the following recursive algorithm?
algorithm getScore
read score
if score score
printInstructions
getScore
end if
return score
end getScore
Question
A classmate wrote the following implementation of one of the stack functions and asks your opinionadvice about it What advice would you give to your classmate? Justify your answer. Hint: Are any advantagesdisadvantages compared to your implementation of the same function? Which one of the stack functions is guess?
template
bool Stack::guessT &item
StackNode temp;
if length
return false;
item topvalue;
temp topnext;
delete top;
top temp;
length;
return true;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started