CSE 333 Sec(on Sec(on 8 Upcoming Important Dates Exercise 7 due - - PowerPoint PPT Presentation

cse 333 sec on
SMART_READER_LITE
LIVE PREVIEW

CSE 333 Sec(on Sec(on 8 Upcoming Important Dates Exercise 7 due - - PowerPoint PPT Presentation

CSE 333 Sec(on Sec(on 8 Upcoming Important Dates Exercise 7 due 11/20 @ 11:15 AM Homework 3 due 11/30 @ 11:59 PM Lecture 11/25 Op(onal Material No Class on 11/26 and 11/27 Standard Template Library C++s library for:


slide-1
SLIDE 1

CSE 333 Sec(on

Sec(on 8

slide-2
SLIDE 2

Upcoming Important Dates

  • Exercise 7 due 11/20 @ 11:15 AM
  • Homework 3 due 11/30 @ 11:59 PM
  • Lecture 11/25 Op(onal Material
  • No Class on 11/26 and 11/27
slide-3
SLIDE 3

Standard Template Library

  • C++’s library for:

– Containers (familiar data structures) – Iterators – Algorithms (such as sort and find)

  • Stored by value
slide-4
SLIDE 4

STL vector

  • Analogous to Java’s ArrayList

– Con(nuously stored memory – Dynamically size

  • Located in the <vector> package
  • Documenta(on @

h]p://www.cplusplus.com/reference/vector/vector/

slide-5
SLIDE 5

STL Iterator

  • Each container has an iterator
  • Common Opera(ons:

– Incremented with (++) – Copied – Copy Constructed

  • Addi(onal Opera(ons

– Dereferencing (LHS/RHS) – Decremented with (--) – Random Access

slide-6
SLIDE 6

Itera(ng over a vector

slide-7
SLIDE 7

Itera(ng over a vector (in reverse)

slide-8
SLIDE 8

Random Access Vector Iterator

slide-9
SLIDE 9

STL Algorithms

  • Func(ons used on range of elements
  • Range = sequence of items accessible through

iterators or pointers

  • Algorithms operate on values using assignment
  • r copy constructors
  • Useful Algorithms:

– find, count, binary_search, sort, transform, …

  • Documenta(on @

h]p://www.cplusplus.com/reference/algorithm/

slide-10
SLIDE 10

STL Algorithms on vector

slide-11
SLIDE 11

STL Algorithms on vector

slide-12
SLIDE 12

Sec(on Exercise

  • Func(on Signature:

vector<int> ProcessQuery(<list<list<string>> wordLists, list<string> query>);

  • Input:

wordLists - A list of lists of words. query - A list of words

  • Output:

The index of each word list that contains all the words in query sorted by decreasing matching word count. (This is similar to the part B6 of Homework 3)