Assignment Problem Statement 1. Write an algorithm to insert and remove a node in the middle of the singly linked list with a suitable example. [2 marks] 2. Write an algorithm to insert and remove a node from the middle of the circular linked list with a suitable example. [2 marks] 3. Evaluate the following postfix expressions and write out a corresponding infix expression. a) 12-32^3*6/+ b) 1234^*+ c) 2324*+* d) 25^1- 4. Convert infix to postfix expression a) A+B*C/D-F+A^E b) A+(B^*C-((D)/(E^F))^G)^H 5. Write an algorithm to insert and delete an element from the queue with an example.
Added by Kelly N.
Close
Step 1
Once the middle node is found, we can insert the new node after the middle node. Step 2: For removing a node from the middle of a singly linked list, we also need to traverse the list to find the middle node. Once the middle node is found, we can remove it by Show more…
Show all steps
Your feedback will help us improve your experience
Madhur L and 94 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Problem 1 (15 points): You can evaluate a postfix expression by using a stack for storing the operands and applying the following algorithm: - Scan the expression from left to right. - For each symbol in the expression, perform the following actions: If the symbol is Operand: push it onto the stack If the symbol is Operator: pop an operand from the stack (this will be the second operator, as it has been pushed last); pop another operand from the stack (this will be the first operand) perform the operation and push the result back onto the operand stack. Using this algorithm, evaluate the following postfix expression: 8 7 3 - / 2 * Show the content of the stack at each step (number the steps). Problem 2 (15 points): Convert the following infix expression to a postfix expression by using a stack and applying the rules below: a – ( d + b * a ) / c
Madhur L.
Which one of the following is an invalid postfix expression? a. -p+qee b. abc+d- c. p+qe d. abc*+d-x
C++ full code!! Use the DynintStack class to help reverse a linked list. Write a function that has a linked list head as an input parameter. The function returns a new linked list which has the reverse order of the input list. Given a string that has more than one type of delimiter of brackets. For example, a string may have braces ), parentheses ( ), and brackets [ ]. Determine if the input string is valid. Valid means: Open parenthesis must be closed with the same type of parenthesis. Open parenthesis must be closed in the correct order. Example: s = "() 1" True s = "() []{}" True s = "[J 1" False Hint: Use a stack to help solve the problem Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. For example: The sliding window size is 3. Input integers are [1, 10, 3, 5] Outputs are [0, 1.0, 5.5, 4.6667, 6.0] Hint: Use a queue to help solve the problem. Given two queues with their standard operations (enqueue, dequeue, isEmpty, size), implement a stack with its standard operations (pop, push, isEmpty, size).
Akash M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD