Data Structures

CSI33      D01 (51433)

Monday, Wednesday, 12:00 pm-1:50 pm, room CP 320
 

 
Date Class Materials HW assignment
05/20

Final Exam


 
Weeks 15-16

Some interesting reads:
1) Pointers vs References:
http://www.cplusplus.com/articles/ENywvCM9/,
https://www.geeksforgeeks.org/pointers-vs-references-cpp/
https://www.geeksforgeeks.org/passing-by-pointer-vs-passing-by-reference-in-c/
2) Unique pointers (std::unique_ptr):
https://en.cppreference.com/w/cpp/memory/unique_ptr
http://www.cplusplus.com/reference/memory/unique_ptr/
 
05/15 Review

Final exam preparation slides

recording link

The due date for the Final Project is Friday, 11:59pm, May 22nd
Don't forget to review the Final Project Submission Guidelines.

We had 18 homeoworks in total.
5 of the lowest scores with be dropped! 

The Final Grade will be composed of:
Homeworks: 20%
Quizzes: 15%
Midterm Exam: 25%
Final Project: 20%
Final Exam: 20%


Our Final Exam is scheduled for Wendesday, May 20.
From 12 pm to 1:50pm.
It will be in the same format as ourMidterm Exam.
You must send me your answers by 2:30 pm on Wednesday, May 20th.
Make sure that you send everything to me by the 2:30pm!
 
05/13 Sections 14.1 - 14.4

Recording link

Lecture slides: CSI33-lecture27_part1.pdf, CSI33-lecture27_part2.pdf
Dikstra's example: DijkstrasExample.pdf
Breadth First Search implementation in C++: BFS.h, BFS.cpp, usingBFS.cpp, input1.txt

Breadth First Search Demonstration (you tube, ~9 mins): https://www.youtube.com/watch?v=EuwG9nk0VxQ

Dijkstra algorithm Demonstration (you tude, ~9 mins): https://www.youtube.com/watch?v=8Ls1RqHCOPw

A short (~2mins) but very nice video of depth first search algorithm application: https://www.youtube.com/watch?v=mE_PCK0oFyo

In-class Work: CSI33_Lecture27InClassWork.pdf
Solutions: CSI33_Lecture27InClassWorkSols.pdf
 
05/08 Section 13.3 in C++

Lecture slides: CSI33-lecture26.pdf

Meeting recording

programs (in C++): TreeNode.h, TreeNode.cpp, AVLTree.h, AVLTree.cpp, TestAVLTree.cpp
programs (from the book, in Python): TreeNode.py, AVLTree.py, helpForAVL.py

in-class work (with solutions):
CSI33-AVL-In-Class-Practice.pdf,
avl_handout-CSVirginiaEDU.pdf
 
Suggested exercises (for practice, not for grade):

1) Multiple-Choice questions: p. 481 / 10
2) Short-Answer Questions: p. 481 / 2
3) AVL trees (Short Answer questions): page 481 / 4-11,
Answers: Chapter13-AVL-answers.pdf
4) Look through the AVL code in Python and lecture slides - understand how the rotations are done. Finish up the AVL.py code.
Comments
: you can use the following code for testing/seeing what is happenning(just add it to your program) helpForAVL.py
5) Look through the AVL code in C++ thoroughly
 
05/06 Section 7.5 in C++

Lecture slides: CSI33-Lecture25.pdf

Meeting recording

programs (in C++):
TreeNode.h, TreeNode.cpp, usingTreeNode.cpp,
BST.h, BST.cpp, usingBST

Useful links:
BST delete node: http://www.algolist.net/Data_structures/Binary_search_tree/Removal
Insertion and deletion (6 mins video): https://www.youtube.com/watch?v=wcIRPqTR3Kc
Comment: deletion procedure here follows a different strategy: right subtree, leftmost element.

In-class work: see lecture slides
Suggested exercise (for practice, not for grade):

1) define the delete operation for BSTs in our C++ code (use Python's code)

2) define the reverse operation for BSTs (in C++ and in Python implementations) that will reverse the structure of the BST, i.e. for every node, all nodes in the left subtree have values greater than the value of the node; and all nodes in the right subtree have values less than the value of the node.
Week 14

You can see your class grades here

Updated office hours: Tuesdays, 4 pm - 5 pm and Fridays, 3 pm - 4 pm
 
04/29 Sections 13.3-13.5 in C++

