Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Data Structure Visualization DSV Viva Stack Tree Graph Test Practice

Rating
-
Sold
-
Pages
21
Grade
A+
Uploaded on
30-05-2025
Written in
2024/2025

Data Structure Visualization DSV Viva Stack Tree Graph Test Practice

Institution
Module

Content preview

DSA Viva Stack Tree Graph Test Practice
2025-2026
1. Given the following sequence of letters and asterisks:

(a) Consider the stack data structure, supporting two operations push and pop, as discussed in
class. Suppose that for the above sequence, each letter (such as E) corresponds to a push of that
letter onto the stack and each asterisk (*) corresponds to a pop operation on the stack. Show the
sequence of values returned by the pop operations.



(b) Consider the queue data structure, supporting two operations insert and remove, as discussed
in class. Suppose that for the above sequence, each letter (such as E) corresponds to an insert of
that letter into the queue and each asterisk (*) corresponds to a remove operation on the queue.
Show the sequence of values returned by the remove operations.

Answer:
a).Answer for stack Output: SYEUQTSAONIE.
b).Answer for Queue Output: EASYQUESTION

2. Suppose you were asked to write a method that will take two sorted stacks A and B (min on top)
and create one stack that is sorted (min on top). You are allowed to use only the stack operations
such as pop, push, size and top. No other data structure such as arrays are not allowed. You are
allowed to use stacks. Note that elements on the stack can be compared using compareTo.

Public Stack mergeSortedStacks(Stack A, Stack B)
{
…...
}
Answer:

,3. Evaluate the postfix expression: 10 5 + 60 6 / * 8 -

, Answer :142

4. Write a recursive delete method for singly-linked lists with integer data that deletes the
first occurrence of a given integer from the list and returns the resulting list.
class ListNode
{
private int value; //data value
Public ListNode next; //next element of list, or null if last
public ListNode(int v)
{
value = v;
}
public int value()
{
return value;
}
}

Answer :
static ListNode delete(int i, ListNode s)
{
if (s == null)
return s;
if (s.value() == i)
return s.next;
s.next = delete(i, s.next);
return s;
}

5. If the sequence of operations - push (1), push (2), pop, push (1), push (2), pop, pop, pop, push
(2), pop are performed on a stack, then what will be the sequence of popped out values?

Answer:




Question 6 :-Suppose you want to get from s to t on weighted graph G with
nonnegative edge weights, but you would like to stop by u if it isn’t too
inconvenient. (Here too inconvenient means that it increases the length of

Written for

Institution
Module

Document information

Uploaded on
May 30, 2025
Number of pages
21
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

£10.53
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Exammate Indiana University Of Pennsylvania
Follow You need to be logged in order to follow users or courses
Sold
62
Member since
4 year
Number of followers
8
Documents
3200
Last sold
1 week ago
The plug

You cannot simultaneously prevent and prepare for war. Albert Einstein We'd love to hear how satisfied you are with your order. Please take a moment to leave a review, Thank you.

2.7

10 reviews

5
1
4
2
3
3
2
1
1
3

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions