CS106B Midterm Review

Size: px
Start display at page:

Download "CS106B Midterm Review"

Transcription

1 CS106B Midterm Review Anna Zeng and Aleksander Dash Slides adapted from Anton Apostolatos, Ashley Taylor and Nolan Handali Special thanks to Brahm Capoor for everything recursion-related

2 Today s Session Overview Logistics C++ basics ADTs Big-O Recursion Tips, tricks, and everything in between! Memory, pointers, and link nodes Additional study tips

3 Logistics

4 Midterm Logistics Thursday February 15th, 7:00-9:30 pm Memorial Auditorium Open book No electronic copies, no print-outs There will be a few copies in the front if you don t have a copy Closed notes (reference sheet will be provided) Pencils highly recommended, pens accepted Problems graded based on functionality, not style But if we can t read your handwriting, we can t grade you!

5 What s on the midterm Topics: C++ basics: Console I/O, strings, streams, functions and pass by value/reference ADTs: Vector, Grid, Stack, Queue, Set (+ HashSet), Map (+ HashMap) Big-Oh Notation Recursion Backtracking Pointers 8-10 questions total Mix between reading code and writing code Source: XKCD

6 What s not on the midterm

7 C++ Basics

8 Understand what Tip #0: happens when you pass by value vs. reference Make sample mystery Tip #1: code and test yourself and your friends Review assignments 1 and 2 for I/O, strings Tip #2: and file streams Source: International Obfuscated C Code Contest

