100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Computer Science: Data Structures and Algorithms Questions and Answers $12.49   Add to cart

Exam (elaborations)

Computer Science: Data Structures and Algorithms Questions and Answers

 2 views  0 purchase
  • Course
  • Computer Science: Data Structures and Algorithms
  • Institution
  • Computer Science: Data Structures And Algorithms

Computer Science: Data Structures and Algorithms Doubly Linked List: advantage, disadvantage - Answer- Advantage: quick insert to beginning, quick removal from end Disadvantage: slow search, not great for indexing Data Structures: Discuss characteristics of a Dictionary - Answer- Use when...

[Show more]

Preview 2 out of 15  pages

  • August 18, 2024
  • 15
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Computer Science: Data Structures and Algorithms
  • Computer Science: Data Structures and Algorithms
avatar-seller
Freshy
Computer Science: Data Structures
and Algorithms
Doubly Linked List: advantage, disadvantage - Answer- Advantage: quick insert to
beginning, quick removal from end

Disadvantage: slow search, not great for indexing

Data Structures: Discuss characteristics of a Dictionary - Answer- Use when: order is
unimportant, frequently adding and removing items, frequently looking up items

Why is looking up, adding, and removing elements from a dictionary or hash map an
O(1) operation? - Answer- Hash maps are built upon arrays: keys entered into a
dictionary/hash map are hashed first to find where the key/value pair should be
stored. This position is unique and can be used for fast lookups, as well as insertions
and deletions.

When searching in a regular list, Python iterates over the list to see if a given value
is in the list -- this is an O(n) operation. When looking to see if a value is in a hash
table, Python hashes the value that's sought and can go immediately to that position
in the array to see if there is a value there. That process of hashing and indexing is
an O(1) operation.

Similarly, as every item in a hash map has a unique position, adding or inserting
items does not require that eery other item shift index position; an items' position is
not dependent on other items in the array.

Explain why removing elements from or adding elements to an arbitrary location in a
Python list are O(n) operations. - Answer- Python lists are contiguous in memory.
When an item is removed or added to the middle of a list, all the subsequent items in
the list must be shifted either up or down by one position

What's the runtime for Bubble Sort? - Answer- O(n^2) (very bad);
best case O(n)

What's the runtime for Quick Sort? - Answer- O(n log n) (okay);
worst case O(n^2)

What's the runtime for Merge Sort? - Answer- O(n log n) (okay)
particularly good when number of items being sorted increases

What's the runtime for Insertion Sort? - Answer- O(n^2) (very bad);
best case O(n).
Its good when the number of items being sorted is small, but as N grows, runtime
slows dramatically.

What's the runtime for TimSort? - Answer- O(n) (fair);
worst case O(n log n) (okay)

, What's the runtime for Heap Sort? - Answer- O(n log n) (okay)

What's the runtime for Selection Sort? - Answer- O (n^2) (very bad)

What's the runtime for Tree Sort? - Answer- O(n log n) (okay);

What's the runtime for Shell Sort? - Answer- O(n log n) (okay);

What's the runtime for Bucket Sort? - Answer- Ω(n+k) (very good; close to O(log n)
or O(1)

What's the runtime for Radix Sort? - Answer- Ω(n+k) (very good; close to O(log n) or
O(1)

What's the runtime for Counting Sort? - Answer- Ω(n+k) (very good; close to O(log n)
or O(1)

What's the runtime for Cube Sort? - Answer- O(n)

6. What is the difference between a tree and a graph? - Answer- A tree is a restricted
kind of graph where there are no loops or cycles.

(Might require pen/paper)
Using the Python implementation of Quick Sort from the instructions:

Given the list [8, 4, 1, 6, 5, 2, 7, 3]:
When this function is initially called, what is the value of list? - Answer- [8, 4, 1, 6, 5,
2, 7, 3]

(Might require pen/paper)
Using the Python implementation of Quick Sort from the instructions:

Given the list [8, 4, 1, 6, 5, 2, 7, 3]:
When this function is initially called, what is the value of pivot? - Answer- 5

(Might require pen/paper)
Using the Python implementation of Quick Sort from the instructions:

Given the list [8, 4, 1, 6, 5, 2, 7, 3]:
When this function is initially called, what is the value of low? - Answer- [ 4, 1, 2, 3 ]

(Might require pen/paper)
Using the Python implementation of Quick Sort from the instructions:

Given the list [8, 4, 1, 6, 5, 2, 7, 3]:
When this function is initially called, what is the value of high? - Answer- [8, 6, 7]

Top 3 characteristics of Lists - Answer- Iterable,
Ordered,

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

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

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

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 Freshy. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

77988 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$12.49
  • (0)
  Add to cart