Video Recording

Lecture slides: CSI33-Lecture24.pdf

programs (in C++): Heap.h, Heap.template, testingHeap.cpp,
mapUse.cpp
programs (from the book and not, in Python): Heap.py, usingHeap.py

C++ map reference: http://www.cplusplus.com/reference/map/map/

In-class Work: see lecture slides, files to use: PQueue_ideas.py
Answers/solutions: PQueue.py
HW19 (due date: Friday, 05/15):

(1) no programming exercicse
(2) ZyBook: HW 19

Suggested exercises (for practice, not for grade):

0) Look through the hash examples in Section 13.5
1) True/False questions: p. 478 / 1, 2
2) Short-Answer Questions: pp. 479 - 480/ 1, 2, 4, 5, 8, 9
3) In-class work
Answers: Chapter13-answers.pdf

Self-study:
HashLetter.py, test_HashLetter.py,
HashTable.py, test_HashTable.py,
HashTable2.py, test_HashTable2.py
 
04/27 Sections 12.1-13.2

Video recording

Lecture slides: CSI33-Lecture23.pdf
programs (from the book and not):
maximum.cpp, vec1.cpp, vec2.cpp, vec3.cpp
Stack.h, Stack.template, test_Stack.cpp

Reference manual for Vector class template: http://www.cplusplus.com/reference/vector/vector/

Algorithms library reference manual: http://www.cplusplus.com/reference/algorithm/

In-class Work:
1) Implement a template minimum function and test it on int and double type values.
Solution: minimumInClassWork.cpp

2) Implement a Queue using templates along with the code to test it. This is a suggested HW assignment.
Solution
: Queue.h, Queue.template, test_Queue.cpp
HW18 (due date: Monday, 05/11):

(1) Programming excercise: implement a template version of the average function (you may assume that we are planning to use it on the arrays of integers, floats and doubles only): averageFunction.cpp.
(2) Programming excercise: p. 442 / 3
Feel free to use these starters: TemplateList_forHelp.h, test_TemplateList.cpp
the header file has all the declarations you'll need, so you only need to add missing definitions;
the testing has a good enough testing code for you;
another suggestion would be to put all the definitions that are missing into the header file (after the class declaration and the cin and cout declarations), then you don't have to create a file with extension .template - it seems to be the better way.
(3) ZyBook: HW 18

Suggested exercises (for practice, not for grade):

1) True-False questions: p. 440 / 1, 2, 5

2) Multiple-Choice questions: p. 440-441 / 1, 2, 4

3) Programming exercise: p. 442 / 2
Solution: Queue.h, Queue.template, test_Queue.cpp
Answers: Chapter12questionsAnswers.pdf
Week 13

You can see your class grades here

My office hours: Mondays, 2 pm - 3 pm and Tuesdays, 1pm - 2pm
04/22 Sections 11.1 - 11.4

Video recording link: https://youtu.be/gdC5s6nrPUg

Lecture slides: CSI33-Lecture22.pdf

programs (from the book and not): ListNode.h, LList.h, LList.cpp, testLList.cpp

In-class Work: see lecture slides.
Solutions:
2) ListNode2.h, LList2.h, LList2.cpp, testLList2.cpp
3) to be posted
HW17 (due date: Friday, 05/08)

(1) Programming exercise: p. 424 / 2
    here is the code to check that your program works correctly: Chapter11-testLList2.cpp

(2) ZyBook: HW 17

Suggested exercises (for practice, not for grade):

1) True-False questions: p. 422 / 1, 2, 5

2) Multiple-Choice questions: p. 423 / 1, 2, 4

3) Short-Answer questions: p. 424 / 1, 2
Solutions: Chapter11questionsAnswers.pdf
04/20 Sections 10.4 - 10.5

Video recording: https://youtu.be/ivg5pp8WWzI

Lecture slides: CSI33-Lecture21.pdf

programs (from the book): List.h, List.cpp, testList.cpp, testList1.cpp, testListp.cpp
Check out this one as well: unsigned.cpp

In-class work: see lecture slides
Solution (only for cin): List2.h, List2.cpp, testList2.cpp
 

HW16 (due date: Monday, 05/04)

