Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A vocabulary (voc for short) is a set of (word, frequency) pairs. Find() is a function that takes a string and a voc as arguments

A vocabulary (voc for short) is a set of (word, frequency) pairs. Find() is a function that takes a string and a voc as arguments and checks whether the string is a word in the voc. If it is, return the frequency of the word; if not, return -1.

Suppose a voc has n (word, frequency) pairs, and there are many ways to store the voc. When the voc is stored as the following data structures, explain how the Find() function finds the frequency of a given word and what is the worst-case time complexity of the function.

(a) An array

(b) A hash table

(c) A binary search tree (BST)

(d) Please describe another data structure that is appropriate for this purpose. How does it work?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

Students also viewed these Databases questions

Question

Explain why the long-run aggregate-supply curve is vertical.

Answered: 1 week ago