Kentucky is Karst Country - Kentucky Geological Survey - University
CS100 - University of Kentucky
Transcript of CS100 - University of Kentucky
![Page 1: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/1.jpg)
CS 100
Tuesday 6 October 2015
![Page 2: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/2.jpg)
Today’s Agenda
0. Announcements 1. Calendar 2. Professor Ruigang Yang, UK Computer
Science 3. Teem Geek Chapter 2 4. The Magic of Computer Science
A. Algorithms and Structure B. Massive Parallelism (map reduce)
![Page 3: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/3.jpg)
0. Announcements
• 13 October: Group Project Launch – Expect Group assignments and project details
• 20 October: Quiz 1 – Begin to organize your notes for Quiz Study
• Office hours – Can check with Amy or Diane in CS department to see if a meeYng and/or trip has curtailed office hours
![Page 4: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/4.jpg)
1. Calendar • HW3 (“numbers”) due tonight by midnight tonight
int main () { int SHIFT=10; // number of shifts to print in table // ASCII codes to "decode" (this was given in the assigned problem) char A[55] = {80, 94, 25, 58, 107, 94, 25, 80, 98, 101, 93, 92, 90, 109, 108, 26}; // Construct a string from the declared array of characters string message(A); // Print the table for each shift value, starting at zero for(int i =0; i < SHIFT; i++) { printShifted(message, -i); cout << endl; } return 0; }
![Page 5: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/5.jpg)
// Shifts each ASCII character in string by "shift” void printShifted (string s, int shift) { // print shifted values as characters, fixed field width so that // it lines up for (int i=0; i < (s.length()); i++) cout << setw(3) << (char)(s[i]-shift); cout << endl; // print shifted values as ASCII equivalents for (int i=0; i < (s.length()); i++) cout << setw(3) << s[i]-shift; cout << endl; }
![Page 6: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/6.jpg)
2. Professor Yang
• PhD UNC Chapel Hill • Full Professor at UK
![Page 7: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/7.jpg)
Teem Geek
• Clickers
![Page 8: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/8.jpg)
The Magic of Computer Science (Part 2)
Any sufficiently advanced technology is indisYnguishable from magic -‐ Arthur C. Clarke
![Page 9: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/9.jpg)
There is no magic. -‐ Ken Calvert
![Page 10: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/10.jpg)
Review: Powers of 2
20 = 1 24 = 16 28 = 255 212 = 4096
21 = 2 25 = 32 29 = 512 213 = 8192
22 = 4 26 = 64 210 = 1024 214 = 16384
23 = 8 27 = 128 211 = 2048 215 = 32768
![Page 11: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/11.jpg)
Recap • The power of compuYng comes from the ability to manipulate digital informaYon
• Analog-‐to-‐Digital conversion translates natural phenomena (e.g., waveforms) into digital representaYon – Music (MP3), voice telephony – Images (JPEG, HDTV)
• Once informaYon is encoded digitally, it can be: – Stored on any digital medium – Manipulated by any computer – Duplicated perfectly at very low cost
![Page 12: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/12.jpg)
Algorithms
Exploit structure of a problem / ordering Very common problem: Order a set of informaYon
12
![Page 13: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/13.jpg)
Resumes
• Last Name, First Name • Lots of other info…
• Problem – return resumes to owners (aler ingesYng informaYon, of course)
![Page 14: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/14.jpg)
Ordering is Crucial for Queries
• Queries (or “data mining”) – Find informaYon in the set of data to answer quesYons
– InformaYon can be composite: • How many people are from Jessamine county?
– Or individual • What is Jamie Lewis’ age?
• Queries are hard without structure / ordering
![Page 15: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/15.jpg)
Algorithm for Ordering
• MulYple stages – “sort” smallest stack – Reduce number of stacks via merge
![Page 16: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/16.jpg)
Ordering a.k.a. SorYng
• Sort – Sort a single group of papers any way you want. Make sure at the end your group of papers is in alphabeYcal order by last name.
– At the end of this phase we should have a bunch of stacks of papers, each of which is alphabeYzed.
![Page 17: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/17.jpg)
Total Ordering: Can Merge to Reduce Number of Stacks
• Merger task: merge two stacks together, keeping them in alphabeYcal order
• Now find another merger and negoYate again (one of you drops out, the other conYnues to the next round as a merger)
• Double down!
![Page 18: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/18.jpg)
Alternate Plan: Shards
• How about creaYng shards based on first leqer of last name?
• 26 shards • Now order each shard
• Any relaYonship to binary numbers?
• There is no magic.
![Page 19: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/19.jpg)
Ordered Data: Can Answer Queries
• Ordered / structured data very powerful • But there is just one of me to rifle through the data source to answer quesYons….
• What about informaYon like this? – What are the top Kentucky counYes (by count) represented in this class?
![Page 20: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/20.jpg)
Parallelism
• Structure of many problems allows the possibility to solve them in pieces, where the pieces happen simultaneously
(There is no magic)
![Page 21: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/21.jpg)
hqp://www.tutorialspoint.com/map_reduce/map_reduce_quick_guide.htm
![Page 22: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/22.jpg)
MapReduce
• Programming model for solving problems – In parallel – On a cluster – Low level abstracYons (binary numbers) – Structure of informaYon (algorithms) – Massively parallel / distributed soluYons driven by data centers available on a global scale
![Page 23: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/23.jpg)
TakeAways
• Numbers are an abstracYon – At the lowest level, they are binary sequences
• Media is an abstracYon – At the lowest level, digital media is a binary sequence
• Algorithms are abstracYons – At the lowest level, they are sequences of operaYons on binary sequences
• Parallelism is an abstracYon – At the lowest level, it is simultaneous, structured acYvity on binary sequences
![Page 24: CS100 - University of Kentucky](https://reader031.fdocuments.us/reader031/viewer/2022032823/6213c1b19569623032455de2/html5/thumbnails/24.jpg)
DistribuYng Results
• Collect and show results