(1) Programming exercise: p. 400 / 4
see and use: mystring.h, mystring_draft.cpp, string_using.cpp

  reccomendations:
  1) Start with definitions of constructor, destructor, operator+=(const char c), resize and cout functions.
  2) Then add operator[], search/find, and reverse definitions.
  3) Conclude with definitions of copy constructor, assignment operator= (both of these operators can use private method copy), and operator+=(const String& str)input method is already defined in the files provided.  

(2) ZyBook: HW 16

Week 12

Summarize the data structures we explored so far with the run-time efficiency of common operations!!!

You can see your class grades here

My office hours: Mondays, 2 pm - 3 pm and Tuesdays, 1pm - 2pm
 
04/15 Sections 10.1 - 10.3

Meeting recording link: https://youtu.be/FA1aXaRJWOE
Lecture slides: CSI33-Lecture20.pdf
programs: Source.cpp
In-class work: see lecture slides

Answers:
1) we do have a memory leak, see the picture
2) program: CSI33Lecture20InClassWork.cpp

More practice with pointers: http://condor.depaul.edu/ntomuro/courses/309/notes/pointer_exercises.html
HW15 (due date: Thursday, 04/30)

1) Short-Answer questions: p. 399 /5, 6

2) ZyBook: HW 15

Suggested exercises (for practice, not for grade):
1) True-False questions: p. 396 / 3, 4,
2) Multiple-Choice questions: p. 397 / 1, 2, 3, 5
Solutions: Chapter10-questionsAnswers_part1.pdf
04/13 Sections 9.4 - 9.5

Lecture slides: CSI33-Lecture19.pdf

Video recording: https://youtu.be/Dn8xGlfbtDE

programs (from the book):
mainv1.cpp, Rationalv1.cpp, Rationalv1.h;
Rationalv2.h, Rationalv2.cpp, mainv2.cpp;
Rationalv3.h, Rationalv3.cpp, mainv3.cpp;
Card.h, Card.cpp, using_Card.cpp

in-class work solution: (with counter_ placed in the private section):
Card-InClassWork.h, Card-InClassWork.cpp, using_Card2.cpp
 
HW14 (due date: Monday, 04/27)

1) Programming Exercise: p. 352 / 3
Use this code to test your program: Rational_testing.cpp

2) ZyBook: HW 14

Suggested exercises:

1) Short Answer questions: page 351/4
Answers to some of the True/False and Multiple Choice questions from Chapter 9: Chapter9-questionsAnswers.pdf
2) Define a Complex Number class using rectangular form of complex numbers, i.e. any complex number is r+mi, where r and m are real numbers and i is imaginary unit). Recall that i2 = -1.

The class should have +, -, and * binary operations defined.

Here are examples of operations:
(2+3i)+(9-7i) = 11-4i
(2+3i)-(9-7i) = -7+10i
(2+3i)*(9-7i) = 18-14i+27i-21i2 = 18+21+13i = 39 + 13i 
Week 11

April 8-10 Spring Break. Stay well and safe!

 
04/06 Sections 8.17, 9.1-9.3

Video recording link: https://youtu.be/oFcTJBPQgDc


Reference manual to C++ string class: http://www.cplusplus.com/reference/string/string/

comparison of C-strings and C++ strings: http://cs.stmarys.ca/~porter/csc/ref/c_cpp_strings.html

Lecture slides: CSI33-Lecture18.pdf

programs (from the book):
Rational.cpp, Rational.h, MainProg.cpp;
RationalOldStyle.cpp;
stringex.cpp, getline.cpp, readfile.cpp

Announcements:
(1) We will have access to the online book at zyBook for our class (the price of access is $0). Here are the instructions:
1) Sign in or create an account at learn.zybooks.com
2) Enter zyBook code: CUNYCSI33NovakSpring2020
3) Subscribe
A subscription is $0. Students may begin subscribing on Mar 19, 2020 and the cutoff to subscribe is May 27, 2020. Subscriptions will last until Jun 14, 2020.

(2) According to BCC Academic Calendar, April 7th, Tuesday follows Wednesday shedule. However, we will not meet. Have some time to yourselves, have some rest!

(3) The Final Exam projects will be distibuted this week.
 
HW13 (due date: Wednesday, 04/22)

1) Read sections 9.1-9.3, and go through the True/False questions 1-13, and multiple choice Questions 1-6 (not for submission),
2) Write a program that reads a collections of values (decimal numbers) from the input file and
- finds the smallest value,
- find the greatest value,
- finds the average of all values,
- finds the average of all positive values,
- finds the average of all negatice values,
- reports how many zeros,
- reports how many positive values are in the file,
- reports how many negative values are in the file,
- sorts them and stores the sorted collection of values in an output file.

All the information (except for the sorted collection) should be displayed on the screen. Each item above (finding smallest value,etc.) should be defined as a function.

3) ZyBook:
HW 13 Part 1 (due April 21st) and Part 2 (due April 26th) are mandatory;
HW 13 Part 3 Optional is optional, if you want to get more points (due May 11th)
Week 10

You can see your class grades here

My office hours: Mondays, 2 pm - 3 pm and Tuesdays, 1pm - 2pm

 
04/01 Sections 8.12-8.17

Video recording
link: https://youtu.be/Q0-7K1aF-Kc

Lecture slides: CSI33-Lecture17.pdf

programs (from the book):
conversions.cpp, conversions.h, conversions2.h;
macro.cpp;
reference.cpp;
scope.cpp;
selection.cpp

Extra practice: CSI33_Day17_InClassWork.pdf
Solution: functions.h, inClassWork17.cpp
 
HW 12 (due date: Friday, 04/17)
1) Read about macros on page 302 and see example (macro.cpp)

2) read sections 8.17.2 and 8.17.3

3) programming exercise: page 317/ 8-9 (do it in one program)
test code and header for your programs: searches.h, test_searches.cpp


Suggested exercises:
(for practice, not for grade):

1) Read chapter 8 and look through the True/False and Multiple choice questions of Chapter 8

2) Use our Python code (mergeSort.py) and write the definition of Merge Sort. Use the following files to put Selection sort (selection.cpp) and Merge sort into: sort.h, sort.cpp, and then use these ones to test them: test_sort.cpp, test_sort2.cpp.

 
03/30 Sections 8.8-8.11, 8.14, 8.17.1


If you were not able to join the meeting, see the recording of it.
Video recording of the meeting
: https://youtu.be/2aY7WbgWJ_k

Lecture slides:CSI33-lecture16.pdf

programs (from the book): grades.cpp, if1.cpp, if2.cpp, if3.cpp, typeConvs.cpp, loopExample1.cpp, buffer.cpp, str1.cpp,
switchWithAssert.cpp, switch.cpp, switch2.cpp, switch3.cpp;

Here is a link to C-string vs C++ string: http://cs.stmarys.ca/~porter/csc/ref/c_cpp_strings.html


Extra practice: CSI33Day16InClassWork.pdf
Solution: CSI33-Day16-InClassWork2.cpp 
HW 11 (due date: Wednesday, 04/15)
2) programming exercises: page 316/ 1, 2, 3, 4, 6

for programming exercise 2, here is the link to the slides that give the algorithm for it (starting from slide 53): CSI30-Ch3Section1part2.pdf

Instructions on how to work with Visual Studio:
1) Create a project:
    File -> New -> Project...
choose Visual C++ (on the left) Empty Project (on the right),
below: change the Name of the project and change the Location of the project.
it will take from few seconds to a couple of minutes to create a project ... wait
2) to add a file to you project:
find a panel on your right (called Solution Explorer) - you should see your project name there with a bunch of folders like Source Files, Resource Files, Header Files, ...
right click on the Source Files -> Add -> New Item
Choose Visual C++ (on the left) and C++ File (.cpp) (on the right),
don't foget to change the name of the file below (if you want it changed)
A window will open in the middle of the screen - you are ready to type the C++ code!
3) The following steps are to keep the console window open when you are running your program (otherwise it will be closed fast): In the Solution Explorer Panel (on your right): right click on your Project name (a menu will pop-up)
choose Properties (at the very bottom) -> then click on the triangle to the left of Linker -> then choose System -> then on the right, at the very top, click on the SubSystem and in the drop-down menu for this item choose Console (...). Click OK!

Congratulations! You are all set!

To compile and run your program / project hit Ctrl F5 or go to menu (on top) Debug -> Start Without Debugging.
Week 9

Summarize the data structures we explored so far with the run-time efficiency of common operations!!!

You can see your class grades here
Use the last 4 digits of your school ID to find your record  
Note that there are two pages: one with the HWs grades and one with the quizzes scores.

There will be no Midterm Grades !!!
 
03/25 C++ is coming to our classroom!

Sections 8.1-8.7

Recording of the meeting
link: https://us-lti.bbcollab.com/recording/7291e01bf2974bb8b507c5213fb0fb4e

Lecture slides: CSI33-lecture15.pdf

programs (from the book): ctof.cpp, swap.cpp, increment.cpp, uninit.cpp

In-class work: see lecture slides
Solutions: FtoC.cpp, CSI33-Day15-InClassWork.cpp

Software:
1) We have Microsoft Visual Studio installed on all computers at CP 320.
Choose Community Edition (free) at download from :
https://visualstudio.microsoft.com/vs/features/cplusplus/

If you are using Apple computers, grab Visual StudioCode with all instructions here:
https://www.freecodecamp.org/news/how-to-compile-your-c-code-in-visual-studio-code/

2) Code Blocks (for all platforms, free): http://www.codeblocks.org/downloads/26

3) JetBrains CLion
It is free, but you will have to apply for it with your school e-mail. The confirmation will be sent to your e-mail immediately. Then you can proceede to the download page and get CLion.

https://www.jetbrains.com/student/
 
Not for grade (due date: Wednesday, 03/27)
1) Install a C++ compiler on your home computer,
2) Read the beginning of Section 8.2 (pages 256-257),
3) Run all the programs from the lecture.

03/23 Midterm Exam

 
Week 8 - instructional recess for distance-learning preparation
March 12 - March 18th


03/18 Video session: Midterm Exam Sample

Blackboard Collaborate link: https://us.bbcollab.com/guest/e85cc6dd6b534dc5a81f2d15ab84f03a
(use it to join the video session)

instructions:
1) join the session 5-10 minutes in advance, look around for the tools that are available to you!
2) when you join the session, both microphone(share audio) and camera(share video) are turned off. So if you want to ask the question, make sure you turn the audio on.
3) you can also join these video meetings when you log-in into our Blackboard page.

    I'm planning to go over the following:
    Midterm Exam Sample: MidtermExample_CSI33_Sample.pdf
    Library and Patron (answer to the question from the Midterm Exam Sample): LibraryPatrons.py, Library-PatronsTesting.py

    In-class practice: CSI33MidtermExamInClassPractice.pdf
    In-class practice answers: CSI33MidtermExamInClassPracticeAnswersAndSolutions.pdf

Slides from the meeting: MidtermExamSampleSlides.pdf
Recorded Video of the Meeting (beware, it is long!!!): https://us-lti.bbcollab.com/recording/2100024add0342a49e296859585f7e9d

Videos of coding questions' solutions from the Midterm Exam Sample:
Question 1: idea (YouTube video, ~6 mins), code (YouTube video, ~8mins)
Question 2: Patron and Lbrary (YouTube video, ~ 27 mins)
03/13 Dear All,
The classes will resume on Thursday, March 19th in a distance-learning form. However, we will have our first online meeting on Wednesday, March 18th (see below)!

During this recess, please prepare for the Midterm Exam! The new date is Monday, March 23rd, the format will be posted.

Visit the Midterm and Final Exams page to prepare for the Midterm Exam. Do not delay preparation! Work on it now!

Planned meetings for the next two weeks:
Wednesday, March 18th, 12 pm - 2 pm.
    Online meeting. I will invite you to Blackboard Collaborate. You don't need to log-in to Blackboard. I will just post a link here. Follow it.
    If you have any questions about the review problems, this is the moment to ask them!

    I'm planning to go over the following:
    Midterm Exam Sample: MidtermExample_CSI33_Sample.pdf
    Library and Patron (answer to the question from the Midterm Exam Sample): LibraryPatrons.py, Library-PatronsTesting.py

    In-class practice: CSI33MidtermExamInClassPractice.pdf
    In-class practice answers: CSI33MidtermExamInClassPracticeAnswersAndSolutions.pdf

