Data Structures

CSI33     D01 (61239)

Monday, Wednesday, 2:00 pm-3:50 pm, room CP 320
 

 
Date Class Materials HW assignment
12/21 Final Exam, 4 pm - 5:50 pm, at CP 320

Some interesting reads for the summer:
1) Finish Chapter 14 and do Chapter 15 from our textbook
2) 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/
3) Unique pointers (std::unique_ptr):
https://en.cppreference.com/w/cpp/memory/unique_ptr
http://www.cplusplus.com/reference/memory/unique_ptr/

12/14 Final Exam preparation

12/12 Sections 14.1 - 14.4

Terminology review (from CSI 35): CSI33-lecture24.pdf
Lecture slides: CSI33-lecture24.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_Lecture24InClassWork.pdf
Solutions: CSI33_Lecture24InClassWorkSols.pdf
   
12/07 Section 13.3

Lecture slides: CSI33-lecture23.pdf

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
 
12/05 Sections 13.3-13.5 in C++

Lecture slides: CSI33-Lecture22.pdf

programs (in C++): mapUse.cpp,
programs (from the book and not, in Python): HashLetter.py, test_HashLetter.py

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

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: starts on page 471
HashTable.py, test_HashTable.py (demonstrates hash table using chaining),
HashTable2.py, test_HashTable2.py (demonstrates hash table using open addressing with linear probing)
11/30 Sections 13.1-13.2 Priority queues and heaps

Lecture slides: CSI33-Lecture21.pdf

programs: Heap.py, usingHeap.py,
Heap.h, Heap.template, testingHeap.cpp

In-class Work: see lecture slides, files to use: PQueue_ideas.py
Answers/solutions: PQueue.py C++ map reference: http://www.cplusplus.com/reference/map/map/

Quiz 6 is based on topics discussed on November 14th meeting, Chapter 12
HW11 (due date: Friday, 12/09) - last HW assignment
1) programming exercises: p. 248 / 2, 3, 5 - you can do in C++ or in Python versions, it is your choice
Python test code you can use for these problems: TestCodeForHWAssignment.py, for C++ use a similar one

2) define the reverse operation for BSTs 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.

Suggested exercises (for practice, not for grade):
1) Short Answer questions: p. 248 / 2, 3, 4
Solutions: Chapter7-questionsAnswers.pdf
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.
3) Think of implementation of BST in C++. You can also start working on it.
Here is a suggested implementation: TreeNode.h, TreeNode.cpp, usingTreeNode.cpp,
BST.h, BST.cpp, usingBST
4) define the delete operation for BSTs in the C++ code given above (use Python's code)


11/28 Sections 7.5
in-person meeting

Lecture slides: CSI33-Lecture19.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: CSI33Leture19InClassWorkSols.pdf, InClassWorkDay13.py

Quiz 6 is based on topics discussed on November 14th meeting, Chapter 12 - moved to Wednesday
 
  Thursday , November 24th - Sunday, November 27th,Thanksgiving



You can see all your grades in this Google Spreadsheet.
Look into the row with the last four digits of your CUNY First ID (EMPLID).
11/23 No meeting today

Quiz 6 will be on Monday, at the end of the meeting, and will be based on topics discussed on November 14th meeting, Sections 12.1 - 13.2
11/21 Sections 6.4-6.6

Lecture slides: CSI33-Lecture17.pdf
programs (from the book): mergeSort.py, hanoi.py

meeting recording

Reminder: make sure you go over the materials places for the meeting on November 7th, as our next class will assume the knowledge of Sections 7.1 - 7.4

Useful links: check out the online Tower of Hanoi puzzle

You can watch a video on Merge Sort here: http://en.wikipedia.org/wiki/Merge_sort
Suggested exercises (not for grade):
1) Use our Python code (mergeSort.py) and write the definition of Merge Sort in C++, define it is a template function. Test it.
2) You can compare the running times of the Selection sort (selection.cpp) and Merge sort (use the definition you wrote and tested). You can put the code of both procedures in one header file, say sort.h, and then use them: test_sort.cpp, test_sort2.cpp.
Summarize all the data structures we explored so far with the run-time efficiency of common operations!!!

You can see all your grades in this Google Spreadsheet.
Look into the row with the last four digits of your CUNY First ID (EMPLID).
11/16 Sections 6.1-6.3

