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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:30:47+00:00 2026-05-15T15:30:47+00:00

Recently I have read about hash-tables in a very famous book Introduction to Algorithms

  • 0

Recently I have read about hash-tables in a very famous book “Introduction to Algorithms“. I haven’t used them in any real applications yet, but want to. But I don’t know how to start.
Can anyone give me some samples of using it, for example, how to realize a dictionary application (like ABBYY Lingvo) using hash-tables?
And finally I would like to know what is the difference between hash-tables and associative arrays in PHP, I mean which technology should I use and in which situations?
If I am wrong (I beg pardon) please correct me, because actually I am starting with hash-tables and I have just basic (theoretical) knowledge about them.
Thanks a lot.

  • 1 1 Answer
  • 2 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-15T15:30:48+00:00Added an answer on May 15, 2026 at 3:30 pm

    In PHP, associative arrays are implemented as hashtables, with a bit of extra functionality.

    However technically speaking, an associative array is not identical to a hashtable – it’s simply implemented in part with a hashtable behind the scenes. Because most of its implementation is a hashtable, it can do everything a hashtable can – but it can do more, too.

    For example, you can loop through an associative array using a for loop, which you can’t do with a hashtable.

    So while they’re similar, an associative array can actually do a superset of what a hashtable can do – so they’re not exactly the same thing. Think of it as hashtables plus extra functionality.

    Code examples:

    Using an associative array as a hashtable:

    $favoriteColor = array();
    $favoriteColor['bob']='blue';
    $favoriteColor['Peter']='red';
    $favoriteColor['Sally']='pink';
    echo 'bob likes: '.$favoriteColor['bob']."\n";
    echo 'Sally likes: '.$favoriteColor['Sally']."\n";
    //output: bob likes blue
    //        Sally likes pink
    

    Looping through an associative array:

    $idTable=array();
    $idTable['Tyler']=1;
    $idTable['Bill']=20;
    $idTable['Marc']=4;
    //up until here, we're using the array as a hashtable.
    
    //now we loop through the array - you can't do this with a hashtable:
    foreach($idTable as $person=>$id)
        echo 'id: '.$id.' | person: '.$person."\n";
    
    //output: id: 1 | person: Tyler
    //        id: 20 | person: Bill
    //        id: 4 | person: Marc
    

    Note especially how in the second example, the order of each element is maintained (Tyler, Bill Marc) based on the order in which they were entered into the array. This is a major difference between associative arrays and hashtables. A hashtable maintains no connection between the items it holds, whereas a PHP associative array does (you can even sort a PHP associative array).

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

Sidebar

Related Questions

I have recently read about the Command Pattern This pattern is used to represent
I have read about the push technologies recently. Using it real-time data streaming is
Recently I have read a lot about different NoSQL databases and how they are
I have recently read topics about memory fragmentation: How to solve Memory Fragmentation and
I have read many posts on this topic; among them and most recently .NET
I have recently read about how cursors should be avoided. Well, I would like
I have recently read an article about fast sqrt calculation. Therefore, I have decided
I have recently read bits and pieces about garbage collection (mostly in Java) and
Recently I read about the grid graphing system in R. It is very flexible
I recently read about the Dependency-Inversion Principal in Robert.C.Martin's excellent book Agile Principals, Patterns

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.