Monday, March 23rd, TIME TBA
    Midterm Exam, the format will be posted (I'm working on it)

All your grades are and will be available at Google Sheets
Week 7

Summarize the data structures we explored so far with the run-time efficiency of common operations!!!

Now you can see your class grades here
Use the last 4 digits of your school ID to find your record  
Note that there are two pages: one with the HWs grades and one with the quizzes scores.

The Midterm Grade will be composed of:
HWs (6 best scores out of 9 are averaged): 60%,
Midterm Exam: 40%
 
03/11 Section 7.5

Lecture slides: CSI33-Lecture13.pdf

programs (from the book): TreeNode.py, BST.py
other programs: usingBST.py

Useful links:
BST delete node: http://www.algolist.net/Data_structures/Binary_search_tree/Removal
Insertion and deletion (6 mins video): https://www.youtube.com/watch?v=wcIRPqTR3Kc
Comment: deletion procedure here follows a different strategy: right subtree, leftmost element.

In-class work: see lecture slides
Solutions: CSI33Leture13InClassWorkSols.pdf, InClassWorkDay13.py
 
HW10 (due date: Sunday, 03/22)
1) programming exercises:
p. 248 / 2, 3, 5
Test code you can use for these problems: TestCodeForHWAssignment.py

2) Write unit tests for class BST to test insert_rec and find method, by doing the following:
Insert the following elements, one by one into a tree: 7, 3, 8, 2, 5, 9, then by using BST's method asList compare the produced by that method list with list [2,3,5,7,8,9] - this is one unit test for insert_rec method.
To test the find method: create the same BST as above, and find 8, 2, 9, and 5; compare the result with the numbers themselves. Then try to find 11, 1, and 4 and compare the result of each search with None.

Suggested exercises (not for grade):
1) Short Answer questions: p. 248 / 2, 3, 4
Solutions: Chapter7-questionsAnswers.pdf
03/09 Sections 6.6, 7.1-7.4

Quiz 4 is based on Sections 4.1, 4.2 and Chapter 5

Lecture slides: CSI33-Lecture12.pdf
,
programs (from the book): TreeNode.py

In-class work: CSI33_Day12_InClassWork.pdf
Answers: CSI33Lecture12pics.pdf

Useful links: check out the online Tower of Hanoi puzzle
Suggested exercises (not for grade):
1) True-False questions: p. 245 / 1-5
2) Multiple-Choice questions: p. 246 / 2, 3
3) Short-Answer questions: p. 248 / 6

Solutions: Chapter7-questionsAnswers.pdf
Week 6

Summarize the data structures we explored so far with the run-time efficiency of common operations!!!

Midterm Exam will be on Wednesday, March 18th
See materials for preparation to the Midterm Exam in Midterm and Final Exams.  
03/04 Sections 6.1-6.5

Lecture slides: CSI33-Lecture10-11.pdf

You can watch a video on Merge Sort here: http://en.wikipedia.org/wiki/Merge_sort

programs (from the book): fact.py, reverse.py, anagrams.py, power.py, bsearch.py
programs (from the book): fib.py, selectionSort.py, mergeSort.py, hanoi.py

In-class work: see lecture slides
Solutions/answers: maxRec.py
HW 9 (due date: Friday, 03/13)

programming exercises: p. 215 / 1, 5

Suggested exercises:
(for practice, not for grade):
1) What list is returned by anagrams("word")?
2) True-False questions: p. 212 / 1, 2, 3, 6
3) Multiple-Choice questions: p. 213 / 1, 4, 5, 6
4) Trace recPower(4,8) and and figure out exactly how many multiplications it does.
5) Short Answer questions: p.214 / 1, 5

Solutions: Chapter6Answers_part1.pdf, Chapter6Answers_part2.pdf
 
03/02 Sections 5.3-5.5

Lecture slides: CSI33-lecture09.pdf

programs (from the book): MyQueue.py, palindrome.py

In-class work: see the lecture slides, CabCompany.pdf, TestingCab.py
Solution: CabCompany.py

Self-study:
time-driven simulation: simulation.py, CheckerSim.py
Event-driven simulation: simulationEventDriven.py, CheckerSimEventDriven.py
 
HW 8 (due date: Monday, 03/09)

programming exercise: p. 184 / 4
Week 5

Now you can see your class grades here
Use the last 4 digits of your school ID to find your record  
Note that there are two pages: one with the HWs grades and one with the quizzes scores.
 
02/26 Sections 5.1-5.2

Lecture slides: CSI33-lecture08.pdf

programs (from the book): Stack.py, parensBalance2.py

In-class assignment: see lectures slides.
Solutions/answers: In-classWorkAnswers.pdf, Stackunittesting.py

Quiz 3 will be based on Sections 3.5, 3.6, 4.1, and 4.2

Check out these useful videos:
Infix to Postifx:
https://www.youtube.com/watch?v=rA0x7b4YiMI
Infix to Prefix:
https://www.youtube.com/watch?v=fUxnb5eTRS0
 
