1. In a Linked stack implemented using singly linked list with pointer top pointing to top of the stack, which of the following statements, correctly push a node into a non-empty stack? Assume temp is the node to be pushed. temp = top; top->next = temp; top->next = temp; temp = top %3D temp->next = top; top = temp top = temp; temp->next = top %3D

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 21SA
icon
Related questions
Question
1. In a Linked stack implemented using singly
linked list with pointer top pointing to top of
the stack, which of the following statements,
correctly push a node into a non-empty
stack? Assume temp is the node to be
pushed.
temp = top; top->next = temp;
%3!
top->next = temp; temp = top
%3D
temp->next = top; top = temp
%3D
%3D
top = temp; temp->next = top
2. You are given pointers to first and last nodes
of a singly linked list, which of the following
operations are dependent on the length of
the linked list?
O Insert a new element as a first element
Add a new element to the end of the list
Delete the first element
Delete the last element of the list
Transcribed Image Text:1. In a Linked stack implemented using singly linked list with pointer top pointing to top of the stack, which of the following statements, correctly push a node into a non-empty stack? Assume temp is the node to be pushed. temp = top; top->next = temp; %3! top->next = temp; temp = top %3D temp->next = top; top = temp %3D %3D top = temp; temp->next = top 2. You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list? O Insert a new element as a first element Add a new element to the end of the list Delete the first element Delete the last element of the list
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning