This is python programming. Please answer the questions based on python programming.
1.Answer “True/False” for the following statements
(4 points each):
a. The Stack follows the LILO principle.
b. The Queue follows the FIFO principle
c. The Deque follows the FILO principle.
d. The Stack needs two references to achieve a worst case complexity of O(1).
e. The Queue needs two references to achieve a worst case complexity of O(1).
f. The Stacks always adds a node to the top.
g. The Queue always adds a node to the top.
h. The Deque only adds to one place in the structure.
i. The Deque can remove any node in the structure, the first, last or any middle node.
j. The Deque is considered a hybrid of the stack.
2. Demonstrate the following operations on an empty stack. DO NOT simply show the final stack diagram, show what the stack looks like after each operation.
a. Push(20)
b. Push(30)
c.Pop()
d.Push(20)
e.Push(30)
f.Push(1)
g.Push(5)
h.Pop()
i.Push(8)
j. Push(16)
1. (a) False
The Stack follows the LIFO principle.
stack = ["Amit", "Deepak", "Divya"]
stack.append("Mahesh")
stack.append("Suresh")
print(stack)
print(stack.pop())
print(stack)
print(stack.pop())
print(stack)
Output:
['Amit', 'Deepak', 'Divya', 'Mahesh', 'Suresh'] Suresh ['Amit', 'Deepak', 'Divya', 'Mahesh' ] Mahesh [ 'Amit', 'Deepak', 'Divya' ]
(b)True
Yes,The Queue follows the FIFO principle
(c)False
Deque stands for double ended queue . Deques are generalization of stack(FILO) and queue(FIFO).
(f)True
The Stacks always adds a node to the top.
(g) False
(h)
This is python programming. Please answer the questions based on python programming. 1.Answer “True/False” for the...
2. Consider a circular array based Queue as we have discussed in the lectures (class definition given below for reference) public class CircArrayQueue<E> implements Queue<E private EI Q private int front-0 indicates front of queue l indicates position after end of queue private int end-0: public CircArrayQueue( public int getSize (.. public boolean isEmpty ( public void enqueue (E e)... public E dequeue ) throws EmptyQueueException... Il constructor We are interested in implementing a Stack class based on the above...
Python coding conceptual questions - Conceptual Questions Suppose you are given a (strange) computer that can only perform the following instructions (in addition to if and while): S-create_stack() create stack makes a new stack s iS.pop() removes the top item from stack s and places it in variable i .S.push (i) makes item i the top item in stack s Solve the following problems and justify your answers: 1. (10 pts) Show how you can use these operations to implement...
Please, answer the three questions. Many thanks 1 Question Which of the following methods does a stack not support? Not yet answered Points out of Select one 1.00 O a. push P Flag question O b. top O C. pop O d. pu 2 Drag and drop an appropriate item (stack, queue, or adapter) into each Question Not yet answered description below. Points out of 3.00 is a container where objects are inserted and removed according to P Flag question...
help me answer the following questions please 1. Stack (LIFO) & its application 1. Stack overflow & underflow 2. Implementation: partially filled array & linked list 3. Applications: reverse string, backtracking Exercises: 1) Which of the following applications may use a stack? A. parentheses balancing program. B. Keeping track of local variables at run time. C. Syntax analyzer for a compiler. D. All of the above. 2) Consider the usual algorithm for determining whether a sequence of parentheses is balanced....
11.2 Problem Set 2: PostScript Stack Commands (in python please) For this assignment you are to implement a PostScript command interpreter using a Stack. You must implement the stack using a singly-linked list. Solutions that use a data structure other than a singly-linked list will received no credit. The interpreter must read and execute a string of PostScript commands based on the following definitions: 1. = objn objn-1 … obj1 = : objn-1 … obj1 This command removes the topmost...
Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your own Array-Based Stack (ABS) and Array-Based Queue (ABQ). A stack is a linear data structure which follows the Last-In, First-Out (LIFO) property. LIFO means that the data most recently added is the first data to be removed. (Imagine a stack of books, or a stack of papers on a desk—the first one to be removed is the last one placed on top.) A queue...
Can you please help with the below? 1) Which of the following is true about using a 2-3-4 tree? a. It is designed to minimize node visits while keeping to an O(log n) search performance b. It is designed to self-balance as new values are inserted into the tree c. As soon as a node becomes full, it performs the split routine d. None of the above 2) Which of the following is true about a binary search tree? a. ...
JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...
Please Write Pseudocode or Python code! Thanks! P1. b) is the following: W1. (6 marks) Write the pseudocode for removing and returning only the second element from the Stack. The top element of the Stack will remain the top element after this operation. You may assume that the Stack contains at least two items before this operation. (a) Write the algorithm as a provider implementing a Stack using a contiguous memory implementation. You can refer to the implementation given in...
can anyone provide answers with explaination ? thanks a lot I. In the example of recycling the elements of a list in O1) time, which situation holds? A. Both lists are circular B. Both ists are not circular C. The list to be recycled is circular, the garbage list is not D. The garbage list is circular, the list to be recycled is not 2. What is the worst-case time to perform MINIMUML) for a sorted, doubly-linked list with nodes?...