HW 7 (due date: Thursday, 03/05)
programming exercise: p. 184 / 3 (use Stack to evaluate the post-fix expression as shown in lecuture slides)

Suggested exercises:
1) True-False questions: p. 181 / 1-4
2) Multiple-Choice questions: p. 182 / 1-5
3) Short-Answer questions: p. 183 / 1

Answers/Solutions: Chapter5-questionsAnswers-part1.pdf, Chapter5-questionsAnswers-part2.pdf
02/24 Sections 4.4 - 4.5, 4.7

Lecture slides: CSI33-lecture07.pdf

Programs: ListNode.py, LList.py

In-class work: see the last slide in the lecture slides
Solutions: Section4_6InClassWork.py (work with LList),
Fibonacci numbers generator (2 versions): Section4_6InClassWorkGenerator.py, Section4_6InClassWorkGenerator.py
Which version do you like better?
HW 6 (due date: Monday, 03/02)
programming exercises: p. 152 / 1, 3 (do both in one file, LList.py)

Suggested exercises:
1) True-False questions: p. 148 / 1, 2, 4, 5
2) Multiple-Choice questions: p. 149 / 1-4
3) take a look at two versions of __copy__ method for LList class's implementation on page 132.
Solutions/answers: Chapter4-questionsAnswersSuggestedProblems.pdf
Week 4

Note that on Wednesday, February 12th the college is closed - Lincoln's birthday
on Monday, February 17th the college is closed - President's day

 
02/19 Sections 4.2-4.3

Quiz 2 today

Lecture slides: CSI33-lecture06.pdf

Programs: Section4_2example.py, ListNode.py
For in-class work: Sections4_1-4_3InClassWork.py, Section4_2example2.py

In-class work: see lecture slides (the last two slides) and use this file: problems1-2
Answers:
    problems 1-2: ListNode_classwork.py, Sections4_1-4_3InClassWorkProblems1-2.py;
    problems 3-4: In-classWorkProblems3_4.pdf

Very useful read about classes, namespaces and many more: https://docs.python.org/3/tutorial/classes.html
HW 5 (due date: Wednesday, 02/26)

Programming assignment: Let's think about doubly-linked lists. Define a class ListNode2, with three attributes: item, leftL, and rightL.
Left link points to the previous node in the list, right link points to the next node in the list.
You can also add the display method to this class (like we did it in class for the ListNode class).
Then test your class.
For example, create a linked list of 5 values: 34, 1, 23, 7, and 10. Display it. Then insert new value, say 8 between 34 and 1 (this time you will have to take care of links pointing to the previous and next node), display the resulting list. Then delete an element, say 7, update the links and display the new list.
Use this draft: ListNode2_forStudents.py


Suggested exercises
(not for grade, but highly recommended):
1) Short-Answer questions: p. 151 / 2
Answers: Chapter4-questionsAnswers.pdf
02/17 college is closed - President's day  
Week 3

Note that on Wednesday, February 12th the college is closed - Lincoln's birthday
on Monday, February 17th the college is closed - President's day

 
02/12 college is closed - Lincoln's birthday  
02/10 Sections 3.5-3.6

Lecture slides: CSI33-lecture05.pdf
HW2 discussion: SelectionSortAnalysis

Here is a link to time-complexity (aka "Big O" or "Big Oh") of various operations in current CPython: https://wiki.python.org/moin/TimeComplexity

Quiz 2 will be on Wednesday, February 19th and will be based on Chapters 2 and 3.
HW 4 (due date: Wednesday, 02/19)
programming exercise: p. 104 / 9
See suggested specification with some code here:
a simple version (do not store the contents of each pile, only the top card): Chapter3-prog9SolitaireSpecs-easy.py


Suggested exercises
(not for grade, but highly recommended):
1) True-False questions: p. 100 / 8, 12
2) Multiple choice questions: p. 101 / 1, 3, 4, 5, 6, 8
3) Short-answer questions: p.102 / 3

Solutions: Chapter3-questionsAnswers-part1.pdf, Chapter3-questionsAnswers-part2.pdf

Week 2
 
02/05 Sections 3.1-3.4

Quiz 1 today (based on Chapter 1)

Lecture slides: CSI33-lecture04.pdf

On this page you can find the link to the compressed file with all the codes from the book:
http://www.fbeedle.com/content/data-structures-and-algorithms-using-python-and-c