9 Tracing Exercise int main() { int frodo = 7; int sam = 5; int merry = 4; int pippin = cervantes(sam, dumas(frodo, sam, merry)); cout << sam << endl; cout << pippin << endl; cout << merry << endl; return 0; int cervantes(int &sancho, int quixote) { sancho *= quixote; return quixote--; int dumas(int athos, int &aramis, int &porthos) { if (athos + aramis < porthos) { athos = aramis - porthos; else { porthos--; return aramis - (athos + 7);

10 Tracing Exercise int main() { int frodo = 7; int sam = 5; int merry = 4; int pippin = cervantes(sam, dumas(frodo, sam, merry)); cout << sam << endl; cout << pippin << endl; cout << merry << endl; return 0; Console int cervantes(int &sancho, int quixote) { sancho *= quixote; return quixote--; int dumas(int athos, int &aramis, int &porthos) { if (athos + aramis < porthos) { athos = aramis - porthos; else { porthos--; return aramis - (athos + 7);

11 ADTs

12 43 Vector Grid (1D list of elements) (2D list of elements)

13 Stack Queue (LIFO linear structure) (FIFO linear structure) push pop enqueue dequeue

14 Map Set (Collection of key/value pairs) (Collection of unique elements)

15 ADT Exercise I Write a function that reads a input file of phone numbers and prints all the phone numbers with the most commonly occurring area code. Sample input.txt: Sample output:

16 Solution (part 1) void areacodes(string filename) { // open file ifstream input; ifstream input(filename); input.open(filename.c_str()); if (input.fail()) { return; // read file data into map of sets Map <string, Set<string>> numbers; string line; while (getline(input, line)) { string areacode = line.substr(0, 3); numbers[areacode].add(line);

17 Solution (part 2) // find most popular area code string best = ""; for (string areacode : numbers) { if (best.empty() numbers[areacode].size() > numbers[best].size()) { best = areacode; // print all numbers in that area code for (string number : numbers[best]) { cout << number << endl;

18 ADT Exercise II Write a function commoncontacts(map<string, int>& mybook, Map<string, int>& theirbook) that returns a set of the names of all the common contacts (same name & number) between two phonebooks Chris Marty Mehran

19 ADT Exercise II - Using vectors Set<string> commoncontacts(map<string, int>& mybook, Map<string, int>& theirbook) { Set<string> commoncontacts; for (string mycontact : mybook.keys()) { for (string theircontact : theirbook.keys()) { if (mycontact == theircontact && mybook[mycontact] == theirbook[theircontact]) { commoncontacts.add(mycontact); return commoncontacts;

20 Big-Oh Notation

21 Big-Oh Exercise I If vec has N elements and database has M elements: int mystery(vector<int>& vec, Set<int>& database) { int total = 0; Set<int> s = database; for (int itemone : vec) { for (int itemtwo : database) { if (itemone == itemtwo) { total++; else { for (int itemthree : vec) { s.add(itemthree); return total;

22 Big-Oh Exercise I - Answer: O(N²Mlog(M)) If vec has N elements and database has M elements: int mystery(vector<int>& vec, Set<int>& database) { int total = 0; // O(1) Set<int> s = database; // O(M) for (int itemone : vec) { // O(N * M for (int itemtwo : database) { // O(M if (itemone == itemtwo) { // total++; // else { for (int itemthree : vec) { // s.add(itemthree); return total; // O(1) * N * log(m)) * N * log(m)) O(1) O(1) O(N * log(m)) // O(log(M))

23 Big-Oh Exercise II If s has N elements: int recurse(stack<int>& s) { if (!s.isempty()){ int x = s.pop(); return x + recurse(s); return 0;

24 Big-Oh Exercise II - Answer: O(N) If s has N elements: int recurse(stack<int>& s) { if (!s.isempty()){ int x = s.pop(); return x + recurse(s); return 0; // O(1) // O(1) What is the Big-Oh of each recursive call? How many recursive calls do we make? Each recursive step is O(1), and since we go through the entire stack one element at a time, we have N recursive steps, so we multiply them to get O(1 * N)

25 Recursion Brahm Capoor In order to understand recursion, you must first understand recursion

26 Section problems 1. Problem 3: Reverse 2. Problem 5: Subsequence

27 Reverse Let s find the base case When is the problem so simple you don t need to think? What s the simplest possible string? Now let s do the harder cooler part If we have a more complex string, how can we make the problem simpler? reverse( banter ) = retnab key insight: we can break a string into two parts: the first letter, and the rest of the string How does this suggest recursion?

28 The Pseudocode function reverse(s): if s is blank: return a blank string else: c = first character of s r = rest of string return reverse(r) + c The Code string reverse(string s) { if (s == ) return ; return reverse(s.substr(1)) + s[0];

29 Subsequence: is s2 a subsequence of s1? Let s find the base case(s) When is the problem so simple that you don t need to think? What s the simplest possible string? How many base cases do we need? Now let s do the harder cooler part If we have more complex strings, how do we make the problem simpler? examples: issubsequence( catch, cat ) = issubsequence( atch, at ) issubsequence( scatter, cat ) = issubsequence( catter, cat ) key insights: if the two strings have the same first character, we examine the rest of the strings if the two strings have different first characters, we examine the rest of the first string

30 The Pseudocode function is_subseq(s1, s2) : if s2 is blank: return true if s1 is blank: return false else: if same first character: r1 = rest of s1 r2 = rest of s2 return is_subseq(r1, r2) else: r1 = rest of s1 return is_subseq(r1, s2) The Code bool is_subseq(string s1, string s2) { if (s2 == ) return true; if (s1 == ) return false; if (s1[0] == s2[0]){ string r1 = s1.substr(1); return is_subseq(r1, r2); else { string r1 = s1.substr(1); return is_subseq(r1, s2);

31 Other useful recursion problems Tracing problem: Basic recursion practice: Problem 1 Problem 2: Sum of squares Recursion string problems: Problem 3: Reverse Problem 4: Star string

32 Backtracking Choose. Explore. Unchoose. Repeat.

33 Recursion vs backtracking: building an intuition string reverse(string s) { if (s == ) return ; return reverse(s.substr(1)) + s[0]; bool is_subseq(string s1, string s2) { if (s2 == ) return true; if (s1 == ) return false; if (s1[0] == s2[0]){ string r1 = s1.substr(1); return is_subseq(r1, r2); else { string r1 = s1.substr(1); return is_subseq(r1, s2);

34 Recursion vs backtracking: building an intuition string reverse(string s) { if (s == ) return ; return reverse(s.substr(1)) + s[0]; bool is_subseq(string s1, string s2) { if (s2 == ) return true; if (s1 == ) return false; if (s1[0] == s2[0]){ string r1 = s1.substr(1); return is_subseq(r1, r2); else { string r1 = s1.substr(1); return is_subseq(r1, s2); // the recursive cases are mutually exclusive In recursion, you only ever do one recursive call at every level of the recursion In recursion, you know that your recursive call will work (it s the leap of faith!)

35 Section problems 1. Problem 4: Longest Common Subsequence

36 issubsequence bool is_subseq(string s1, string s2) { if (s2 == ) return true; if (s1 == ) return false; if (s1[0] == s2[0]){ string r1 = s1.substr(1); return is_subseq(r1, r2); else { string r1 = s1.substr(1); return is_subseq(r1, s2); subseq( banter, bar ) = subseq( anter, ar ) subseq( banter, ant ) = subseq( anter, ant ) Let s find a base case When is the problem so simple you don t need to think? What s the simplest possible string? Let s think about more complicated versions of the problem Let s try and mirror the structure of bool is_subseq(string s1, string s2) What s the LCS when the two strings have the same first character? What s the LCS when the two strings have different first characters?

37 LCS redux: so why backtracking? bool is_subseq(string s1, string s2) { if (s2 == ) return true; if (s1 == ) return false; if (s1[0] == s2[0]){ string r1 = s1.substr(1); return is_subseq(r1, r2); else { string r1 = s1.substr(1); return is_subseq(r1, s2); subseq( banter, bar ) = subseq( anter, ar ) subseq( banter, ant ) = subseq( anter, ant ) Let s find a base case When is the problem so simple you don t need to think? What s the simplest possible string? when strings are blank! Let s think about more complicated versions of the problem Let s try and mirror the structure of bool is_subseq(string s1, string s2) What s the LCS when the two strings have the same first character? LCS(the rest) What s the LCS when the two strings have different first characters?

38 LCS redux: so why backtracking? What do we do when the two strings have different first characters? LCS( banter, ant ) = LCS( anter, ant ) How did I know to remove the b from banter? LCS( banter, abat ) = LCS( banter, bat ) How did I know to remove the a from abat? Radical idea: What if I didn t know? What if I tried both ways? I d get two subsequences. How would I know which was better? Hint: What is the function trying to find? Let s put it all together...

39 The Pseudocode Compare: issubsequence Pseudocode function LCS(s1, s2) : if s1 or s2 is blank: return a blank string else: if same first character: c = first char r1 = rest of s1 r2 = rest of s2 return c + LCS(r1, r2) else: r1 = rest of s1 r2 = rest of s2 p1 = LCS(s1, r2) p2 = LCS(r1, s2) return longer of p1 and p2 function is_subseq(s1, s2) : if s2 is blank: return true if s1 is blank: return false else: if same first character: r1 = rest of s1 r2 = rest of s2 return is_subseq(r1, r2) else: r1 = rest of s1 return is_subseq(r1, s2)

40 The Pseudocode function LCS(s1, s2) { if s1 or s2 is blank: return a blank string else: if same first character: c = first char r1 = rest of s1 r2 = rest of s2 return c + LCS(r1, r2) else: r1 = rest of s1 r2 = rest of s2 p1 = LCS(s1, r2) p2 = LCS(r1, s2) return longer of p1 and p2 The Code string LCS(string s1, string s2) { if (s1 == s2 == ) return ; if (s1[0] == s2[0]){ string r1 = s1.substr(1); return s1[0] + LCS(r1, r2); else { string r1 = s1.substr(1); string p1 = LCS(s1, r2); string p2 = LCS(r1, s2); if (p1.length() > p2.length() { return p1; else { return p2;

41 Rethinking backtracking It s hard to think of this in terms of choose/explore/unchoose But what did we do? string LCS(string s1, string s2) { if (s1 == s2 == ) return ; if (s1[0] == s2[0]){ return s1[0] + LCS(r1, r2); else { string r1 = s1.substr(1); string p1 = LCS(s1, r2); string p2 = LCS(r1, s2); if (p1.length() > p2.length()) { return p1; else { return p2;

42 Rethinking backtracking It s hard to think of this in terms of choose/explore/unchoose But what did we do? We found the possible options string LCS(string s1, string s2) { if (s1 == s2 == ) return ; if (s1[0] == s2[0]){ return s1[0] + LCS(r1, r2); else { string r1 = s1.substr(1); string p1 = LCS(s1, r2); string p2 = LCS(r1, s2); if (p1.length() > p2.length()) { return p1; else { return p2;

43 Rethinking backtracking It s hard to think of this in terms of choose/explore/unchoose But what did we do? We found the possible options We figured out what the best one was string LCS(string s1, string s2) { if (s1 == s2 == ) return ; if (s1[0] == s2[0]){ return s1[0] + LCS(r1, r2); else { string r1 = s1.substr(1); string p1 = LCS(s1, r2); string p2 = LCS(r1, s2); if (p1.length() > p2.length()) { return p1; else { return p2;

44 Rethinking backtracking It s hard to think of this in terms of choose/explore/unchoose But what did we do? We found the possible options We figured out what the best one was We gave that one back string LCS(string s1, string s2) { if (s1 == s2 == ) return ; if (s1[0] == s2[0]){ return s1[0] + LCS(r1, r2); else { string r1 = s1.substr(1); string p1 = LCS(s1, r2); string p2 = LCS(r1, s2); if (p1.length() > p2.length()) { return p1; else { return p2;

45 Rethinking backtracking It s hard to think of this in terms of choose/explore/unchoose But what did we do? We found the possible options We figured out what the best one was We gave that one back Backtracking isn t about choosing, exploring and unchoosing It s about figuring out which option works best (sometimes, that means choosing, exploring and unchoosing) string LCS(string s1, string s2) { if (s1 == s2 == ) return ; if (s1[0] == s2[0]){ return s1[0] + LCS(r1, r2); else { string r1 = s1.substr(1); string p1 = LCS(s1, r2); string p2 = LCS(r1, s2); if (p1.length() > p2.length()) { return p1; else { return p2;

46 That said... Choose (kinda) string LCS(string s1, string s2) { if (s1 == s2 == ) return ; if (s1[0] == s2[0]){ return s1[0] + LCS(r1, r2); else { string r1 = s1.substr(1); string p1 = LCS(s1, r2); string p2 = LCS(r1, s2); if (p1.length() > p2.length()) { return p1; else { return p2;

47 That said... Choose (kinda) Explore (kinda) string LCS(string s1, string s2) { if (s1 == s2 == ) return ; if (s1[0] == s2[0]){ return s1[0] + LCS(r1, r2); else { string r1 = s1.substr(1); string p1 = LCS(s1, r2); string p2 = LCS(r1, s2); if (p1.length() > p2.length()) { return p1; else { return p2;

48 That said... Choose (kinda) Explore (kinda) Unchoose (kinda-er) string LCS(string s1, string s2) { if (s1 == s2 == ) return ; if (s1[0] == s2[0]){ return s1[0] + LCS(r1, r2); else { string r1 = s1.substr(1); string p1 = LCS(s1, r2); string p2 = LCS(r1, s2); if (p1.length() > p2.length()) { return p1; else { return p2;

49 Other useful backtracking problems (all of them) Working with the choose-explore-unchoose paradigm: Using Recursive helper functions: Problem 6: Make Change Problem 9: Ways to climb Batsh!t awesome problems: Problem 7: Print Squares Problem 10: Twiddle Problem 11: Hacking & cracking (So literally, all of them. These are awesome midterm practice)

50 endl; /* good luck with the midterm! */

51 Pointers and Linked Nodes

52 Linked Lists 101 int main() { ListNode* front = new ListNode(); front->data = 3; delete front; Use new to create a new object on the heap To access data on the other end of a pointer, use -> Remember that this is just the same as, (*front).data Need to delete whatever you create Otherwise, memory leaks!

53 struct ListNode { int data; ListNode* next; Linked Nodes practice list1 list (8 out of 9 practice midterms have some form of this as the linked list problem) Tips: Draw a picture! Potentially declare temporary pointers to help you rearrange nodes

54 Linked Nodes practice answer ListNode* temp = list1; list1 temp list2 ListNode* temp2 = list2; temp2 list1 list1 = list1->next; temp 4 list2 = list1->next; temp2 5 list2

55 Linked Nodes practice answer list1 list1 -> next = temp2 -> next; list1->next->next = temp; list1->next->next->next = nullptr; temp temp2 1 4 list2 ->next = temp2; list2->next->next = nullptr; list

56 Pointer trace tips: The * symbol has two uses type* ptrname declares a pointer that points to an object of type type e.g. ListNode* front is a pointer that points to a ListNode *ptrname dereferences ptrname (aka, goes to where the pointer is pointing to) We ve seen this! Recall that ptr->data is equivalent to (*ptr).data

57 Pointer trace tips: The & symbol has two uses &value means give me the memory address that value is stored at e.g. &value returns something that looks like 0x20065ab0 Don t confuse this with reference parameters in function prototypes! e.g. void printlist (Vector<int>& v) {...

58 Pointer trace practice (from Practice Midterm #9) What is the output?

59 Pointer trace practice (from Practice Midterm #9) What is the output? Console

60 Additional Study Tips Good practice materials: Practice exams (9 total) Leftover section problems Codestepbystep.com See Julie Zelenski s Exam Strategies handout (bottom of cs106b.stanford.edu/exams.shtml) You got this! Good luck!

PRACTICE MIDTERM EXAM #2

PRACTICE MIDTERM EXAM #2 This practice exam is based on the actual midterm exam from Cynthia s Spring 2014 class. It did not include a classes problem (which you should expect this quarter), and the memory/pointers problem covered

More information

Programming Abstractions

Programming Abstractions Programming Abstractions C S 1 0 6 B Cynthia Lee Today s Topics ADTs Stack Example: Reverse-Polish Notation calculator Queue Example: Mouse Events Stacks New ADT: Stack stack.h template

More information

Queues and Unit Testing

Queues and Unit Testing Queues and Unit Testing Shreya Shankar Stanford CS 106B 3 July 2018 Based on slides created by Ashley Taylor, Marty Stepp, Chris Gregg, Keith Schwarz, Julie Zelenski, Jerry Cain, Eric Roberts, Mehran Sahami,

More information

CS 106X, Lecture 14 Classes and Pointers

CS 106X, Lecture 14 Classes and Pointers CS 106X, Lecture 14 Classes and Pointers reading: Programming Abstractions in C++, Chapter 6, 11 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons

More information

Practice Midterm Exam #1

Practice Midterm Exam #1 Eric Roberts Handout #23 CS106B January 28, 2013 Practice Midterm Exam #1 Review session: Sunday, February 3, 7:00 9:00 P.M., Hewlett 201 (next door) Midterm #1: Tuesday, February 5, 3:15 5:15 P.M., Braun

More information

PRACTICE MIDTERM EXAM #1

PRACTICE MIDTERM EXAM #1 CS106B Spring 2016 PRACTICE MIDTERM EXAM #1 Instructor: Cynthia Lee Practice Exam NAME (LAST, FIRST): SUNET ID: @stanford.edu Problem 1 2 3 4 5 Strings Pointers, Topic Recursion Classes Big-O and ADTs

More information

PRACTICE FINAL EXAM 3

PRACTICE FINAL EXAM 3 This practice exam is based on an actual final exam from CS106X (same topics coverage as CS106B, but somewhat higher expectations for mastery). The question types and mix of topics of our CS106B exam will

More information

CS106X Final Review. Rachel Gardner and Jared Bitz. slides adapted from Ashley Taylor, Anton Apostolatos, Nolan Handali, and Zachary Birnholz

CS106X Final Review. Rachel Gardner and Jared Bitz. slides adapted from Ashley Taylor, Anton Apostolatos, Nolan Handali, and Zachary Birnholz CS106X Final Review Rachel Gardner and Jared Bitz slides adapted from Ashley Taylor, Anton Apostolatos, Nolan Handali, and Zachary Birnholz Final Review Session Overview Logistics Pointers and Dynamic

More information

Practice Final Examination #2

Practice Final Examination #2 Eric Roberts Handout #54 CS106B March 11, 2013 Practice Final Examination #2 Review session: Sunday, March 17, 3:00 5:00 P.M. (Hewlett 200) Scheduled finals: Tuesday, March 19, 12:15 3:15 P.M. (Hewlett

More information

CS 106B, Lecture 1 Introduction to C++

CS 106B, Lecture 1 Introduction to C++ CS 106B, Lecture 1 Introduction to C++ reading: Programming Abstractions in C++, Chapters 1 & 2 This document is copyright (C) Stanford Computer Science and Ashley Marty Stepp, Taylor, licensed under Creative

More information

Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work. It is most beneficial to you to write this mock midterm UNDER EXAM CONDITIONS. This means: Complete the mock final in 170 minutes. Work on your own. Keep your notes and textbook closed. Attempt every question.

More information

double d0, d1, d2, d3; double * dp = new double[4]; double da[4];

double d0, d1, d2, d3; double * dp = new double[4]; double da[4]; All multiple choice questions are equally weighted. You can generally assume that code shown in the questions is intended to be syntactically correct, unless something in the question or one of the answers

More information

SYSC 2006 CD. Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

SYSC 2006 CD. Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work. It is most beneficial to you to write this mock midterm UNDER EXAM CONDITIONS. This means: Complete the mock final in 180 minutes. Work on your own. Keep your notes and textbook closed. Attempt every question.

More information

CSCI 102L - Data Structures Midterm Exam #2 Spring 2011

CSCI 102L - Data Structures Midterm Exam #2 Spring 2011 CSCI 102L - Data Structures Midterm Exam #2 Spring 2011 (12:30pm - 1:50pm, Thursday, March 24) Instructor: Bill Cheng ( This exam is closed book, closed notes, closed everything. No cheat sheet allowed.

More information

Programming Abstraction in C++

Programming Abstraction in C++ Programming Abstraction in C++ Eric S. Roberts and Julie Zelenski Stanford University 2010 Chapter 4. Using Abstract Data Types Outline 1 Vector Class 2 Grid Class 3 Stack Class 4 Queue Class 5 Map Class

More information

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises CS 2308 Spring 2014 Jill Seaman Chapters 1-7 + 11 Write C++ code to: Determine if a number is odd or even Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

CS 216 Exam 1 Fall SOLUTION

CS 216 Exam 1 Fall SOLUTION CS 216 Exam 1 Fall 2004 - SOLUTION Name: Lab Section: Email Address: Student ID # This exam is closed note, closed book. You will have an hour and fifty minutes total to complete the exam. You may NOT

More information

CSCI-1200 Data Structures Fall 2017 Lecture 7 Order Notation & Basic Recursion

CSCI-1200 Data Structures Fall 2017 Lecture 7 Order Notation & Basic Recursion CSCI-1200 Data Structures Fall 2017 Lecture 7 Order Notation & Basic Recursion Announcements: Test 1 Information Test 1 will be held Monday, Sept 25th, 2017 from 6-7:50pm Students will be randomly assigned

More information

Linked Lists CS 16: Solving Problems with Computers I Lecture #16

Linked Lists CS 16: Solving Problems with Computers I Lecture #16 Linked Lists CS 16: Solving Problems with Computers I Lecture #16 Ziad Matni Dept. of Computer Science, UCSB Material: Everything we ve done Homework, Labs, Lectures, Textbook Tuesday, 12/12 in this classroom

More information

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Sample Exam 2 75 minutes permitted Print your name, netid, and

More information

Lecture Notes on Queues

Lecture Notes on Queues Lecture Notes on Queues 15-122: Principles of Imperative Computation Frank Pfenning and Jamie Morgenstern Lecture 9 February 14, 2012 1 Introduction In this lecture we introduce queues as a data structure

More information

PRACTICE FINAL EXAM #4 (DRESS REHEARSAL)

PRACTICE FINAL EXAM #4 (DRESS REHEARSAL) Page 1 of 14 CS106B Spring 2016 Instructor: Cynthia Lee June 1, 2016 PRACTICE FINAL EXAM #4 (DRESS REHEARSAL) NAME (LAST, FIRST): SUNET ID: @stanford.edu Problem 1 2 3 4 5 6 7 Topic MST Linked List Heap

More information

Programming Abstractions

Programming Abstractions Programming Abstractions C S 1 0 6 X Cynthia Lee Today s Topics ADTs Stack Example: Reverse-Polish Notation calculator Queue Example: Mouse Events Stacks New ADT: Stack stack.h template

More information

CS61BL Summer 2013 Midterm 2

CS61BL Summer 2013 Midterm 2 CS61BL Summer 2013 Midterm 2 Sample Solutions + Common Mistakes Question 0: Each of the following cost you.5 on this problem: you earned some credit on a problem and did not put your five digit on the

More information

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 Instructor: K. S. Booth Time: 70 minutes (one hour ten minutes)

More information

CS 106B Lecture 5: Stacks and Queues

CS 106B Lecture 5: Stacks and Queues CS 106B Lecture 5: Stacks and Queues Monday, July 3, 2017 Programming Abstractions Summer 2017 Stanford University Computer Science Department Lecturer: Chris Gregg reading: Programming Abstractions in

More information

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001 CPSC 211, Sections 201 203: Data Structures and Implementations, Honors Final Exam May 4, 2001 Name: Section: Instructions: 1. This is a closed book exam. Do not use any notes or books. Do not confer with

More information

CS 106X, Lecture 7 Introduction to Recursion

CS 106X, Lecture 7 Introduction to Recursion CS 106X, Lecture 7 Introduction to Recursion reading: Programming Abstractions in C++, Chapter 7 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons

More information

Wentworth Institute of Technology COMP201 Computer Science II Spring 2015 Derbinsky. Stacks and Queues. Lecture 11.

Wentworth Institute of Technology COMP201 Computer Science II Spring 2015 Derbinsky. Stacks and Queues. Lecture 11. Lecture 11 1 More Data Structures In this lecture we will use a linked list to implement two abstract data types (ADT) An ADT provides the interface, or what a data structure does We can then use code

More information

! Mon, May 5, 2:00PM to 4:30PM. ! Closed book, closed notes, clean desk. ! Comprehensive (covers entire course) ! 30% of your final grade

! Mon, May 5, 2:00PM to 4:30PM. ! Closed book, closed notes, clean desk. ! Comprehensive (covers entire course) ! 30% of your final grade Final Exam Review Final Exam Mon, May 5, 2:00PM to 4:30PM CS 2308 Spring 2014 Jill Seaman Closed book, closed notes, clean desk Comprehensive (covers entire course) 30% of your final grade I recommend

More information

Pointers, Dynamic Data, and Reference Types

Pointers, Dynamic Data, and Reference Types Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple

More information

CSCI-1200 Data Structures Fall 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic

CSCI-1200 Data Structures Fall 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic CSCI-1200 Data Structures Fall 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic Announcements: Test 1 Information Test 1 will be held Thursday, Sept 20th, 2018 from 6-7:50pm Students will be randomly

More information

Lecture 10 Notes Linked Lists

Lecture 10 Notes Linked Lists Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to

More information

CSE 143. Lecture 4: Stacks and Queues

CSE 143. Lecture 4: Stacks and Queues CSE 143 Lecture 4: Stacks and Queues Stacks and queues Sometimes it is good to have a collection that is less powerful, but is optimized to perform certain operations very quickly. Today we will examine

More information

106B Final Review Session. Slides by Sierra Kaplan-Nelson and Kensen Shi Livestream managed by Jeffrey Barratt

106B Final Review Session. Slides by Sierra Kaplan-Nelson and Kensen Shi Livestream managed by Jeffrey Barratt 106B Final Review Session Slides by Sierra Kaplan-Nelson and Kensen Shi Livestream managed by Jeffrey Barratt Topics to Cover Sorting Searching Heaps and Trees Graphs (with Recursive Backtracking) Inheritance

More information

CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion

CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion Review from Lectures 5 & 6 Arrays and pointers, Pointer arithmetic and dereferencing, Types of memory ( automatic, static,

More information

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2007 7p-9p, Thursday, March 1 Name: NetID: Lab Section

More information

UNIVERSITY REGULATIONS

UNIVERSITY REGULATIONS CPSC 221: Algorithms and Data Structures Midterm Exam, 2015 October 21 Name: Student ID: Signature: Section (circle one): MWF(101) TTh(102) You have 90 minutes to solve the 8 problems on this exam. A total

More information

Programming Abstractions

Programming Abstractions Programming Abstractions C S 1 0 6 B Cynthia Lee Today s Topics ADTs Containers within containers Example: anagram finder Recursion First steps in this fun/crazy new concept Factorial! Compound Containers

More information

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

Cpt S 122 Data Structures. Course Review Midterm Exam # 1 Cpt S 122 Data Structures Course Review Midterm Exam # 1 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 1 When: Friday (09/28) 12:10-1pm Where:

More information

CS106B Sprint 2017 April 27 th, 2017 CS106B Practice Midterm (KEY)

CS106B Sprint 2017 April 27 th, 2017 CS106B Practice Midterm (KEY) CS106B Sprint 2017 April 27 th, 2017 CS106B Practice Midterm (KEY) This is an open-note, open-book exam. You can refer to any course handouts, textbooks, handwritten lecture notes, and printouts of any

More information

PRACTICE FINAL EXAM 2

PRACTICE FINAL EXAM 2 This practice exam is based on an actual final exam from CS106X (same topics coverage as CS106B, but somewhat higher expectations for mastery). The question types and mix of topics of our CS106B exam will

More information

Practice CS106B Midterm Solutions

Practice CS106B Midterm Solutions CS106B Handout 16S Winter 2019 February 12, 2019 Practice CS106B Midterm Solutions Here s one possible set of solutions for the midterm questions. Before reading over these solutions, please, please, please

More information

CS106X Handout 17 Winter 2015 January 28 th, 2015 CS106X Practice Exam

CS106X Handout 17 Winter 2015 January 28 th, 2015 CS106X Practice Exam CS106X Handout 17 Winter 2015 January 28 th, 2015 CS106X Practice Exam Exam Facts: When: Thursday, February 5 th from 7:00 10:00 p.m. Where: Cubberley Auditorium Coverage The exam is open-book, open-note,

More information

Programming Abstractions

Programming Abstractions Programming Abstractions C S 1 0 6 B Cynthia Lee Recursion! The exclamation point isn t there only because this is so exciting, it also relates to one of our recursion examples. Recursion Factorial! Recursive

More information

CS 106X, Lecture 10 Recursive Backtracking

CS 106X, Lecture 10 Recursive Backtracking CS 106X, Lecture 10 Recursive Backtracking reading: Programming Abstractions in C++, Chapter 9 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons

More information

Data Abstraction and Specification of ADTs

Data Abstraction and Specification of ADTs CITS2200 Data Structures and Algorithms Topic 4 Data Abstraction and Specification of ADTs Example The Reversal Problem and a non-adt solution Data abstraction Specifying ADTs Interfaces javadoc documentation

More information

Practice Final Examination #2

Practice Final Examination #2 Eric Roberts Handout #52 CS 106B March 9, 2015 Practice Final Examination #2 Review session: Sunday, March 15, 3:00 5:00 P.M. (Hewlett 200) Final exam: 1. Simple algorithmic tracing (5 points) Tuesday,

More information

== isn t always equal?

== isn t always equal? == isn t always equal? In Java, == does the expected for primitives. int a = 26; int b = 26; // a == b is true int a = 13; int b = 26; // a == b is false Comparing two references checks if they are pointing

More information

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises Chapters 1-7 + 11 Write C++ code to:! Determine if a number is odd or even CS 2308 Fall 2018 Jill Seaman! Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

CSE 143, Winter 2010 Midterm Exam Key

CSE 143, Winter 2010 Midterm Exam Key 1. ArrayList Mystery CSE 143, Winter 2010 Midterm Exam Key List (a) [10, 20, 10, 5] (b) [8, 2, 9, 7, -1, 55] (c) [0, 16, 9, 1, 64, 25, 25, 14, 0] Output [0, 10, 20, 10] [0, 0, 8, 9, -1, 55] [0, 0, 0, 0,

More information

CS106B Handout 18 Autumn 2012 October 15 th, 2012 Recursive Backtracking I

CS106B Handout 18 Autumn 2012 October 15 th, 2012 Recursive Backtracking I CS106B Handout 18 Autumn 2012 October 15 th, 2012 Recursive Backtracking I Recursive Backtracking So far, all of the recursive algorithms we have seen have shared one very important property: each time

More information

The examination is open-book, and you may make use of any texts, handouts, or course notes. You may not, however, use a computer of any kind.

The examination is open-book, and you may make use of any texts, handouts, or course notes. You may not, however, use a computer of any kind. CS106B Spring 2012 Handout #14 April 30, 2012 Practice Midterm 1 Based on a handout by Eric Roberts Midterm Locations: Last Name A J: Go to Braun Auditorium Last Name K R: Go to Hewlett 201 Last Name S

More information

Lecture 10 Notes Linked Lists

Lecture 10 Notes Linked Lists Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Summer 1 2015) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to

More information

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Sample Exam 2 75 minutes permitted Print your name, netid, and

More information

Data Structures CSci 1200 Test 2 Questions

Data Structures CSci 1200 Test 2 Questions Overview Data Structures CSci 1200 Test 2 Questions Test 2 will be held Thursday, March 10, 2010, 12:00-1:30pm, Darrin 308. No make-ups will be given except for emergency situations, and even then a written

More information

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 1/9/ Review. Here s a simple C++ program:

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 1/9/ Review. Here s a simple C++ program: Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams

More information

Section Handout #4: Classes, Pointers, and Dynamic Memory

Section Handout #4: Classes, Pointers, and Dynamic Memory Nick Troccoli Section #4 CS 106X Week 5 Section Handout #4: Classes, Pointers, and Dynamic Memory Based on handouts by various current and past CS106B/X instructors and TAs. Extra practice problems: CodeStepByStep

More information

CSE 326 Team. Today s Outline. Course Information. Instructor: Steve Seitz. Winter Lecture 1. Introductions. Web page:

CSE 326 Team. Today s Outline. Course Information. Instructor: Steve Seitz. Winter Lecture 1. Introductions. Web page: CSE 326 Team CSE 326: Data Structures Instructor: Steve Seitz TAs: Winter 2009 Steve Seitz Lecture 1 Eric McCambridge Brent Sandona Soyoung Shin Josh Barr 2 Today s Outline Introductions Administrative

More information

CS 106X, Lecture 23 Dijkstra and A* Search

CS 106X, Lecture 23 Dijkstra and A* Search CS 106X, Lecture 23 Dijkstra and A* Search reading: Programming Abstractions in C++, Chapter 18 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons

More information

CS32 Final Exam. E03, F15, Phill Conrad, UC Santa Barbara

CS32 Final Exam. E03, F15, Phill Conrad, UC Santa Barbara 1 #1 Page: 1 Name: CS32 Final E03, F15, Phill Conrad, UC Santa Barbara Thursday, 12/10/2015, noon 3pm Name: Umail Address: @ umail.ucsb.edu Please write your name above AND AT THE TOP OF EVERY PAGE Be

More information

Practice test for Midterm 1; solutions

Practice test for Midterm 1; solutions Practice test for Midterm 1; solutions November 1, 2 1 1 C++ review & UML diagrams Write a function which takes a vector of int and returns true if all the elements of the vector are positive ( 0) and

More information

CS 216 Fall 2007 Midterm 1 Page 1 of 10 Name: ID:

CS 216 Fall 2007 Midterm 1 Page 1 of 10 Name:  ID: Page 1 of 10 Name: Email ID: You MUST write your name and e-mail ID on EACH page and bubble in your userid at the bottom of EACH page including this page and page 10. If you do not do this, you will receive

More information

PIC 10A. Review for Midterm I

PIC 10A. Review for Midterm I PIC 10A Review for Midterm I Midterm I Friday, May 1, 2.00-2.50pm. Try to show up 5 min early so we can start on time. Exam will cover all material up to and including todays lecture. (Only topics that

More information

Programming Abstractions

Programming Abstractions Programming Abstractions C S 1 0 6 B Cynthia Lee Compound Containers I t s t u r t l e s a l l t h e w a y down Comparing two similar codes: Vector numbers; numbers.add(1); numbers.add(2); numbers.add(3);

More information

CMPT 125: Practice Midterm Answer Key

CMPT 125: Practice Midterm Answer Key CMPT 125, Spring 2017, Surrey Practice Midterm Answer Key Page 1 of 6 CMPT 125: Practice Midterm Answer Key Linked Lists Suppose you have a singly-linked list whose nodes are defined like this: struct

More information

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2007 7p-9p, Thursday, March 1 Name: NetID: Lab Section

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #34. Function with pointer Argument

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #34. Function with pointer Argument Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #34 Function with pointer Argument (Refer Slide Time: 00:05) So, here is the stuff that we have seen about pointers.

More information

UNIVERSITY REGULATIONS

UNIVERSITY REGULATIONS CPSC 221: Algorithms and Data Structures Midterm Exam, 2013 February 15 Name: Student ID: Signature: Section (circle one): MWF(201) TTh(202) You have 60 minutes to solve the 5 problems on this exam. A

More information

Lecture Notes on Queues

Lecture Notes on Queues Lecture Notes on Queues 15-122: Principles of Imperative Computation Frank Pfenning Lecture 9 September 25, 2012 1 Introduction In this lecture we introduce queues as a data structure and linked lists

More information

Separate Compilation Model

Separate Compilation Model Separate Compilation Model Recall: For a function call to compile, either the function s definition or declaration must appear previously in the same file. Goal: Compile only modules affected by recent

More information

CS106X Handout 35 Winter 2018 March 12 th, 2018 CS106X Midterm Examination

CS106X Handout 35 Winter 2018 March 12 th, 2018 CS106X Midterm Examination CS106X Handout 35 Winter 2018 March 12 th, 2018 CS106X Midterm Examination This is an open-book, open-note, closed-electronic-device exam. You needn t write #includes, and you may (and you re even encouraged

More information

You must include this cover sheet. Either type up the assignment using theory4.tex, or print out this PDF.

You must include this cover sheet. Either type up the assignment using theory4.tex, or print out this PDF. 15-122 Assignment 4 Page 1 of 12 15-122 : Principles of Imperative Computation Fall 2012 Assignment 4 (Theory Part) Due: Thursday, October 18, 2012 at the beginning of lecture Name: Andrew ID: Recitation:

More information

CMPSCI 187: Programming With Data Structures. Review for Final Exam David Mix Barrington 10 December 2012

CMPSCI 187: Programming With Data Structures. Review for Final Exam David Mix Barrington 10 December 2012 CMPSCI 187: Programming With Data Structures Review for Final Exam David Mix Barrington 10 December 2012 Exam Overview Thursday 13 December, 1:30-3:30 p.m., Marcus 131 Format is the same as the Fall 2011

More information

Lecture 24 Notes Search in Graphs

Lecture 24 Notes Search in Graphs Lecture 24 Notes Search in Graphs 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, André Platzer, Rob Simmons, Penny Anderson 1 Introduction In this lecture, we will discuss the

More information

Section Solutions 2. Problem One: Iteration Station. This code works just fine! This one works just fine!

Section Solutions 2. Problem One: Iteration Station. This code works just fine! This one works just fine! CS106B Winter 2019 Handout 10S January 22, 2019 Section Solutions 2 Problem One: Iteration Station void iteratevec1(const Vector& vals) { for (int i = 0; i < vals.size(); i++) { cout

More information

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26 COSC 2P95 Procedural Abstraction Week 3 Brock University Brock University (Week 3) Procedural Abstraction 1 / 26 Procedural Abstraction We ve already discussed how to arrange complex sets of actions (e.g.

More information

Data Structures Lecture 3 Order Notation and Recursion

Data Structures Lecture 3 Order Notation and Recursion Data Structures Lecture 3 Order Notation and Recursion 1 Overview The median grade.cpp program from Lecture 2 and background on constructing and using vectors. Algorithm analysis; order notation Recursion

More information

CS106X Handout 24 Winter 2018 February 9 th, 2018 CS106X Midterm Examination

CS106X Handout 24 Winter 2018 February 9 th, 2018 CS106X Midterm Examination CS106X Handout 24 Winter 2018 February 9 th, 2018 CS106X Midterm Examination This is an open-book, open-note, closed-electronic-device exam. You have 80 minutes to complete the exam. If you re taking the

More information

Chapter 9 STACK, QUEUE

Chapter 9 STACK, QUEUE Chapter 9 STACK, QUEUE 1 LIFO: Last In, First Out. Stacks Restricted form of list: Insert and remove only at front of list. Notation: Insert: PUSH Remove: POP The accessible element is called TOP. Stack

More information

Postfix (and prefix) notation

Postfix (and prefix) notation Postfix (and prefix) notation Also called reverse Polish reversed form of notation devised by mathematician named Jan Łukasiewicz (so really lü-kä-sha-vech notation) Infix notation is: operand operator

More information

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

CS 2150 Exam 1, Spring 2018 Page 1 of 6 UVa userid:

CS 2150 Exam 1, Spring 2018 Page 1 of 6 UVa userid: CS 2150 Exam 1, Spring 2018 Page 1 of 6 UVa userid: CS 2150 Exam 1 Name You MUST write your e-mail ID on EACH page and put your name on the top of this page, too. If you are still writing when pens down

More information

[2:3] Linked Lists, Stacks, Queues

[2:3] Linked Lists, Stacks, Queues [2:3] Linked Lists, Stacks, Queues Helpful Knowledge CS308 Abstract data structures vs concrete data types CS250 Memory management (stack) Pointers CS230 Modular Arithmetic !!!!! There s a lot of slides,

More information

Programming Abstractions

Programming Abstractions Programming Abstractions C S 1 0 6 B Cynthia Lee Today s Topics HW Tips QT Creator dos & don ts ADTs Stack Example: Reverse-Polish Notation calculator Queue Event queues QT Creator A F E W W A R N I N

More information

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program:

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program: Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams

More information

Announcements. Recursion and why study it. Recursive programming. Recursion basic idea

Announcements. Recursion and why study it. Recursive programming. Recursion basic idea Announcements Recursion and why study it Tutoring schedule updated Do you find the sessions helpful? Midterm exam 1: Tuesday, April 11, in class Scope: will cover up to recursion Closed book but one sheet,

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

! Determine if a number is odd or even. ! Determine if a number/character is in a range. ! Assign a category based on ranges (wind speed)

! Determine if a number is odd or even. ! Determine if a number/character is in a range. ! Assign a category based on ranges (wind speed) Final Exam Exercises Chapters 1-7 + 11 Write C++ code to:! Determine if a number is odd or even CS 2308 Spring 2013 Jill Seaman! Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Name: Email address: CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial

More information

15-122: Principles of Imperative Computation, Fall 2015

15-122: Principles of Imperative Computation, Fall 2015 15-122 Programming 5 Page 1 of 10 15-122: Principles of Imperative Computation, Fall 2015 Homework 5 Programming: Clac Due: Thursday, October 15, 2015 by 22:00 In this assignment, you will implement a

More information

CS 376b Computer Vision

CS 376b Computer Vision CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves

More information

CSE 332: Data Structures. Spring 2016 Richard Anderson Lecture 1

CSE 332: Data Structures. Spring 2016 Richard Anderson Lecture 1 CSE 332: Data Structures Spring 2016 Richard Anderson Lecture 1 CSE 332 Team Instructors: Richard Anderson anderson at cs TAs: Hunter Zahn, Andrew Li hzahn93 at cs lia4 at cs 2 Today s Outline Introductions

More information

CS 222: Linked Lists, Queues, Stacks

CS 222: Linked Lists, Queues, Stacks CS 222: Linked Lists, Queues, Stacks Chris Kauffman Week 7-2 Logistics Reading Ch 10 (Vector/List Data Types) Start finishing up exercises Homework 6 Up HWs reweighted, worth 7% each Due next Tue night

More information

Computer Science II CSci 1200 Test 1 Overview and Practice

Computer Science II CSci 1200 Test 1 Overview and Practice Computer Science II CSci 1200 Test 1 Overview and Practice Overview Test 1 will be held Tuesday, February 13, 2007, 2:00-3:30pm, West Hall Auditorium. No make-ups will be given except for emergency situations,

More information

CPSC 221: Algorithms and Data Structures Lecture #0: Introduction. Come up and say hello! Fibonacci. Fibonacci. Fibonacci. Fibonacci. (Welcome!

CPSC 221: Algorithms and Data Structures Lecture #0: Introduction. Come up and say hello! Fibonacci. Fibonacci. Fibonacci. Fibonacci. (Welcome! Come up and say hello! (Welcome!) CPSC 221: Algorithms and Data Structures Lecture #0: Introduction Kendra Cooper 2014W1 1 2 Fibonacci 0 + = Fibonacci 0 + = 1, 1, 2, 3, 5, 8, 13, 21, Definition: Applications,

More information

Learning Recursion. Recursion [ Why is it important?] ~7 easy marks in Exam Paper. Step 1. Understand Code. Step 2. Understand Execution

Learning Recursion. Recursion [ Why is it important?] ~7 easy marks in Exam Paper. Step 1. Understand Code. Step 2. Understand Execution Recursion [ Why is it important?] ~7 easy marks in Exam Paper Seemingly Different Coding Approach In Fact: Strengthen Top-down Thinking Get Mature in - Setting parameters - Function calls - return + work

More information

Section I B COMPUTER SCIENCE SOLUTION

Section I B COMPUTER SCIENCE SOLUTION Computer Science Foundation Exam December 17, 2010 Section I B COMPUTER SCIENCE NO books, notes, or calculators may be used, and you must work entirely on your own. SOLUTION Question # Max Pts Category

More information

CSCI 262 Data Structures. Arrays and Pointers. Arrays. Arrays and Pointers 2/6/2018 POINTER ARITHMETIC

CSCI 262 Data Structures. Arrays and Pointers. Arrays. Arrays and Pointers 2/6/2018 POINTER ARITHMETIC CSCI 262 Data Structures 9 Dynamically Allocated Memory POINTERS AND ARRAYS 2 Arrays Arrays are just sequential chunks of memory: Arrays and Pointers Array variables are secretly pointers: x19 x18 x17

More information