100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSE 2050 Final Exam Questions with 100% Actual correct answers | verified | latest update | Graded A+ | Already Passed | Complete Solution $7.99   Add to cart

Exam (elaborations)

CSE 2050 Final Exam Questions with 100% Actual correct answers | verified | latest update | Graded A+ | Already Passed | Complete Solution

 5 views  0 purchase
  • Course
  • Institution

CSE 2050 Final Exam Questions with 100% Actual correct answers | verified | latest update | Graded A+ | Already Passed | Complete Solution

Preview 2 out of 6  pages

  • June 24, 2024
  • 6
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
avatar-seller
CSE 2050 Final Exam
Consider a binary tree with height k and n nodes. What is the maximum number of
leaves in the tree? - ANS-2^k

How many iterator objects are created by the following code snippet:
L = ["a", "b", "c", "d"]
for i in L:
print("hello")
for j in L:
print("goodbye") - ANS-5 iterator objects

Give the nodes visited in the correct order by the following traversal generator in a BST
Node class, originally called with the root (e.g. root.traversal()):

def traversal(self): if self.left is not None: yield from self.left if self.right is not None: yield
from self.right yield self - ANS-1,3,5,4,7,6,2

Which of the following is most likely the correct put method for a BSTNode class? -
ANS-def put(self, key, value):
if key == self.key: self.value = value

elif key > self.key:
if self.left is not None:
self.right.put(key, value)

else:
self.right = BSTNode(key, value)

elif key < self.key:
if self.right is not None:
self.left.put(key, value)

else:
self.left = BSTNode(key, value)

Consider a binary search tree with n nodes. What is the asymptotic worst-case running
time of one rotate operation for a given node in the tree? - ANS-O(1)

, Consider the following BST. How many nodes are in the subtree rooted at node 3 after
rotating node 3 left? Include node 3 in this count - your answer should be at least 1. -
ANS-1

Which of the following problems would best be solved with a priority queue? -
ANS-Calling passengers to board an airplane in order of status (e.g. first-class, then
preferred, then economy)

Consider a priority queue implemented with an unsorted list data structure and the
following initialization:
class UnsortedListPQ:
def __init__(self):
self._entries = [] - ANS-def remove_min(self):
entry = min(self._entries)
self._entries.remove(entry)
return entry

Give the nodes in order for the list representation of the following heap: -
ANS-[1,4,7,6,5]

Consider the heap represented by the following list:

self._L = [a,b,c,d,e,f,g]

Which nodes are the children of b? Give the letters representing those nodes, not their
indices. - ANS-Left: d, Right: e

Which of the following operations have a worst case asymptotic running time of O(logn)
(no better, no worse) in a heap? - ANS-insert, remove min, upheap, downheap

Consider an undirected, unweighted graph. We want to visit all the vertices connected
to a given start vertex, by order of non-decreasing distance from the start vertex.
Which one or ones of the following algorithms solve the problem? - ANS-Only breadth
first search

Which one of the following is a reason that the adjacency set implementation of a graph
is generally preferred to the edge set implementation? - ANS-The adjacency set
implementation provides faster access to the neighbors of a given vertex.

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

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79223 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

Recently viewed by you


$7.99
  • (0)
  Add to cart