100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Other

CS 010C Final Exam Study Guide

Rating
-
Sold
4
Pages
25
Uploaded on
18-08-2024
Written in
2023/2024

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.

Show more Read less










Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
August 18, 2024
Number of pages
25
Written in
2023/2024
Type
Other
Person
Unknown

Content preview

📓
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
$11.98
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
jasminehanna

Also available in package deal

Thumbnail
Package deal
Final Exam Study Guides for CS 010C, MATH/CS 011, and MATH 009C (UCR)
-
3 2024
$ 35.45 More info

Get to know the seller

Seller avatar
jasminehanna University Of California - Riverside
View profile
Follow You need to be logged in order to follow users or courses
Sold
4
Member since
1 year
Number of followers
0
Documents
3
Last sold
6 months ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

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

Frequently asked questions