Lecture slides: CSI33-Lecture16.pdf
programs (from the book): fact.py, reverse.py, anagrams.py, power.py, bsearch.py, fib.py
In-class work: see lecture slides
Solutions/answers: maxRec.py

meeting recording

Quiz 5 today, based on Sections 5.3 - 5.5

Quiz 6 will be next Wednesday, and will be based on topics discussed on November 14th meeting, Sections 12.1 - 13.2
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
6) programming exercises: p. 215 / 1, 5
Solutions: Chapter6Answers_part1.pdf, Chapter6Answers_part2.pdf
 
11/14 Sections 12.1-13.2

Lecture slides: CSI33-Lecture15.pdf
programs (from the book and not):
maximum.cpp, vec1.cpp, vec2.cpp, vec3.cpp
Stack we defined before: Stack.h, Stack.cpp, StackTesting.cpp
Template class Stack: Stack.h, StackTesting.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, testingQueue.cpp
HW10 (due date: Wednesday, 11/23):
(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): average.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 a good way.

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, testingQueue.cpp
Answers: Chapter12questionsAnswers.pdf
11/09 Sections 5.3-5.5

Lecture slides: CSI33-lecture14.pdf

programs (from the book): MyQueue.py, palindrome.py , C++ versions will be done in the next class meeting

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 

Quiz 4 today, based on Sections 5.1 - 5.2
HW 9 (due date: Thursday, 11/17)
programming exercises:
1) p. 184 / 3 (use Stack to evaluate the post-fix expression as shown in lecuture slides), and
2) p. 184 / 4 (make sure to pay attention to all requirements in this exercise)

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
11/07 nobody came to class.
Self-study assignment: read Sections 7.1 - 7.4 from textbook

You may also find these materials helpful:
Lecture slides: CSI33-Lecture18.pdf
programs (from the book): TreeNode.py
In-class work: CSI33_Day18_InClassWork.pdf
Answers: CSI33Lecture18pics.pdf
Suggested HW assignment (not for grade, but the knowledge will be tested):
1) Recall singly linked lists (in both, Python and C++), i.e. every ListNode instance has two attributes: item and link. Define a method reverse() of LList class (in either Python or C++ implementations of our LList class), that would reverse the list.
Here is an example (click on the picture to see it at a higher resoution):


2) True-False questions from Chapter 7: p. 245 / 1-5
3) Multiple-Choice questions from Chapter 7: p. 246 / 2, 3
4) Short-Answer questions from Chapter 7: p. 248 / 6


Solutions: Chapter7-questionsAnswers.pdf
Summarize all the data structures we explored so far with the run-time efficiency of common operations!!!

You can see all your grades in this Google Spreadsheet.
Look into the row with the last four digits of your CUNY First ID (EMPLID).
11/02 Sections 5.1-5.2

Lecture slides: CSI33-lecture13.pdf

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

In-class assignment: see lectures slides.
Solutions/answers: In-classWorkAnswers.pdf, Stackunittesting.py
Quiz 3 at the end of the class today, based on linked lists (in both, Python and C++).


Announcements:
1) our Final Exam is scheduled for Wednesday, October 21st, 4pm - 5:50pm, at CP 320.
2) Quiz 4 next week on Wednesday, will be based on Sections 5.1 - 5.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

Suggested exercises:
1) Implement the balanced parentheses check in C++
10/31 Topic: linked lists in Python and C++
Sections 11.1-11.5 (C++)
Plan: today we will work on C++ implementation of linked lists

Lecture slides: CSI33-lecture12.pdf

Programs to use: ListNode.py, LList.py, testingLList.py,
Final Result: ListNode.h, LList.h, LList.cpp, testLList.cpp

Additional practice:
1) define cout operator<< for the linked list implementation in C++
A solution: LList2.h, LList2.cpp, testList2.cpp
2) Prepare a table of time complexities of operations of LList class we defined.

After class comments:
We went through the lecture sldides and started working on the ListNode.h, LList.h, LList.cpp and testingLList.cpp.
We had majority of the methods defined, but some other ones are not. You are to look over the Final result code (see above) for all the remaining methods, and also look at the overloaded cout operator<< for the output of LList objects - see item 1) in Additional practice.