more programs (from the book):
CardADT.py,
Card.py (different from previous lecture meeting), Deck.py, Hand.py, TestDeck.py, TestCards.py

If you want to find out how to play Bridge:
rules: http://www.acbl.org/learn_page/how-to-play-bridge/
video: https://www.youtube.com/watch?v=Tyd7KlsRYO4
another video: https://www.youtube.com/watch?v=9yzS_26fICk

In-class work: see lecture slides (last few slides)
Solutions: in-classWork.py 
HW 3 (due date: Wednesday, 02/12)

1) Finish implementing the program discussed in class (in-class work, second assignment).
comment: note that at this level you should define classes (for example, for player, for scoring and so forth) where appropriate, also don't forget documentation (both inner comments that start with # and docstrings)! The program must use the classes Card and Deck we defined in class.

2) Programming Exercises: p 103 / 1, 2, 3- all of these exercises should be implemented in one file Deck.py
Test all the operations, send the tests with your HW submission!


Suggested exercises
(not for grade, but highly recommended):
1) True-False questions: p. 100 / 2, 3, 6
2) Short-answer questions: p.102 / 1, 2

Solutions: Chapter3-questionsAnswers-part1.pdf
02/03 Sections 2.1-2.3, and 2.6 from the book.

Lecture slides: CSI33-lecture03.pdf

Programs:
cardADT.py, test_cardADT.py,
Card-spec.py,
Card.py, testCard.py, unitTestingCard.py

Two questions we started our class with: estimate the run-time complexity of the following blocks of code:
1. # n is a positive integer
s = 0
for i in range(n):
      for j in range(10):
            s += 1

2. # the program finds a square root of n, if the answer is an integer value:
n = int(input("Enter a positive integer:"))
assert n >= 1
i = 1
while i * i <= n:
      if i * i == n:
            return i
      else: i+= 1
return "not an integer"

In-class work: start working on the HW assignment
HW 2 (due date: Monday, 02/10)

Write unit tests to test the methods suit, suitName and rankNameof Card class

See the Chapter2-unitTestingCardHW.py

Week 1
 
01/29 Section 1.3 Algorithm Analysis

Lecture slides: CSI33-lecture02.pdf

Additional materials: BinarySearchIllustrated.pdf

We watched a video about O, Ω, and Θ notations: https://youtu.be/6Ol2JbwoJp0

Additional resources: Check out this simple explanation of big-O notation:
https://medium.freecodecamp.org/big-o-notation-simply-explained-with-illustrations-and-video-87d5a71c0174

In-class work: lecture02InClassPractice.pdf
Solutions: lecture02InClassPracticeSols.pdf
HW 1 (due date: Wednesday, 02/05):

1) True/False questions: p. 33 / 4-6, 9, 10 - not for grade
2) Multiple Choice questions: pp.34-35 / 1-6, 10 - not for grade

Solutions: Chapter1solsTFMConly.pdf

3) Short-answer questions: p. 36 / 8 - not for grade
Solution: Chapter1ShortAnswerQuestions.pdf

4) Write a program that has both Linear Search and Binary Search algorithms implemented defined as two seprate functions.
Run each of the algorithms on the list of integers from 0 to 999999 and time them on three different numbers to search for: 10, 499999, and 999999. At the end your program should print the results.
Here is a draft/skeleton of the program: hwAssignment-twoSearches.py

5) Programming Exercises: p. 37-38 / 3, 9
Comments:
* Programming exercise 3 asks you to implement Selection Sort algorithm.
See my comments here: here and
video (about 10 mins) presenting visualization of Selection Sort: https://www.youtube.com/watch?v=f8hXR_Hvybo

* In programming exercise 9 you are not to use the built-in set type.

Reminder: don't forget to put specification for each of the functions you are defining as well as to use internal comments (that start with #)
01/27 Sections 1.1, 1.2

Lecture slides: CSI33-lecture01.pdf

In-class work: lecture01-handout.pdf
Solutions: lecture01-handoutSols.pdf

Announcements:
First two chapters of the book are available through e-reserves:
http://bcc-cuny.libguides.com/er.php?b=c
Choose CSI33 from the list
HW 0 (due date: Friday, 01/31):
1) read Sections 1.1-1.2

2) read about docstring conventions at http://www.python.org/dev/peps/pep-0257/

3) get the book