Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMPT 120 Lecture 26 – Unit 5 – Internet and Big Data

Similar presentations


Presentation on theme: "CMPT 120 Lecture 26 – Unit 5 – Internet and Big Data"— Presentation transcript:

1 CMPT 120 Lecture 26 – Unit 5 – Internet and Big Data
Python – More on Lists of Lists Algorithm - Searching

2 A few things on our menu today
Thank you for answering the Survey during our class of Friday, June 28! Talk about our Midterm 2 this week Go over “test cases” by looking at Question 11 of last Friday’s Lecture 25 – Practice Exam Finish looking at lists of lists … … and answering the question: Why are we looking at lists of lists? Start our Unit 5 – Internet and Big Data

3 Survey Result

4 Lecture 25 – Practice Exam – Part 1 – Question 11 – Test Cases

5 Let’s have another look at lists - cont’d

6 Another 2D Data Structure: Lists of Lists
Question: What if a problem statement ask us to manipulate a matrix? Answer: In our solution (program), we could use a list of lists to represent a matrix the Python code representing the above data would look like: myMatrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

7 Lists of Lists How can we create myMatrix?
How can we access each of its elements? myMatrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] How can we slice it? How can we modify its elements?

8 What else can we represent using a list of lists?
Let’s have a little demo!

9 Unit 5 - Internet and Big Data
A LOT of data The internet has given us data For example, Google is able to search through billions of web pages, and Amazon has millions of products In this unit, we will learn about searching, sorting and how to do it fast even when there’s lots data

10 Where is search used? We need search to be especially efficient for large amounts of data Google Domain name system (DNS) servers Music databases Amazon customer databases … everywhere!

11 Unit 5 - Internet and Big Data
APPLICATIONS In this unit, we’ll learn about algorithms that allow machines to solve a very common problem: searching and sorting ALGORITHMS We’ll look at searching algorithms: linear search and binary search and code We’ll look at sorting algorithms: bubble, selection and insertion sort and code We’ll analyze their “complexity” and see what we can do knowing their “complexity” PYTHON: Revisiting file I/O A common problem: find an element in a sequence.

12 First, the basic algorithm: Linear Search
Searching First, the basic algorithm: Linear Search

13 Let’s try! Is in this sequence?
Called “target”

14 What did we do to find the target?

15 Lecture Review Write a Python statement (only one) that will create the variable border = ['-','-','-','-','-','-'] What is the name of the searching algorithm we learned today and why is it called this way? Do we need to use comparison operators when searching? Write a Python statement that will produce the result [4,5,2] using myLists = [[9,0],[4,5,2],[3,1,1,9]] Write a Python statement that will produce the result [4,5] using myLists = [[9,0],[4,5,2],[3,1,1,9]]

16 Next Lecture Our Midterm 2 - Theory and Understanding In SWH 10081
At 9:30am Good luck in your studying!


Download ppt "CMPT 120 Lecture 26 – Unit 5 – Internet and Big Data"

Similar presentations


Ads by Google