CSE 1322 - Programming
Problem Solving IIwith
complete verified
solutions(graded A+)
A stack is a data structure where we add elements on the top and
remove the element, which has been added first. - answer False
The stack provides 3 major operations: push (add an element at the
top of the stack), pop (take the last added element from the top of
the stack) and peek (get the element from the top of the stack
without removing it). - answer True
The "queue" data structure is created to model queues, for example
a queue of waiting for printing documents. Such queues are very
convenient and are naturally modeled via the structure "queue". In
queues we can add elements only on the back and retrieve elements
only at the front. - answer True
Yes. We can add the element into queue at front and remove the
element from queue at back.
Two of the basic operations of a queue are Push and Dequeue. -
answer False
Two of the basic operations of a queue is Enqueue and Dequeue
Suppose, there is a 5-element queue Q (from front to back: 1, 2, 3,
4, 5, 6), and an empty stack S. If you remove the elements one-by-
one from the queue Q and insert them into the stack S, then remove
,them one-by-one from the stack S and re-insert them into the queue
Q. Then, finally how the queue will looks like (from back to front)? -
answer 1, 2, 3, 4, 5, 6
**NOT**
6, 5, 4, 3, 2, 1
Which one of the following is an application of Queue Data
Structure? - answer When data is transferred asynchronously (data
not necessarily received at same rate as sent) between two
processes
When a resource is shared among multiple consumers
Load Balancing
**All of the above
Stack is a restrictive data type in a sense that we cannot - answer
remove from the bottom
How would you access elements of an aggregated object (such as a
collection) sequentially without exposing the underlying structure of
the object? - answer Using an iterator
The main intent of an iterator is to access the elements of an
aggregate object sequentially without exposing its underlying
representation.
Stacks and queues are typically implemented internally as an array
or a linked list. - answer True
,Consider the situation where no other data structure like arrays,
linked list is available to you. Then how many stacks are needed to
implement a queue. - answer 2
Frequently inserting and removing items from a collection
(especially a large number of items), can lead to low performance.
In such cases it is advisable to use linked lists. - answer True
In a singly-linked list the elements keep information about their
next element. - answer True
In a doubly-linked lists each element contains its value and two
pointers - to the previous and to the next element. - answer True
The LinkedLIst<T> class is a dynamic implementation of a doubly-
linked list. Its elements contain a certain value and only one pointer
which points to the next element. - answer False
In the worst case, what is the number of comparisons needed to
search a singly-linked list of length n for a given element? - answer
n
Use of an ArrayList is preferred when we have to add / remove
elements dynamically. - answer True
What does the following recursive function do for a given Linked
List with first node as head?
void myFunc(Node head)
{
if(head == NULL)
return;
myFunc(head.next);
, print(head.data + " ");
} - answer Displays all nodes of linked list in reverse order
Which of the following points is/are true about Array List data
structure when it is compared with array? - answer **(Wrong
answer)
Array List has better cache locality that can make them better in
terms of performance
Which of the following sorting algorithms can be used to sort a
random linked list with minimum time complexity? - answer Merge
Sort
In general, a singly-linked list allows: - answer Insertions and
removals anywhere
Which of the following statements is NOT true for a thread? -
answer Every runnable process contains at least two threads
In a multithreaded program many threads run concurrently within a
single program/process. - answer True
The main() method always has a thread that can create additional
threads - answer True
A thread is an incomplete program - answer False
A process contains only one path of execution called a thread -
answer False
Which of the following is not a valid state of Thread Life Cycle? -
answer New State
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller BRAINBOOSTERS. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $15.49. You're not tied to anything after your purchase.