100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CS 010C Final Exam Study Guide $9.99   Add to cart

Other

CS 010C Final Exam Study Guide

 3 views  0 purchase

This is a comprehensive study guide for CS 010C at the University of California, Riverside based on the class taught by Pat Miller for Winter 2023 and Spring 2024. Includes code, definitions, and all other major topics covered by the course on the final exam.

Preview 3 out of 25  pages

  • August 18, 2024
  • 25
  • 2023/2024
  • Other
  • Unknown
All documents for this subject (1)
avatar-seller
jasminehanna
📓
CS 010C: Study Guide
UCR’s CS010C - Data Structures & Algorithms

Professor Pat Miller [Winter 2024 Final Exam: Study Guide]




HEAPS
heaps: a complete binary tree that satisfies the heap property

completely filled at all levels

height of O(logn), where n =number of elements

efficient for priority queue
implementations

max-heap: the max element is
at the root

min-heap: the min element is at
the root




CS 010C: Study Guide 1

, complete binary tree: every level, except possibly the last, is completely filled & all
nodes are as far left as possible

this allows for efficient storage & retrieval of elements without using explicit
pointers/references as in linked lists

insertion, deletion, heapification, and other heap operations are easier to
implement because the structure of complete binary trees make it so that the
child nodes are in predictable positions

less storage because no memory is occupied by pointers



File I/O
string filename("bar.txt");
int x;


// open file
input.open(filename);

// check if file was opened
if (!input.is_open()) {
throw runtime_error("can't open file");
}

// attempt to read int x to file
input >> x;

// check if anything was read (if not, it's an empty file)
if(input.eof()) {
throw runtime_error("empty file");
}

// check if integer was read (if not, it wasn't an int)
if(input.fail()) {




CS 010C: Study Guide 2

, throw runtime_error("not an integer");
}




Sorting Algorithms
SELECTION SORT
selection sort: repeatedly finds the minimum element from the unsorted section &
moves it to the sorted section until the whole array is sorted.

has O(n2 )runtime complexity

void selectionSort(int arr[], int n) {
for (int i = 0; i < n-1; i++) {
int min_idx = i;
for (int j = i+1; j < n; j++) {
if (arr[j] < arr[min_idx]) {
min_idx = j;
swap(arr[min_idx], arr[i]);
}
}
}
}




BUBBLE SORT
bubble sort: repeatedly steps through the list, compares adjacent elements, and
swaps them if they are in the wrong order. The pass through the list is repeated
until the list is sorted; the algorithm gets its name because smaller elements
"bubble" to the top of the list (beginning) with each iteration.

has O(n2 )runtime complexity




CS 010C: Study Guide 3

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

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

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