GATE DA · 2024 · DA
Question 38: Programming, Data Structures and Algorithms
Give it a try, then reveal the answer to check your work.
Question 38
DAMCQ2 marksNeeds review
Consider the following Python code:
def count(child_dict, i):
if i not in child_dict.keys():
return 1
ans = 1
for j in child_dict[i]:
ans += count(child_dict, j)
return ans
child_dict = dict()
child_dict[0] = [1,2]
child_dict[1] = [3,4,5]
child_dict[2] = [6,7,8]
print(count(child_dict,0))
Which ONE of the following is the output of this code?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerEXPLORE & PRACTISE
Paper and topic context
See where this question comes from and choose what to practise next.
2024DA
GATE DA 2024 · Paper 1
Data Science and Artificial Intelligence · Original paper archive
- Section
- Data Science and Artificial Intelligence
- Question type
- Multiple choice (MCQ)
- Marks
- 2 marks
Practise related topics
Explore more previous year questions using this question’s imported topic tags.
data science
GATE DA previous year questions
artificial intelligence
GATE DA previous year questions
computing
GATE DA previous year questions
Programming, Data Structures and Algorithms
GATE DA previous year questions
Comments
Ask a question, share your approach, or help someone understand.
Log in to view the discussion
You’re not logged in. Log in or create an account to see discussions and add comments.