Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7961307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:00:16+00:00 2026-06-04T05:00:16+00:00

What is the best time complexity O(n) of a function that solves boggle, where

  • 0

What is the best time complexity O(n) of a function that solves boggle, where the boggle board is n by n?

I feel that it’s n^2 since for each character we must look at 2(n-1) other characters. The interviewer argued that it’s not n^2 for an O(1) dictionary look-up.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:00:17+00:00Added an answer on June 4, 2026 at 5:00 am

    I finally figured it out. The answer turns out to be exponential in time.

    Imagine a 4X4 boggle grid

    ABCD
    EFGH
    IJKL
    MNOP
    

    Then for example, any of the ordered subsequences starting with A in ABCDHGFEIJKLPONM is a potential word; so is any of the ordered subsequences starting with A in AEIMNOPLHDCBFJKG or AEIMNOPLHGFIK or ABCDHLPONMIEFGKJ. Then we need to look at the potential words starting wiht B, then with C, etc.

    Let’s look at this another way. Say we only had to consider _ABCD, where _ represents some starting character, say X; then the potential words belong to the power set are:

    XD; XC; XCD; XB; XBD; etc.
    

    Hence, considering only the clockwise spirals starting at each character, we are already looking at n^2*2^(n-1). n^2 because the grid is n by n and so for a 4 by 4 grid there are 16 possible starting characters. And 2^(n-1) because of the powerset led by each starting character. Of course the clockwise spiral is not the only possible pattern. But we can already see the time complexity with that first pattern: Big-Omega(2^n) which is exponential.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please mention time complexity and best data structure to store these values, when values
Is System.currentTimeMillis() the best measure of time performance in Java? Are there any gotcha's
What is the best way to randomize the time part for a DATE column,
What is the best way to parse time from a string? Example string: this
Whats the best way to get the current time (HH:MM:SS) using Objective-C. I would
Having a hard time figuring out the best way to do this... I have
what is best way to measure computation time, with either STL C++ or Qt?
I'm having a tricky time in thrashing out how best to approach this particular
It is a best practise to initialise a variable at the time of declaration.
What would be the best way to see if the current time lies between

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.