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)

CS101 EXAM 2 QUESTIONS AND ANSWERS

Rating
-
Sold
-
Pages
7
Uploaded on
04-01-2025
Written in
2024/2025

CS101 EXAM 2 QUESTIONS AND ANSWERS...

Institution
CS101
Course
CS101

Content preview

Singly Linked List runtimes for:
insertFront, insertBack, removeFront, removeBack - ANSWER insertFront: 1
insertBack: N
removeFront: 1
removeBack: N

Types of Linked Lists: - ANSWER 1. Singly-linked list
2. Doubly-linked list
3. Circular linked list

Describe a singly-linked list. - ANSWER Each node has a next pointer, but no
previous pointer.

Describe a doubly-linked list. - ANSWER Each node has a next pointer and a
previous pointer.

What is a circularly-linked list? - ANSWER A list that wraps around to the
front. The tail pointer points to the head.

Singly Linked List WITH TAIL runtimes for:
insertFront, insertBack, removeFront, removeBack - ANSWER insertFront: 1
insertBack: 1
removeFront: 1
removeBack: N

Doubly Linked List WITH TAIL runtimes for:
insertFront, insertBack, removeFront, removeBack - ANSWER insertFront: 1
insertBack: 1
removeFront: 1
removeBack: 1
same as DLL circular

, Doubly Linked List CIRCULAR runtimes for:
insertFront, insertBack, removeFront, removeBack - ANSWER insertFront: 1
insertBack: 1
removeFront: 1
removeBack: 1
same as DLL with tail

Even though the worst case in this Amortized Analysis is log(n), the average is -
ANSWER O(1).

Dynamic Array Runtimes B/W/A for: insertFront, insertBack, removeFront,
removeBack - ANSWER insertFront: N/N/N
insertBack: N/1/1
removeFront: N/N/N
removeBack: N/1/1

In a pop-push stack, what is the rule? - ANSWER Last-in, first-out.

Cons of a stack (or queue) for a linked list - ANSWER POP takes longer for a
linked list.

Cons of a stack (or queue) for an array - ANSWER Size limit and chance for
wasted space.

Pros of a stack (or queue) for an array (as apposed to a linked list) - ANSWER
Arrays allocate all at once, so they are faster. Arrays also take up less memory
(linked list has to track data AND pointer).

In a queue, what is the rule? - ANSWER First-in, first-out

What does enqueue(x) do? - ANSWER insert back

What does dequeue() do? - ANSWER removes front

What does peek() do? - ANSWER views front

What are the two options for making a queue? - ANSWER Circular array or
singly-linked list.

Written for

Institution
CS101
Course
CS101

Document information

Uploaded on
January 4, 2025
Number of pages
7
Written in
2024/2025
Type
Exam (elaborations)
Contains
Unknown

Subjects

$12.99
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


Also available in package deal

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.
Boostertips Chamberlain College Nursing
Follow You need to be logged in order to follow users or courses
Sold
265
Member since
3 year
Number of followers
195
Documents
5175
Last sold
2 weeks ago

3.8

44 reviews

5
19
4
8
3
10
2
2
1
5

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 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