Quiz 3 on Wednesday, based on linked lists (in both, Python and C++).
HW 8 (due date: Thursday, 11/10)
Programming exercise: p. 424 / 2
You can use this code to check that your program works correctly: Chapter11-testLList2.cpp. Feel free to add additional tests.
Note that you are to work on our C++ source files. Modify, add methods, etc, but not start from scratch.

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
10/26 Last online meeting
Topic: linked lists in Python and C++
Sections 4.4, 4.5, 4.7 (Python)

Lecture slides: CSI33-lecture11.pdf

Programs: ListNode.py, LList.py, testingLList.py

In-class work: see the last slide in the lecture slides
Solutions: Section4_4InClassWork.py (work with LList),
Fibonacci numbers generator (2 versions): Section4_5InClassWorkGenerator.py, Section4_5InClassWorkGenerator.py
Which version do you like better?

Quiz 2 at the end of the class today
HW 7 (due date: Thursday, 11/3)
programming exercises: p. 152 / 1, 3 (do both in one file, LList.py)
you can use this test code to test your program: Chapter4-prog1_3LList-testing.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
10/24 Online meeting
Topic: linked lists in Python and C++
Sections 4.1-4.3 (Python)

Quiz 2 on Wednesday, October 26th, based on Sections 3.31, 3.2, 3.5, 3.6, 10.4, and 10.5 - the ones we covered last week, at Blackboard.
Note that the quiz is timed and can be taken only once.

Lecture slides: CSI33-lecture10.pdf
class meeting recording

Programs: Section4_2example.py, ListNode.py, LList (not finished)

After class work: see lecture slides 14 and 15
1. we did this one in class
2. Work on it, here is a sketch you can use: InClassWorkHelp-problem2.py
and here is a possible solution to it: InClassWork-problem2Answer.py
3. the answer can be found in this file: In-classWorkProblems3_4.pdf
4. Here is the file for it: InClassWorkHelp-problem2.py
And a possible answer can be found in this file: In-classWorkProblems3_4.pdf
5. Here is the file for it: Section4_2example.py
And a possible answer can be found in this file: In-classWorkProblems3_4.pdf

Very useful read about classes, namespaces and many more: https://docs.python.org/3/tutorial/classes.html
 
Suggested exercises
(not for grade, but highly recommended):
1) Short-Answer questions: p. 151 / 2
Answers: Chapter4-questionsAnswers.pdf
2) Complete all the in-class work
10/19 We will be meeting online, via Zoom meeting today

Sections 10.4, 10.5

Lecture slides: CSI33-lecture08-part2.pdf (we will continue implementaiton of List class in C++)

programs that we finished in class: List.h, List.cpp, testingList.cpp


Additional resources:
CPython List operations time complexity: https://wiki.python.org/moin/TimeComplexity

After class comments:
I didn't record the entire class meeting, but here is the recording of the friend method announcements (overloading output operator) and removal of "duplicate code".
HW 6 (due date: Thursday, 10/27)

Let's work on Rational class in C++. We will not need dynamical memory allocation, as rational numbers can be represented at fractions, a/b, where a in integer value and b is a non-zero integer value. Some part of the class definition is already in place. Grab these files and look through them thorougly: Rational.h, Rational.cpp, testingRational.cpp.
You will see that the constructor, the copy constructor, the operation + and comparison operation < are defined, along with helper-methods. Note that operation + is defined as member method/function, and the comparison operation < is defined as standalone method.

You are to continue working on this class to:
1) add three other basic operators - (subtraction), *(multiplication), and /(division) as member methods/functions of the class Rational (see the declaration and definition of addition operator +), see page 339 for their signatures;
2)
add the five comparison operators <=, >, >=, ==, and != as standalone functions (see the declaration and definition of the > operator), see page 337 for their signatures;
no need to define the input (>>) and output (<<) operators (they are written as standalone functions/methods), they are already defined for your convinience!
10/17 We will be meeting online, via Zoom meeting today

Sections 3.1, 3.2, 3.5, and 3.6

Lecture slides: CSI33-lecture08.pdf, CSI33-lecture08-part2.pdf (we only looked at the header file of the List class)

programs we did in class: List.h, List.cpp, testingList.cpp
programs (from the book, FYI, our goal): List.h, List.cpp, testList.cpp
Check out this one as well: unsigned.cpp

