OK, here's Rule 5, Section III, on scoring, from NBA.com(3) If the ball is in the air when the horn sounds ending a period, and it subsequently is touched by: (a) a defensive player, the goal, if successful, shall count; or (b) an offensive player, the period has ended. I would interpret that to mean that if the ball hit the floor and bounced in without touching a player, or anything that was out of bounds, it would count. I didn't find anything that would lead to a different interpretation, in the NBA or FIBA rules. I believe NCAA rules follow one or the other of those two, except where they have adopted their own special rules, i.e.: 35 second shot clock.
By rule, the points would be counted if the ball bounced and passed through the goal before expiration of time. However, if the clock expires during a tap or try for goal, the ball becomes dead when it bounces on the floor, thus ending the tap or try. So, no, the basket would not have counted.