> On 8 Jul 2019, at 05:57, ducasse <[email protected]> wrote: > > More feedback :) > > Do not return nil > Check the last lecture of the mooc > > Did you read Pharo with Style? > > I do not know if LinkedList is the one of the system used by Process but in > that case use the alternate implementation.
Sorry I’ still jet lagged and sleepy But - bfs: is a bad name. - Also why not having a block to specify what we are looking for? > > > bfs: info > "Breadth fisrt search for an information. If there is no key containing > given infomration returns nil. If the info is found returns a node containing > it" > | queue | > self isEmpty > ifTrue: [ ^nil ]. > queue := LinkedList new. > queue addLast: self root. > > [ queue isNotEmpty ] whileTrue: [ > | node | > node := queue removeFirst. > node key == info > ifTrue: [ ^node ]. > node leftChild isNotNil > ifTrue: [ queue addLast: node leftChild ]. > node rightChild isNotNil > ifTrue: [ queue addLast: node rightChild ]. > ]. > ^nil. > > => > > bfs: info > "Breadth fisrt search for an information. If there is no key containing > given infomration returns nil. If the info is found returns a node containing > it" > | queue | > self isEmpty ifTrue: [ ^ self ]. > queue := LinkedList new. > queue addLast: self root. > > [ queue isNotEmpty ] whileTrue: [ > | node | > node := queue removeFirst. > node key == info > ifTrue: [ ^node ]. > node leftChild isNotNil > ifTrue: [ queue addLast: node leftChild ]. > node rightChild isNotNil > ifTrue: [ queue addLast: node rightChild ]. > ]
