100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CS2 Final Exam Practice Test Results - Extended Study questions with correct answers. $13.49   Add to cart

Exam (elaborations)

CS2 Final Exam Practice Test Results - Extended Study questions with correct answers.

 2 views  0 purchase
  • Course
  • CS2
  • Institution
  • CS2

CS2 Final Exam Practice Test Results - Extended Study questions with correct answers.

Preview 2 out of 8  pages

  • October 22, 2024
  • 8
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • CS2
  • CS2
avatar-seller
Lectphilip
CS2 Final Exam Practice Test Results -
Extended Study questions with correct
answers
Do Test 2 Study Guide in Quizlet! - correct answer -



How would you write a recursive method for the Fibonacci sequence? public static long fib(int n) -
correct answer -public static long fib(int n)

{

if (n <= 2) { return 1; }

else

{ return fib(n - 1) + fib(n - 2); }

}



write a code that return the recursive sum of the numbers between 0 and x: - correct answer -import
java.util.*;



public class sumDemo

{

private long k;

public long sumIt(long n)

{

if(n==0){

return k;}

k+=n;

return sumIt(--n);

}



public static void main (String[] args)

, {

sumDemo sum1 = new sumDemo();

sum1.sumIt(18);

}



}



What is the relationship between binary search trees and red & black trees? - correct answer -Red &
Black trees are a special kind of Binary search tree, that balances itself.



What are the 5 properties of red & black trees? - correct answer -1) Every node is colored red or black

2) The root is black

3) A red node cannot have a re child ("No double reds rule")

4) All paths from the root to a nut have the same number of black nodes ("Equal exit costs rule")

5) It must be a binary search tree



What is the time efficiency of the red and black trees? - correct answer -O(log(n))



What is a heap? - correct answer -A binary tree with 2 properties



What are the properties of a heap? - correct answer -1) A heap is an almost full binary tree except the
last level

2) All descendants of the nodes have values that are at least as large as the parent node value. Know as
the heap property.



Is the heap a tree, binary tree or a binary search tree? - correct answer -binary tree



What is Random Access Memory? - correct answer -Accessing specific locations in a file and change only
those locations.

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

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75057 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
$13.49
  • (0)
  Add to cart