• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 18, 2024 |370 Views

SDE Sheet - Trie | (Insert and Search)

  Share  1 Like
Description
Discussion

This video is part of the Trie section under GFG SDE Sheet.

Complete the Insert and Search functions for a Trie Data Structure. 

  1. Insert: Accepts the Trie's root and a string, modifies the root in-place, and returns nothing.
  2. Search: Takes the Trie's root and a string, returns true if the string is in the Trie, otherwise false.

Note: To test the correctness of your code, the code-judge will be inserting a list of N strings called into the Trie, and then will search for the string key in the Trie. The code-judge will generate 1 if the key is present in the Trie, else 0.

Example 1:

Input:
n = 8
list[] = {the, a, there, answer, any, by, bye, their}
key = the
Output: 1
Explanation: 
"the" is present in the given set of strings. 

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Problem: https://www.geeksforgeeks.org/problems/trie-insert-and-search0651/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Article Link: https://www.geeksforgeeks.org/trie-insert-and-search/