GATE Computer ScienceHardGATE CSE · NIELIT
Words car, card, care, cart, cat, dog, door, dot, dove, do, cargo, carbon, catalog, cat are inserted into an initially empty trie (a duplicate insertion changes nothing). Counting the root, how many nodes does the trie have?
- A. 28
- B. 25
- C. 23
- D. 32
Correct answer: B. 25
Shared prefixes are stored once; counting new characters per word (car 3, card 1, care 1, cart 1, cat 1, dog 3, door 2, dot 1, dove 2, do 0, cargo 2, carbon 3, catalog 5, cat 0) gives 24 plus the root = 25.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A B-tree of order 5 (each node holds at most 4 keys) is built by inserting 1, 2, 3, …, 60 in increasing order. When a node overflows to 5…
- How many different arrays A[1..9] that are permutations of {1,…,9} satisfy the min-heap property (A[i] ≥ A[⌊i/2⌋] for every i ≥ 2)?
- What is the minimum number of comparisons needed in the worst case to find both the maximum and the minimum of 101 distinct numbers using…
- The KMP failure (prefix) function π[i] of pattern P = "abaabaabaabab" gives, for each prefix P[0..i], the length of its longest proper…
- A hash table with 7 buckets uses separate chaining, h(k) = k mod 7, and every new key is inserted at the head of its chain. The keys 50…
- A hash table of size 13 uses double hashing: the i-th probe for key k is (k mod 13 + i·(1 + k mod 11)) mod 13. The keys 18, 41, 22, 44…