• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 7 pages
Exam (elaborations)

DSA 1 Quiz 2 Retake Questions and Answers Graded A+

Document preview thumbnail
Preview 2 out of 7 pages

Exam of 7 pages for the course DSA at DSA (DSA 1 Quiz 2 Retake)

Content preview

DSA 1 Quiz 2 Retake

A class defined as abstract must also have abstract methods - answerfalse

Insertion sort is an example of an Abstract Data Type - answerfalse

The Java Collections Framework contains both interfaces and abstract classes. What is
the main difference between these two things?
I. Interfaces are one way Java uses to implement multiple inheritance.
II. Abstract classes describe what something is. Interfaces describe what something can
do.
III. A class can only inherit from one superclass but can implement many different
interfaces - answerI, II, and III

The Comparator interface requires that one method be implemented to allow total
ordering of a collection: sort() - answerFalse

Both .equals() and .compare() are methods inherited from the super class Object -
answerFalse

Suppose we have a vector whose initial capacity is 7 (and initial size 0). Also suppose
that this vector doubles in size any time we try to insert an element that no longer has
space to be inserted. If we start with a size of 0 and insert 25 elements, how many times
will the vector resize? - answer2

Which of the following statements about vectors is not true - answerUnlike insert,
removing from the front of the vector is very fast, because we don't need to shift
elements

Which of the following statements will compile without errors?
I. List<String> myList = new vector<String>();
II. List<Integer> myList2 = new ArrayList < >();
III. Vector<Double> myList3 = new List<Double>();
IV. List<Double> myList4 = New Vector<Integer>(); - answerI and II

If you remove an element from an ArrayList object, the capacity automatically
decreases - answerfalse

Assume a singly linked list implemented using a Node class with two fields data (int)
and nextNode (node). A List class holds the field head (first node in the list). The linked
list contains six nodes holding 20, 11, 13, 19, 12, 14 in that order. What is the result to
the linked list of the following instructions?

, Node newNode = new Node();
newNode.data = 99;
newNode.nextNode = head.nextNode.nextNode;
head.nextNode.nextNode = newNoe - answerThe value 99 is inserted into the linked list
after 13 and before 19???

Assume a singly linked list implemented using a Node class with two fields data (int)
and nextNode (node). A List class holds the field head (first node in the list).
What is the value of nextNode in the last node of the list? - answernull

consider the following code:
public class ListNode {
public int data;
public ListNode next;
}
public class List{
// method of list class
public void Strip(ListNode p){
// precondition: p references the first node of a nonempty list
while(p!=null){
while((p.next!=null)**(p.next.data == p.data))
p.next = p.next.next;
p = p.next
}
}
}

Suppose that L represents the following list:
..... - answerJust know its like 5 2 1 I think

Assume a singly linked list implemented using a Node class with two fields data (int)
and nextNode (node). A List class holds the field head (first node in the list). The linked
list contains six nodes holding 20, 11, 13, 19, 12, 14 in that order. What will the
statement head.nextNode.nextNode.nextNode = null; accomplish? - answerIt will result
in the list ending after 19

Assume a singly linked list implemented using a Node class with two fields data (int)
and nextNode (node). A List class holds the field head (first node in the list). The linked
list contains six nodes holding 20, 11, 13, 19, 12, 14 in that order. What will be returned
by return head.nextNode.nextNode.nextNode.data? - answer19

When a list is copied to a stack (front to back of list) then the stack is copied back to
another list (using insertAtFront()), how do the two lists' orders compare? - answerThey
are the same order because of the insertAtFront()

Document information

Uploaded on
August 29, 2024
Number of pages
7
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.99

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

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.
Dreamer252
4.0
(117)
Sold
497
Followers
297
Items
21575
Last sold
1 month ago




Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right 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 aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions