In بِالْقَاضِي, بِـ is the preposition and الْقَاضِي its genitive complement. Together they form a prepositional phrase.
The phrase attaches to the verb مَرَرْتُ and indicates who was passed by.
Review: the noun is a subject in example 1, an object in example 2, and a genitive noun in example 3.