by using c++ & datastructure 1- Implement a class template Node that has the following declaration:template class Node { T info; Node* next; public: Node(T, Node* n=0); Node* getNext(); void setNext(Node* ); T getInfo (); void setInfo (T); }; 2- Create a class template SLL, which is a single linked list with the following declaration: template class SLL { Node *head, *tail; public: SLL(){head = tail = 0;} void addtoHead(T); void addtoTail(T); T removeFromHead(); T removeFromTail(); T getValueAtHead();//a function that returns the value at head without deleting it bool isEmpty(); void clear(); friend ostream& operator<<(ostream&, const SLL&); }; 3- Implement the class Template StackSLL which uses the linked list you created in part (2). The class should have the functions: push , pop , top, isEmpty, and clear. Each of the functions should use the available member functions of SLL. 4- Implement the class Template QueueSLL which uses the linked list you created in part (2). The class should have the functions: enqueue , dequeue , front, isEmpty, and clear. Each of the functions should use the available member functions of SLL. 5- Implement a function bool chkBalanced(string) that uses a stack to check if the brackets entered within an expression are balanced. The brackets handled should include { } ,< > , [ ], ( ). Example expressions: { ( ( x + y ) * 63 – a [ i+2 ] ) { } }. Output: Balanced Example expressions: { ( x + y ) * 63 – a [ i+2 ] ) { } }. Output: Imbalanced 6- Implement a function string convertToBinary(int) that uses a stack to convert a decimal number to a binary number returned as a bit string. Example input: 218. Output: 11011010 7- Implement a function string convertInfixToPostfix(string) that uses a stack to convert an infix mathematical expression to a postfix notation. Assume that only 1-digit integers are used within the expression. Example input: 6 * 3 + 8 / 2 . Output: 6 3 * 8 2 / + The algorithm to do such conversion is in Weiss book, Chapter 3: Infix to Postfix Conversion, page 108. 8- Implement a function int evaluatePostfix(string) that uses a stack to evaluate a postfix expression and return the value as an integer. Assume that only 1- digit integers are used within the expression. Example input: 6 3 * 8 2 / + . Output: 22
by using c++ & datastructure
1- Implement a class template Node that has the following declaration:template class Node { T info; Node* next; public: Node(T, Node* n=0); Node* getNext(); void setNext(Node* ); T getInfo (); void setInfo (T); };
2- Create a class template SLL, which is a single linked list with the following declaration: template class SLL { Node *head, *tail; public: SLL(){head = tail = 0;} void addtoHead(T); void addtoTail(T); T removeFromHead(); T removeFromTail(); T getValueAtHead();//a function that returns the value at head without deleting it bool isEmpty(); void clear(); friend ostream& operator<<(ostream&, const SLL&); };
3- Implement the class Template StackSLL which uses the linked list you created in part (2). The class should have the functions: push , pop , top, isEmpty, and clear. Each of the functions should use the available member functions of SLL.
4- Implement the class Template QueueSLL which uses the linked list you created in part (2). The class should have the functions: enqueue , dequeue , front, isEmpty, and clear. Each of the functions should use the available member functions of SLL.
5- Implement a function bool chkBalanced(string) that uses a stack to check if the brackets entered within an expression are balanced. The brackets handled should include { } ,< > , [ ], ( ). Example expressions: { ( ( x + y ) * 63 – a [ i+2 ] ) { } }. Output: Balanced Example expressions: { ( x + y ) * 63 – a [ i+2 ] ) { } }. Output: Imbalanced
6- Implement a function string convertToBinary(int) that uses a stack to convert a decimal number to a binary number returned as a bit string. Example input: 218. Output: 11011010
7- Implement a function string convertInfixToPostfix(string) that uses a stack to convert an infix mathematical expression to a postfix notation. Assume that only 1-digit integers are used within the expression. Example input: 6 * 3 + 8 / 2 . Output: 6 3 * 8 2 / + The
8- Implement a function int evaluatePostfix(string) that uses a stack to evaluate a postfix expression and return the value as an integer. Assume that only 1- digit integers are used within the expression. Example input: 6 3 * 8 2 / + . Output: 22
Step by step
Solved in 2 steps