For self-development:
Investigate two data types in Python: array and set in Python.
Suggested exercises
(not for grade, but highly recommended):
1) True-False questions: p. 100 / 2, 3, 6
2) Short-answer questions: p.102 / 3, 4

Solutions: Chapter3-questionsAnswers-part1.pdf

Suggested project: page 104, programming exercise 9
10/12 Sections 3.3, 2.6

Quiz 1 at the end of the class, based on Chapter 1 material

Lecture slides

more programs (from the book):
unitTestingCard.py

Self-development: Section 3.4 talks about a Bridge game. You can read it and watch this nice video on how to play Bridge:
rules: https://www.acbl.org/learn/
video: https://www.youtube.com/watch?v=Tyd7KlsRYO4
another video: https://www.youtube.com/watch?v=9yzS_26fICk
Here is the code of the Hand.py
HW 5 (due date: Friday, 10/21)

1) 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!

2) Write unit tests to test the methods suit, suitName and rankNameof Card class in Card.py. Use Chapter2-unitTestingCardHW.py
  No classes on Tuesday, Wednesday, October 4-5th (Yom Kippur)
No classes on Monday, October 10th - Columbus Day
10/03 Sections 2.1-2.3, and 3.3 from the book.


Lecture slides

Programs:
cardADT.py, test_cardADT.py,
Card-spec.py,
Card.py, testCard.py,
Deck.py, testDeck.py

HW 4 (due date: Wednesday, 10/12)

Implement the card game given in this description in Python.
09/29 No in-person meeting today, asynchronous online class;

Please follow the study plan:
1) watch this video: Algorithm Analysis (continue with Binary Search) ~12 mins long
2) Grab the handout, and work on the three problems on one side of it with the help of this video: Handout, problems 1-3 on one side
3) Flip the page of the handout over and work on the last problem.
Do items 1) and 2) on your own: copy the program, run it, see what the function returns when n = 1, when n = 2, and when n=10. Write down the results.
Then proceed with this video that is working on items 3) - 5)

The handout: CSI33-Lecture05InClassPractice2.pdf
Suggested exercise (for practice, not for grade):
1) Look at your implementation of the Selection Sort.
What assymptotic running time does it have?
Here is the running time analysis of the Selection Sort.
2) estimate the run-time complexity of the following block of code:
# n is a positive integer
s = 0
for i in range(n):
      for j in range(10):
            s += 1
3) estimate the run-time complexity of the following block of code:
# 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"
09/28 Sections 1.1, 1.2, and 1.3

Lecture slides - part 1, Lecture slides - part 2

In-class work: CSI33-Lecture05Handout.pdf, CSI33-Lecture05InClassPractice2.pdf
Solutions: CSI33-Lecture05InClassPractice2-answers.pdf

Additional materials: BinarySearchIllustrated.pdf

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
HW 3 (due date: Thursday, 10/06):
Programming Exercise #9 , page 38 from Textbook (write it in Python)
comments:
1) Write the program in Python, do not use any built-in stuctures other than Python list
2) function squeeze should modify the original list by removing the duplicates
3) pay attention to everything you are asked to do!

Suggested exercises (for practice, not for grade):
1) Look at the example of a simple statistics program (interface) on page 15 in the textbook
2) True/False questions: p. 33 / 4-6, 9, 10 - not for grade
3) Multiple Choice questions: pp.34-35 / 1-6, 10 - not for grade
    Solutions: Chapter1solsTFMConly.pdf
4) Short-answer questions: p. 36 / 8 - not for grade
    Solution: Chapter1ShortAnswerQuestions.pdf
5) read about docstring conventions at http://www.python.org/dev/peps/pep-0257/
6) Watch a video about O, Ω, and Θ notations: https://youtu.be/6Ol2JbwoJp0
Homeworks, Midterm Exam and Final Exam warning:
The homework, midterm exam, and final exam work must be solely your work.
They are not for group work, they are not to be looked for the solutions in online resources.
If I notice that your homework is similar to somebody else in our class, both parties' homework score will be zero (same for Midterm and Final Exam).
If I notice that you found a solution in online resources, your score will be zero as well.
Both cases, copying from somebody or finding and solution in online resources, are academic dishonesty.
You will be given first and last warning.
If I notice anything hapenning again, you will be reported to the chairperson and you may end up with a failing grade for this class.

