Back to problems

Implement Android findViewById

Object-Oriented Programming · Robinhood · Easy

Implement Android’s findViewById(int id) method for a basic view tree in which every View carries a distinct ID. Given an ID, locate and return the matching View from the hierarchy. Describe how your implementation searches the hierarchy, and include unit tests that demonstrate that it works correctly. Method Signature Examples The hierarchy is written as [viewId, [childViews...]]. Example 1 Input: Output: The matching view is a direct child of the root, so the search…

Checking your access…