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 933353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:49:18+00:00 2026-05-15T20:49:18+00:00

I am trying to create a class that implements the Map interface. So I

  • 0

I am trying to create a class that implements the Map interface. So I am writing code that will check if the calling object is empty or not. However I am a little confused as to which data structure I should use internally. At present I am using a Hash Table.
Thanks in advance

  • 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-05-15T20:49:18+00:00Added an answer on May 15, 2026 at 8:49 pm

    From Wikipedia,

    Associative arrays are usually used
    when lookup is the most frequent
    operation. For this reason,
    implementations are usually designed
    to allow speedy lookup, at the expense
    of slower insertion and a larger
    storage footprint than other data
    structures (such as association
    lists).

    Efficient representations:
    There are two main efficient data
    structures used to represent
    associative arrays, the hash table and
    the self-balancing binary search tree
    (such as a red-black tree or an AVL
    tree). Skip lists are also an
    alternative, though relatively new and
    not as widely used. B-trees (and
    variants) can also be used, and are
    commonly used when the associative
    array is too large to reside entirely
    in memory, for instance in a simple
    database. Relative advantages and
    disadvantages include:

    1. Asymptotic operation performance: Hash tables have faster average lookup
      and insertion time, O(1), compared to
      a balanced binary search tree’s Θ(log
      n), while balanced trees have faster
      worst-case lookup and insertion time,
      O(log n) as compared to Θ(n). Skip
      lists have O(n) worst-case and O(log
      n) average-case operation times, but
      with less insertion and deletion
      overhead in practice than balanced
      binary trees.

    2. Ordering preservation: Balanced binary trees and skip lists preserve
      ordering — allowing one to efficiently
      iterate over the keys in order or to
      efficiently locate an association
      whose key is nearest to a given value.
      Hash tables do not preserve ordering
      and therefore cannot perform these
      operations as efficiently (they
      require the data to be sorted in a
      separate step).

    3. Range queries: Balanced binary trees can be easily adapted to
      efficiently assign a single value to a
      large ordered range of keys, or to
      count the number of keys in an ordered
      range. (With n elements in the array
      and performing the operation on a
      contiguous range of m keys, a balanced
      binary tree will take O(log(n)+m) time
      while a hash table would need Θ(n)
      time as it needs to search the entire
      table.)

    4. Allocation behavior: Hash tables with open addressing store all data in
      a large contiguous block of memory
      that is reallocated infrequently,
      whereas tree allocations perform many
      small, frequent allocations. As a
      result hash tables may be difficult to
      allocate in a fragmented heap, and
      conversely trees may cause heap
      fragmentation. Trees are also more
      vulnerable to inefficiencies in
      allocators.

    5. Compactness: Hash tables can have more compact storage for small value
      types, especially when the values are
      bits.

    6. Persistence: There are simple persistent versions of balanced binary
      trees, which are especially prominent
      in functional languages.

    7. Supporting new key types: Building a hash table requires a reasonable
      hash function for the key type, which
      can be difficult to write well, while
      balanced binary trees and skip lists
      only require a total ordering on the
      keys.

    Sometimes simple implementations of
    one data structure or the other have
    disadvantages that can be overcome by
    better design. For example:

    • Hash tables that use untrusted input as keys may be vulnerable to
      denial-of-service attacks where an
      untrusted user supplies data intended
      to generate large numbers of
      collisions. This may be overcome by
      choosing hash functions at random from
      a universal family, or by hashing
      untrusted input with a cryptographic
      hash function before insertion.

    • Simple balanced trees waste space on pointers and allocation
      metadata; these problems can be
      mitigated by storing multiple
      elements in each node and by using
      memory pools.

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

Sidebar

Ask A Question

Stats

  • Questions 542k
  • Answers 542k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use: SELECT p.id as a, p.url as b, t.id as… May 17, 2026 at 3:22 am
  • Editorial Team
    Editorial Team added an answer There are two parts to the problem First Issue You… May 17, 2026 at 3:19 am
  • Editorial Team
    Editorial Team added an answer I thought I'd show the regex approach, too. It doesn't… May 17, 2026 at 3:18 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to create a LINQ to SQL class that represents the latest version
I'm trying to create a UserControl that inherits from a generic class. It does
I'm trying to create a C++ class, with a templated superclass. The idea being,
I'm trying to create an instance of a class at run time. The classes
I'm trying to create a Quicksort base class using VB.NET, taking it an array
I currently have a class and I'm trying to create an easy GUI to
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a user account in a test. But getting a Object reference
Trying to create my first iPhone app that would play back audio. When I
I'm trying to write a managed library in C# that will act as an

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.