Academic Integrity
Academic dishonesty (such as plagiarism and cheating) is prohibited at Bronx Community College and is punishable by penalties, including failing grades, dismissal and expulsion. For additional information and the full policy on Academic Integrity, please consult the BCC College Catalog.

Tutoring Lab for CSI 30, 31, 32, 33, 35:
Online: (visit Blackboard -> BCC online tutoring at the top right corner)
      Monday 11 am - 2 pm
      Tuesday: 11 am - 3 pm

In-Person:
(Appointments are required for in-person support via  WCOnline )
      Wednesday: 2 pm - 8 pm
      Thursday: 11 am - 2 pm; 6 pm - 8 pm
09/21 Topics to be covered:
Chapter 8: Sections 8.1 Introduction and 8.2 C++ History and Background
Chapter 10: Sections 10.1 Introduction, 10.2 C++ pointers, and 10.3 Dynamic Arrays

Lecture slides

Practice questions
Answer to question 1 (picture)
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
3) Short-Answer questions: p. 399 / 5, 6
Solutions/Answers: Chapter10-questionsAnswers.pdf

More practice with pointers: http://condor.depaul.edu/ntomuro/courses/309/notes/pointer_exercises.html
09/19 Today we will refresh our memory about classes in Python and C++. We will be working on the class Complex of a complex number in its rectangular form (a+bi)

Lecture slides


Picture of the smart lock for the HW assignment:
HW 2 (due date: Wednesday, 09/28):
White a class that will emulate a smart door lock with pin pad.
Name the class SmartLock and see the features it should have:
  • every smart lock comes with an admin pin code, i.e. every instance of the class SmartLock should have admin's pin code as a required parameter.
  • the length of any pin code is only four digits (not more, not less)
  • the smart lock can have more than one pin code that will open the door. For example: the admin code, the code for kids, the code for in-laws, the code for cleaning crew, etc.
  • any smart lock can store up to 10 pin codes (not more)
  • to enter a new pin-code, define a method AddNewPinCode() that should have two parameters: admin's pin code (for verification) and new pin code
  • the smart lock doesn't need to store information about pin code's dedication (for kids or for in-laws, it doesn't matter to the lock)
  • any pin code, except for the admin's pin code, can be removed, hence define a method RemovePinCode() that should take two parameters: admin's pin code (for verification) and the pin code to be removed
  • The lock has only two states: OPEN and LOCKED, hence think about having a "state" attribute to store the state of the lock
  • define a method EnterPin() that takes only one parameter: a pin code. If the pin code is one of the valid ones, the door lock should change it's state to the opposite one, i.e. if it was locked, it should become ulocked, and vice versa, if it was unlocked, it should become locked.
  • define a method Lock(), that should lock the smart lock independently at what state was it in
  • Finally, define a method CheckState() that doesn't take any parameters, but returns the "state" of the lock to us - whether it is locked or not (you can either return True or False, or , 0 or 1, where True(1) is for "LOCKED" and False(0) for "UNLOCKED")

    Declare the class in a header file .h, put all the necessary definitions into the implementation .cpp file (if you find it necessary), finally the test code put into a separate .cpp file. Send all the files to me as attachments to an email with subject HW 2 in the subject field.
09/14 We worked on three algorithms: linear search, binary search (in both, Python and C++), and selection sort (in Python)

Lecture slides
Handouts / in-class materials: Selection Sort,
binarySearch.py

the programs we did in class:
linearSearch.py, linearBinarySearch.cpp, SelectionSort2.py
HW 1 (due date: Wednesday, 09/21):
implement the Selection sort in C++.
In your implementation:
* define a function SelectionSort that takes two formal parameters: the array and its size,
* assume that the capacity of the array is 100 elements,
* you may also assume that we are working only with integer values, but you can work with decimal numbers as well, just be consistent!

Comments: Send your cpp file as attachment to an email with subject HW 1 in the subject field.
09/12 Hello and welcome to CSI 33 class.
I plan to spend week and a half to two weeks on Python and C++ languages review.
Therefore, make sure that you have both compilers available and ready to be used.

If we don't have the compilers installed in our lab, we can use the following online compilers for now:
Python at replit or Python at OnlineGDB
C++

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: Wednesday, 09/15):
1) order the textbook

2) get the Python interpreter and C++ compiler, make sure they are working