{ "key_pair_value_system": true, "answer_rating_count": "", "question_feedback_html": { "html_star": "", "html_star_feedback": "" }, "answer_average_rating_value": "", "answer_date_js": "2024-09-12T00:05:12-04:00", "answer_date": "2024-09-12 00:05:12", "is_docs_available": "", "is_excel_available": "", "is_pdf_available": "", "count_file_available": 0, "main_page": "student_question_view", "question_id": "10326222", "url": "\/study-help\/questions\/implement-each-of-the-functions-to-perform-the-necessary-actions-10326222", "question_creation_date_js": "2024-09-12T00:05:12-04:00", "question_creation_date": "Sep 12, 2024 12:05 AM", "meta_title": "[Solved] Implement each of the functions to perfor | SolutionInn", "meta_description": "Answer of - Implement each of the functions to perform the necessary actions outlined in the `.h` files or here. Implement the lin | SolutionInn", "meta_keywords": "implement,functions,perform,necessary,actions,outlined,h,files,linked,list,test,functionality", "question_title_h1": "Implement each of the functions to perform the necessary actions outlined in the `.h` files or here. Implement the linked list and test the functionality", "question_title": "Implement each of the functions to perform the necessary actions outlined in", "question_title_for_js_snippet": "Implement each of the functions to perform the necessary actions outlined in the h files or here Implement the linked list and test the functionality of it using tests As you are writing your functions, read the instructions and think of how you would test that functions while you are writing it Write your Test first and then implement your functions Try running your test and then fixing your issues EXPRESSIONSTREAM is given in the end QUEUE H ifndef CMPE126S18 LABS LIB LAB05 INC QUEUE H define CMPE126S18 LABS LIB LAB05 INC QUEUE H include linked list h namespace lab5 class queue private linked list storage structure public queue() queue(std string data) queue(const queue original) virtual queue() queue operator (const queue RHS) bool isEmpty() const unsigned queueSize() const std string top() const void enqueue(const std string data) void dequeue() friend std ostream operator (std istream stream, queue RHS) endif QUEUE CPP namespace lab5 queue queue() queue queue(std string data) queue queue(const queue original) queue queue() queue queue operator (const queue RHS) bool queue isEmpty() const return false unsigned queue queueSize() const return 0 std string queue top() const void queue enqueue(const std string data) void queue dequeue() std ostream operator (std istream stream, queue RHS) return stream STACK H ifndef CMPE126S18 LABS LIB LAB05 INC STACK H define CMPE126S18 LABS LIB LAB05 INC STACK H include linked list h namespace lab5 class stack private linked list storage structure public stack() stack(std string data) stack(const stack original) virtual stack() stack operator (const stack RHS) bool isEmpty() const unsigned queueSize() const std string top() const void push(const std string data) void pop() friend std ostream operator (std istream stream, stack RHS) endif STACK CPP include stack h namespace lab5 stack stack() stack stack(std string data) stack stack(const stack original) stack stack() stack stack operator (const stack RHS) bool stack isEmpty() const return false unsigned stack queueSize() const return 0 std string stack top() const void stack push(const std string data) void stack pop() std ostream operator (std istream stream, stack RHS) return stream LINKED LIST H ifndef CMPE126S18 LABS LIB LAB05 INC LINKED LIST H define CMPE126S18 LABS LIB LAB05 INC LINKED LIST H include node h include namespace lab5 class linked list node head, tail public linked list() explicit linked list(std string data) linked list(const linked list original) virtual linked list() linked list operator (const linked list RHS) friend std ostream operator (std istream stream, linked list RHS) bool isEmpty() const unsigned listSize() const std string get value at(unsigned location) void insert(const std string input, unsigned location 0 ) void append(const std string input) void remove(unsigned location 0) void sort() endif LINKED LIST CPP include namespace lab5 linked list linked list() linked list linked list(std string data) linked list linked list(const linked list original) linked list linked list() linked list lab5 linked list operator (const linked list RHS) bool linked list isEmpty() const return false unsigned linked list listSize() const return 0 Note that you do not have a size variable in your linked list You MUST count the nodes void linked list insert(const std string input, unsigned int location) create a node from the input string and put it into the linked list at the given location node prev node current node temp new node (input) current head void linked list append(const std string input) create a new node and put it at the end tail of the linked list void linked list remove(unsigned location) Remove the node at the given location std ostream operator (std istream stream, linked list RHS) return stream void linked list sort() Perform selection sort on the linked list std string linked list get value at(unsigned location) NODE H ifndef CMPE126S18 LABS LIB LAB5 NODE H define CMPE126S18 LABS LIB LAB5 NODE H include namespace lab5 class node public node next std string data explicit node(const std string data) data(data), next(nullptr) endif FANCYCALCULATOR H ifndef CMPE126S18 LABS LAB5 CALCULATOR H define CMPE126S18 LABS LAB5 CALCULATOR H include stack h include queue h include expressionstream h include namespace lab5 class calculator lab5 queue infix expression lab5 queue postfix expression void parse to infix(std string input expression) PRIVATE function used for converting input string into infix notation void convert to postfix(lab5 queue infix expression) PRIVATE function used for converting infix FIFO to postfix public calculator() Default constructor calculator(std string input expression) Constructor that converts input expression to infix and postfix upon creation friend std istream operator (std istream stream, calculator RHS) Store the infix and postfix expression in calculator int calculate() Return the calculation of the postfix expression friend std ostream operator (std istream stream, calculator RHS) return stream int calculator calculate() return 0 std ostream operator '0' c", "question_description": "

Implement each of the functions to perform the necessary actions outlined in the `.h` files or here. Implement the linked list and test the functionality of it using tests. <\/p>

As you are writing your functions, read the instructions and think of how you would test that functions while you are writing it. Write your Test first and then implement your functions. Try running your test and then fixing your issues. <\/p>

EXPRESSIONSTREAM is given in the end.<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

QUEUE.H<\/p>

<\/p>

#ifndef CMPE126S18_LABS_LIB_LAB05_INC_QUEUE_H<\/p>

#define CMPE126S18_LABS_LIB_LAB05_INC_QUEUE_H<\/p>

#include \"linked_list.h\"<\/p>

namespace lab5 {<\/p>

class queue {<\/p>

private:<\/p>

linked_list storage_structure;<\/p>

<\/p>

public:<\/p>

queue();<\/p>

queue(std::string &data);<\/p>

queue(const queue &original);<\/p>

virtual ~queue();<\/p>

queue &operator=(const queue &RHS);<\/p>

bool isEmpty() const;<\/p>

unsigned queueSize() const;<\/p>

std::string top() const;<\/p>

void enqueue(const std::string &data);<\/p>

void dequeue();<\/p>

friend std::ostream& operator<<(std::ostream& stream, queue& RHS);<\/p>

friend std::istream& operator>>(std::istream& stream, queue& RHS);<\/p>

};<\/p>

}<\/p>

#endif<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

QUEUE.CPP<\/p>

<\/p>

namespace lab5{<\/p>

queue::queue() { }<\/p>

queue::queue(std::string &data) { }<\/p>

queue::queue(const queue &original) { }<\/p>

queue::~queue() { }<\/p>

queue &queue::operator=(const queue &RHS) { }<\/p>

bool queue::isEmpty() const { return false; }<\/p>

unsigned queue::queueSize() const { return 0; }<\/p>

std::string queue::top() const { }<\/p>

void queue::enqueue(const std::string &data) { }<\/p>

void queue::dequeue() { }<\/p>

std::ostream& operator<<(std::ostream &stream, queue &RHS) { return stream; }<\/p>

std::istream& operator>>(std::istream &stream, queue &RHS) { return stream; }<\/p>

}<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

STACK.H<\/p>

<\/p>

#ifndef CMPE126S18_LABS_LIB_LAB05_INC_STACK_H<\/p>

#define CMPE126S18_LABS_LIB_LAB05_INC_STACK_H<\/p>

<\/p>

#include \"linked_list.h\"<\/p>

namespace lab5 {<\/p>

class stack {<\/p>

private:<\/p>

linked_list storage_structure;<\/p>

public:<\/p>

stack();<\/p>

stack(std::string &data);<\/p>

stack(const stack &original);<\/p>

virtual ~stack();<\/p>

stack &operator=(const stack &RHS);<\/p>

bool isEmpty() const;<\/p>

unsigned queueSize() const;<\/p>

std::string top() const;<\/p>

void push(const std::string &data);<\/p>

void pop();<\/p>

friend std::ostream& operator<<(std::ostream& stream, stack& RHS);<\/p>

friend std::istream& operator>>(std::istream& stream, stack& RHS);<\/p>

};<\/p>

}<\/p>

#endif<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

STACK.CPP<\/p>

<\/p>

#include \"stack.h\"<\/p>

namespace lab5{<\/p>

stack::stack() { }<\/p>

stack::stack(std::string &data) { }<\/p>

stack::stack(const stack &original) { }<\/p>

stack::~stack() { }<\/p>

stack &stack::operator=(const stack &RHS) { }<\/p>

bool stack::isEmpty() const { return false; }<\/p>

unsigned stack::queueSize() const { return 0; }<\/p>

std::string stack::top() const { }<\/p>

void stack::push(const std::string &data) { }<\/p>

void stack::pop() { }<\/p>

std::ostream& operator<<(std::ostream &stream, stack &RHS) { return stream; }<\/p>

std::istream& operator>>(std::istream &stream, stack &RHS) { return stream; }<\/p>

}<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

LINKED_LIST.H<\/p>

<\/p>

#ifndef CMPE126S18_LABS_LIB_LAB05_INC_LINKED_LIST_H<\/p>

#define CMPE126S18_LABS_LIB_LAB05_INC_LINKED_LIST_H<\/p>

<\/p>

#include \"node.h\"<\/p>

#include <\/p>

<\/p>

namespace lab5 {<\/p>

class linked_list {<\/p>

node *head, *tail;<\/p>

public:<\/p>

linked_list();<\/p>

explicit linked_list(std::string &data);<\/p>

linked_list(const linked_list &original);<\/p>

virtual ~linked_list();<\/p>

linked_list &operator=(const linked_list &RHS);<\/p>

friend std::ostream& operator<<(std::ostream& stream, linked_list& RHS);<\/p>

friend std::istream& operator>>(std::istream& stream, linked_list& RHS);<\/p>

bool isEmpty() const;<\/p>

unsigned listSize() const;<\/p>

std::string get_value_at(unsigned location);<\/p>

void insert(const std::string input, unsigned location = 0 );<\/p>

void append(const std::string input);<\/p>

void remove(unsigned location = 0);<\/p>

void sort();<\/p>

};<\/p>

}<\/p>

#endif<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

LINKED_LIST.CPP<\/p>

<\/p>

#include <\/p>

namespace lab5 {<\/p>

linked_list::linked_list() { }<\/p>

linked_list::linked_list(std::string &data) { }<\/p>

linked_list::linked_list(const linked_list &original) { }<\/p>

linked_list::~linked_list() { }<\/p>

linked_list &lab5::linked_list::operator=(const linked_list &RHS) { }<\/p>

bool linked_list::isEmpty() const { return false; }<\/p>

unsigned linked_list::listSize() const { return 0; } \/\/Note that you do **not** have a size variable in your linked list. You *MUST* count the nodes.<\/p>

void linked_list::insert(const std::string input, unsigned int location) { \/\/create a node from the input string and put it into the linked list at the given location<\/p>

node *prev; node *current; node *temp = new node (input); current = head; }<\/p>

void linked_list::append(const std::string input) { } \/\/create a new node and put it at the end\/tail of the linked list<\/p>

void linked_list::remove(unsigned location) { } \/\/Remove the node at the given location<\/p>

std::ostream& operator<<(std::ostream &stream, linked_list &RHS) { return stream; }<\/p>

std::istream& operator>>(std::istream &stream, linked_list &RHS) { return stream; }<\/p>

void linked_list::sort() { } \/\/Perform selection sort on the linked list<\/p>

std::string linked_list::get_value_at(unsigned location) { }<\/p>

}<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

NODE.H<\/p>

<\/p>

#ifndef CMPE126S18_LABS_LIB_LAB5_NODE_H<\/p>

#define CMPE126S18_LABS_LIB_LAB5_NODE_H<\/p>

#include <\/p>

<\/p>

namespace lab5 {<\/p>

class node {<\/p>

public:<\/p>

node *next;<\/p>

std::string data;<\/p>

<\/p>

explicit node(const std::string &data) : data(data), next(nullptr){};<\/p>

};<\/p>

}<\/p>

#endif<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

FANCYCALCULATOR.H<\/p>

<\/p>

#ifndef CMPE126S18_LABS_LAB5_CALCULATOR_H<\/p>

#define CMPE126S18_LABS_LAB5_CALCULATOR_H<\/p>

<\/p>

#include \"stack.h\"<\/p>

#include \"queue.h\"<\/p>

#include \"expressionstream.h\"<\/p>

#include <\/p>

<\/p>

namespace lab5{<\/p>

class calculator{<\/p>

lab5::queue infix_expression;<\/p>

lab5::queue postfix_expression;<\/p>

<\/p>

void parse_to_infix(std::string &input_expression); \/\/PRIVATE function used for converting input string into infix notation<\/p>

void convert_to_postfix(lab5::queue infix_expression); \/\/PRIVATE function used for converting infix FIFO to postfix<\/p>

public:<\/p>

calculator(); \/\/Default constructor<\/p>

calculator(std::string &input_expression); \/\/ Constructor that converts input_expression to infix and postfix upon creation<\/p>

friend std::istream& operator>>(std::istream& stream, calculator& RHS); \/\/Store the infix and postfix expression in calculator<\/p>

<\/p>

int calculate(); \/\/Return the calculation of the postfix expression<\/p>

friend std::ostream& operator<<(std::ostream& stream, calculator& RHS); \/\/Stream out overload. Should return in the format \"Infix: #,#,#,# Postfix: #,#,#,#\"<\/p>

};<\/p>

}<\/p>

#endif<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

FANCYCALCULATOR.CPP<\/p>

<\/p>

#include \"fancy_calculator.h\"<\/p>

#include \"stack.h\"<\/p>

#include \"queue.h\"<\/p>

<\/p>

namespace lab5{<\/p>

void calculator::parse_to_infix(std::string &input_expression) { }<\/p>

void calculator::convert_to_postfix(lab5::queue infix_expression) { }<\/p>

calculator::calculator() { }<\/p>

calculator::calculator(std::string &input_expression) { }<\/p>

std::istream &operator>>(std::istream &stream, calculator &RHS) { return stream; }<\/p>

int calculator::calculate() { return 0; }<\/p>

std::ostream &operator<<(std::ostream &stream, calculator &RHS) { return stream; }<\/p>

bool is_number(std::string input_string);<\/p>

bool is_operator(std::string input_string);<\/p>

int get_number(std::string input_string);<\/p>

std::string get_operator(std::string input_string);<\/p>

int operator_priority(std::string operator_in);<\/p>

}<\/p>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<\/p>

EXPRESSIONSTREAM.CPP \/\/THIS IS ALREADY DONE.<\/p>

<\/p>

#include \"expressionstream.h\"<\/p>

<\/p>

namespace lab1 {<\/p>

bool is_number(char c);<\/p>

expressionstream::expressionstream(const std::string &string_in) : buffer(string_in) {<\/p>

current_pos = buffer.begin();<\/p>

next_position = current_pos;<\/p>

skip_white_space();<\/p>

}<\/p>

<\/p>

void expressionstream::skip_white_space() {<\/p>

while (*current_pos == ' ' && current_pos != buffer.end()) ++current_pos;<\/p>

while (*next_position == ' ' && next_position != buffer.end()) ++next_position;<\/p>

}<\/p>

<\/p>

std::string expressionstream::get_number() {<\/p>

bool is_negative = false;<\/p>

std::string::iterator number_start;<\/p>

<\/p>

\/\/check if the number is negative, this is used to skip any white space after '-'<\/p>

if (*current_pos == '-') is_negative = true;<\/p>

<\/p>

\/\/find beginning of number<\/p>

number_start = current_pos;<\/p>

while (number_start != buffer.end() && !is_number(*number_start))++number_start;<\/p>

<\/p>

\/\/find ending of number<\/p>

next_position = number_start;<\/p>

while (next_position != buffer.end() && is_number(*next_position))++next_position;<\/p>

<\/p>

\/\/create and return number using position iterators<\/p>

return (is_negative) ? '-' + std::string(number_start, next_position) : std::string(number_start,<\/p>

next_position);<\/p>

<\/p>

}<\/p>

<\/p>

bool expressionstream::is_negative() {<\/p>

\/\/after finding a '-' check if it is minus or negative by checking previous character<\/p>

<\/p>

\/\/create an iterator to the previous character<\/p>

std::string::iterator negative_check = next_position - 1;<\/p>

<\/p>

\/\/move backward until reach non-whitespace<\/p>

while (negative_check != buffer.begin() && *negative_check == ' ') --negative_check;<\/p>

<\/p>

\/\/if the previous character is not a number and not a close parenthesis the number is negative<\/p>

\/\/EXAMPLE: the following should get negatives on the 13's but not the 5's : \"-13-(-13-(5--13)-5)--13\"<\/p>

return (!is_number(*negative_check) && *negative_check != ')');<\/p>

}<\/p>

<\/p>

std::string expressionstream::get_next_token() {<\/p>

\/\/move the current_position iterator forward then get the \"current\" token<\/p>

current_pos = next_position;<\/p>

return get_current_token();<\/p>

}<\/p>

<\/p>

std::string expressionstream::get_current_token() {<\/p>

skip_white_space();<\/p>

<\/p>

\/\/check for end of buffer<\/p>

if (current_pos == buffer.end()) return \"\\0\";<\/p>

<\/p>

\/\/reset next position each time current token is called<\/p>

\/\/this should stop the 'next_position' from drifting on<\/p>

\/\/consecutive \"get_current_token()\" calls<\/p>

next_position = current_pos;<\/p>

<\/p>

if (next_token_is_int())<\/p>

return get_number();<\/p>

<\/p>

\/\/if token is not a number then it is one character long<\/p>

\/\/setting the 'next_position' iterator forward one will<\/p>

\/\/return one character<\/p>

++next_position;<\/p>

return std::string(current_pos, next_position);<\/p>

}<\/p>

<\/p>

bool expressionstream::next_token_is_int() {<\/p>

skip_white_space();<\/p>

if (is_number(*next_position))<\/p>

return true;<\/p>

if (*next_position != '-')<\/p>

return false;<\/p>

return is_negative();<\/p>

}<\/p>

<\/p>

bool expressionstream::next_token_is_op() {<\/p>

skip_white_space();<\/p>

if (next_token_is_int()) return false;<\/p>

return (*next_position == '+' || *next_position == '-' || *next_position == '*' || *next_position == '\/');<\/p>

}<\/p>

<\/p>

bool expressionstream::next_token_is_paren_open() {<\/p>

skip_white_space();<\/p>

return *next_position == '(';<\/p>

}<\/p>

<\/p>

bool expressionstream::next_token_is_paren_close() {<\/p>

skip_white_space();<\/p>

return *next_position == ')';<\/p>

}<\/p>

<\/p>

bool is_number(char c) {<\/p>

return (c >= '0' && c <= '9');<\/p>

}<\/p>

}<\/p>", "transcribed_text": "", "related_book": { "title": null, "isbn": null, "edition": null, "authors": null, "cover_image": null, "uri": null, "see_more_uri": "" }, "free_related_book": { "isbn": "", "uri": "", "name": "", "edition": "" }, "question_posted": "2024-09-12 00:05:12", "see_more_questions_link": "\/study-help\/questions\/computer-science-operating-system-2022-August-09", "step_by_step_answer": "The Answer is in the image, click to view ...", "students_also_viewed": [ { "url": "\/study-help\/technical-communication\/3-study-the-excerpt-from-this-micron-data-flyer-2012-1997675", "description": "3. Study the excerpt from this Micron data flyer (2012, p. 1). Describe the designers use of alignment as a design principle. How effective is it? How would you modify it? Present your analysis and...", "stars": 0 }, { "url": "\/the-fleek-corporation-has-5-warehouses-designated-ae-from-which", "description": "The Fleek Corporation has 5 warehouses designated A-E from which they supply 6 customers numbered 1-6.The table below gives the shipping cost in dollars per ton from each warehouse to each customer...", "stars": 3 }, { "url": "\/study-help\/questions\/implement-each-of-the-functions-to-perform-the-necessary-actions-10326222", "description": "Implement each of the functions to perform the necessary actions outlined in the `.h` files or here. Implement the linked list and test the functionality of it using tests. As you are writing your...", "stars": 3 }, { "url": "\/study-help\/questions\/question-4-1-point-a-firm-produced-a-net-income-5796402", "description": "Question 4 (1 point) A firm produced a net income of $16,800. The firm had $50,000 in liabilities and displayed $79,100 in total assets. Furthermore, the firm produced EBIT of $34,500. What is the...", "stars": 3 }, { "url": "\/study-help\/questions\/an-automobile-manufacturer-based-in-lexington-kentucky-wants-to-move-4943820", "description": "An automobile manufacturer based in Lexington, Kentucky, wants to move production jobs from Japan to Mexico so that it can be more responsive to changing demands in its North American markets. Which...", "stars": 3 }, { "url": "\/study-help\/questions\/two-weeks-after-they-were-told-about-the-citys-proposal-5447444", "description": "Two weeks after they were told about the city's proposal to demolish the neighborhood playground and build a parking lot, Diana approached Tony as they were heading to another neighborhood...", "stars": 3 }, { "url": "\/study-help\/questions\/3-test-to-see-if-there-is-a-significant-difference-3502876", "description": "#3. Test to see if there is a significant difference between the age of the participant and the age of the partner. Use a paired-sample t-test and an alpha level of 1%. How would you interpret the...", "stars": 3 }, { "url": "\/study-help\/questions\/in-the-document-the-irish-building-regulations-tgd-part-l-1002963", "description": "In the document the Irish Building Regulations TGD Part L What limitations does the document have", "stars": 3 }, { "url": "\/study-help\/questions\/dont-copy-paste-previous-answers-i-am-already-report-that-1005086", "description": "don't copy paste previous answers i am already report that answers Noah and Kelly know that small businesses need to have a presence on the web to attract customers. However, they are not sure how...", "stars": 3 } ], "next_back_navigation": { "previous": "\/study-help\/questions\/mercer-asbestos-removal-company-removes-potentially-toxic-asbestos-insulation-and-10326221", "next": "\/study-help\/questions\/which-point-should-be-analyzed-in-return-on-invested-capital-10326223" }, "breadcrumbs": [ { "name": "Study help", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers" }, { "name": "Computer Science", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers\/computer-science" }, { "name": "Databases", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/computer-science-databases" }, { "name": "Implement each of the functions to perform the necessary actions outlined in", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/implement-each-of-the-functions-to-perform-the-necessary-actions-10326222" } ], "skill_details": { "skill_id": "656", "skill_name": "Databases", "parent_id": "8" } } }