Queens, Hanoi, and Queues Flashcards
constructor for the general boardd
No inputs. assumes an 8 by 8 is desired
creates a board with all false.
sets boardSize to 8
sets queenscount to 0
copy constructor for queens
board size is the input.
creates an n by n board with all false.
sets boardSize to input boardsize
sets queenscount to 0
The key was that the count of the number of queens has dual meaning.
Besides the number of queens on the board, it is also the next row for placing a queen
time for the towers of hanoi problem with recoursion
exponential time since the number of moves is 2n – 1 for n disks
even if you could do this iteratively, it would stay exponential time because the number of moves stays the same
time for the fibbonacci sequence with recoursion
asking it to find the 100th term, it feels exponential time. Indeed it is exponential time although an iterative solution would be linear time. So, here recursion really hurts
is solveQueensProblem a standard recoursive function
olveQueensProblem is NOT a standard recursive function because it contains iteration too. It needs both to implement the technique called backtracking
rui = spike is equal to
rui.operator= (spike)
this
address of the calling class object
*this
this is a pointer that points to a clone of the current object
3 things i need to delete when there is a circularly linked node of size 1
delete the connection(next is nullptr)
delete the node (delete node)
set it to null (node = nullptr)
what do i need to do in order to delete the first item from a queue
delptr is first item(backptr next)
first item is now second item(backptr next is delptr next)
null delptrs connection(delptr next is nullptr)
delete delptr
when getting the size of a queue when must i loop until
until backptr next is backptr
you must then add another count for the final node
how to prevent work from a=a in the operator= member function
you only do copies in if(this != &rhsq)
then return *this at teh end
write a client which did cascading =’s
zach = rui = spike;
also saw that rui = spike; is equivalent to
rui.operator=(spike)