SORTING ALGORTIHMS CONTININUED
Bucket Sort Drop each element into a bucket.
worst case : O(n + m)
best case : O(n + m)
when does it make sense to use?
when is it a bad idea?
nm
m
Radix Sort (radix = number of unique digits on a counting system)
Put each s
Dictionary / Spellcheck

BST
 Insertion
 o(n) if inserted in alphabetical order.
 Lookup
 o(log n) if dealing with nicely randomly ordered data.
Counting Word
Struct node
cfw_
char *data;
struct node *left, *right;
int count;
;
Corpus  Body of test
SORTING LISTS
*Bubble sort Takes the first index and moves it to the right if larger.
[ 8 , 4, 2, 5 ] becomes [4, 2, 5, 8] becomes [ 2, 4, 5, 8]
worstcase : O(n2)
bestcase : O(n)
*Selection sort  (select the smallest element) and swap with lest most a
KEY TOPIC
Analyze Bigoh runtimes of code segments.
O(n)
O ( 10 ) => O ( 1 )
Produce and solve summations for code segments
*How many times was some line executed?
*What is the value of some variable at the end of execution?
Write recursive functions (e
NOTE: These answers correspond to test Version A. The questions across all test versions are
similar.
Fall 2013 COP 3502 Test #2 Version A Explanations
1) In the function makeStr, which of the following completes the portion of the for loop on line
67 so
Order Notation and Estimating Complexity
We have looked at a few number of algorithms in class thus
far. However, we have not looked at how to judge the efficiency
or speed of an algorithm, which is one of the goals of this class.
We will use order notati
Detailed Algorithm Analysis: Collection Problem
The problem is as follows: We wish to collect all the items in a set,
cfw_1, 2, 3, , n. Unfortunately, we can only buy random items.
Each time we buy an item, we have no control over which one we
get. We sim
Analysis of Code Segments
Each of the following examples illustrates how to determine the BigOh run time of a segment of code or a function. Each of these
functions will be analyzed for their runtime in terms of the variable
n. Keep in mind that runtime
Base Conversion
Our regular counting system is the decimal (base 10) system. This is
because we use 10 distinct digits, zero through nine. In general, the
numerical value of a number is what you were taught in elementary
school. For example,
2713 = 2 x 10
Backtracking
Backtracking is a technique used to solve problems with a
large search space, that systematically tries and eliminates
possibilities.
A standard example of backtracking would be going through a
maze. At some point in a maze, you might have tw
Deletion from an AVL Tree
First we will do a normal binary search tree delete. Note that
structurally speaking, all deletes from a binary search tree
delete nodes with zero or one child. For deleted leaf nodes,
clearly the heights of the children of the n
Linear Search
In C Programming, we looked at the problem of finding a
specified value in an array. The basic strategy was:
Look at each value in the array and compare it to what we're
looking for. If we see the value at any time, return that we've
found i
Algorithm Analysis
Some of the types of problems we've looked at where we'd like
to analyze the efficiency of functions or algorithms:
1) Generic Array Algorithms
2) General Recursive Algorithms
3) Sorting:
A) Selection Sort
B) Merge Sort
C) Quick Sort
5)
Verifying an Algorithmic Analysis through running
actual code
Let's assume that T(N) is the experimental running time of a
piece of code and we'd like to see if T(N) O(F(N).
One way to do this is by computing T(N)/F(N) for a range of
different values for
E xam #2 Study Questions
1) If an O(n2) algorithm takes 40 ms to complete with an input
size of n = 20,000, how much time will it take to complete on an
input size of n = 70,000?
2) What is the runtime (BigOh) in terms of n of the following
code segment
COP 3502 Exam #2 Review
Test Date/Time: October 4 (Friday) 9:3010:20am NSC101
Outline of Material Covered on the exam
I. Linked Lists
a. Creating
b. Inserting Elements
c. Deleting Elements
d. Searching for Elements
e. Circular
f. Doubly Linked
II. Algori
Outline of Topics for the Exam
I. Basics of C if, loops, functions, array, strings, files
II. Mathematical Background
a. base conversion (2, 10, 16, other)
b. logs and exponents
c. sums
d. BigOh problems
III. Pointers and Dynamic Arrays
a. how to allocat
COP 3502 Computer Science I Fall 2013 Syllabus
Course Prerequisites: COP 3223 (Introduction to C Programming)
Class Time: Monday, Wednesday, Friday 9:30 10:20am
Class Location: NSC 101
Course Web Page: http:/www.cs.ucf.edu/courses/cop3502/fall2013
Lecture
Fall 2013 Computer Science I
Recitation Worksheet: Linked Lists (9/16/2013)
For each question use the following struct definition:
struct ll cfw_
int data;
struct ll* next;
;
1) Write a function that takes a pointer to the front of a linked list and chang
Fall 2013 Computer Science I
Recitation Worksheet: Linked Lists (9/16/2013) Solutions
For each question use the following struct definition:
struct ll cfw_
int data;
struct ll* next;
;
1) Write a function that takes a pointer to the front of a linked list
2013 Fall Computer Science I Program #3: Organ Transplant Database
Please consult Webcourse for the due date/time
Note: For this assignment, you will be writing a program that implements a different solution to the
problem posed in the first program for t
AVL Trees
In order to have a worst case running time for insert and delete
operations to be O(log n), we must make it impossible for there
to be a very long path in the binary search tree. The first
balanced binary tree is the AVL tree, named after it's
i
Applications of Binary Search
The basic idea of a binary search can be used in many different
places. In particular, any time you are searching for an answer in a
search space that is somehow sorted, you can simply set a low
bound for the value youre look