How to search through directories and sub dir

Im working on a project that basically imitates the find and whereis commands. The program will take in a file name or regular expression and, starting with the current directory search downwards and match any files with that pattern and prints the path name. I don't understand how to do this without using find and where is how would I do it manually? I know it will involve a switch and the pushd and popd commands...thanks!

try this as a hint:

ls -R | grep <pattern>

How would I do it without using recursion but rather the directory stack (i.e. pushd and popd)

My psuedo code would be something like

Get reg exp or file name
search current dir against the reg exp, print # of files and path names of matching files
change dir and search new dir against reg exp print # of files and path names of matching files
change dir, etc

I'm just having some trouble figuring out how to get from one dir to another...i know there's cd but I won't always know the names of the directories at run time right?

Why don't you know the directory names at runtime, I don't understand, are you running in some exotic shell or something?

Also why do you need to avoid using recursion with built in functions?

Sorry if this sounds silly, but is this a homework question?

Why re-invent the wheel when find and grep will do everything you need?

Well I am new to Unix and still learning about shell programming sometimes you have to reinvent the wheel for understanding. I figured I would ask a more general question about searching through directories and sub directories but I also posted in the Homework forum. Thanks for the replies!