Courses‎ > ‎APCS - Term 1‎ > ‎Konstantinovich‎ > ‎

2019-02-04

posted Feb 4, 2019, 6:27 AM by Konstantinovich Samuel   [ updated Feb 4, 2019, 7:50 AM ]
Goal: More recursion practice

Guest talk:
Using a Neural Net to image/model the human brain
Today 3:45pm lecture hall A

Do Now: Discuss how to approach this problem:
When discussing assume you just want the letters a,b,c.
After you figure it out for abc, then consider maxLetter.
Return a List of all k letter strings of lowercase letters. 

Only the letters a-z inclusive, no capitalized letters or special characters.

1 <= maxLetter <= 26 , 1 is a, 26 is z.
Precondition: k >= 0

public static List<String> makeAllWords(int k, int
maxLetter)
e.g
makeAllWords(1,26) returns the list:
    ["a","b","c",..."z"]

makeAllWords(2,26) returns the list:
    [
"aa","ab","ac",..."az",
     "ba","bb","bc",..."bz",
     ...
     "za","zb","zc",..."zz"]

makeAllWords(3,3) returns the list:
    [
"aaa","aab","aac",
     "aba","abb","abc",    
     ...
     "cca","ccb","ccc"]

makeAllWords(4,2) returns the list:
    [
"aaaa","aaab"
     "aaba","aabb"
     ...
     "bbaa","bbab",
     "bbba","bbbb"]

Hint: For practical testing purposes, start with a small maxLetter so you can see the results more easily.


Classwork:
1. write makeAllWords.
(Finish this at home)

2. Work on the extra codingbat problems posted : https://codingbat.com/home/konstans@stuy.edu/apcs2
(extra for those of you that finish in class, will be part of a homework later)
Comments