Searching and Hashing

14 flashcardsby MariaE
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
Most hash tables are not full.
  • TRUE
  • FALSE
2
Any function can be a hash function if it produces an integer that is suitable to be used as an array index.
  • TRUE
  • FALSE
3
If a class overrides the method equals, it should not override the method hashCode.
  • TRUE
  • FALSE
4
If the method equals considers two objects to be equal, then the method hashCode must return the same value for both objects.
  • FALSE
  • TRUE
5
Calling the method hashCode more than once on an object that has not been altered should return the same value.
  • FALSE
  • TRUE
6
The size of a hash table should always be an even number.
  • TRUE
  • FALSE
7
In open addressing with linear probing, a successful search for an entry that corresponds to a given search key could potentially follow a different probe sequence used to add the entry to the hash table.
  • FALSE
  • TRUE
8
True or False
  • TRUE
9
Calculate the hash code for “ACE” with g = 7, given Unicode 'A' = 65, 'C' = 67, 'E' = 69
Answer: 65 * 9 + 67 * 3 + 69 * 1 = 855
10
Given a hash table length of 29, what index will the value 371 map to?
Answer: 371 % 29 = 23
11
What is λ for a hash table with 500 locations and 200 entries that uses open addressing?
Answer: 200 / 500 = 0.40
12
What are the two categories for collision resolution?
[A] Linear Probing [B] Buckets
13
Which of the following are 4K+3 prime numbers? a) 6863 b) 857
a) 6863 YES b) 857 NO
14
Given the following possible implementations of the hashCode method, which of these would be valid implementations for a class's hashCode method?
  • @Override
    public int hashCode() {
    return 42;
    }
  • @Override
    public int hashCode() {
    return this.id;
    }
  • @Override
    public int hashCode() {
    return this.name.hashCode() * 31 + this.age;
    }
  • @Override
    public int hashCode() {
    return (int) (Math.random() * 1000);
    }
Study all 14 cards for free

More Computer science flashcards

Core Technical Principles 20%33 cardsComputer science · EnglishNickArchitecture in Parallel Processing28 cardsComputer science · English—Griffith—E1 Data and digital technologies21 cardsComputer science · EnglishellaL.2 starting a career in computer servicing17 cardsComputer science · EnglishstudentPlayers and Adversaries11 cardsComputer science · EnglishNijelousINSY3303: Network Architecture and Design (Ch. 6-9)165 cardsComputer science · EnglishAlejandroCybersecurity and Social Engineering126 cardsComputer science · EnglishAbelChapter 1: Network Models 89 cardsComputer science · EnglishManethelCybersecurity Exam 171 cardsComputer science · EnglishZackJDeep Learning: Backpropagation and Initialization59 cardsComputer science · EnglishElliottCPrinciples of Management Exam 1 Vocabulary47 cardsComputer science · EnglishAdinbealEvolución tecnológica: Las 6D y la Curva S40 cardsComputer science · SpanishLara

All Computer science decks

Study these decks in the app

Free on iPhone, Android, Mac and the web. Add any deck to your account in one tap.

Download on the App StoreGet it on Google Play
Study all 14 cards for free