• 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 9 pages
Exam (elaborations)

CMSC 132 Exam 2 review (All Solved Correctly 100%)

Document preview thumbnail
Preview 2 out of 9 pages

When implementing a linked list class, the inner class representing the nodes serves as a __________ around a piece of _________ and a reference to another node. correct answers wrapper, data What does an empty linked list look like? correct answers head --- null Use a for loop to traverse through a linked list. correct answers for(NodeT curr = head; curr != null; curr = ){ } What is something important to think about when writing methods for a linked list implementation? correct answers Ask yourself what these methods will do if the linked list is empty. (T/F) It is better to use == over .equals() when comparing data from a linked list. correct answers FALSE. Use the .equals() method Random access (retrieve element at specified index) What will the runtimes be for an array vs linked list? correct answers - Arrays are better, for this example they would have a O(1) runtime. - A linked list would run in O(n) even for the best case. Binary search What will the runtimes be for an array vs linked list? correct answers - Arrays are better, they have fast random access. It would have a runtime of O(log n). - A linked list would be very bad for the binary search algorithm, there is no random access so starting from the middle of the list to search for the element is not an intelligent approach. The runtime would be O(n*log n). Insert at tail What will the runtimes be for an array vs linked list? correct answers - For arrays it would be O(n), unless you did a trick where you multiplied the size of your array by a constant when you want to add something beyond the size of the original array, in that case you could say 'in aggregate the operation could be as fast as O(1). - Linked list is better. If your linked list is maintaining a tail reference and you want to add a number to the end of the list, all you do is wrap it in a node and make tail equal to the node. If this is the case, the runtime is O(1).


Document information

Uploaded on
September 21, 2023
Number of pages
9
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers
$11.09

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.
SirAnton
3.7
(118)
Sold
807
Followers
438
Items
40070
Last sold
2 weeks 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

Whoops! We can’t load your doc right now. Try again or contact support.