1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Andru [333]
2 years ago
10

Create a program which reads in CSV data of Creatures and loads them into aHash Map. The key of this hash map will be the name o

f each creature. For your hash function, you can simply use the sum of all ASCII values. You can also come up with your own hash function. Your program should present a menu to the user allowing them to look up a creature by name. Additionally, create a function that allows the user to insert a new creature. This creature should be added to the existing hash map. If the name entered by the user already exists, DO NOT ADD IT TO THE HASH MAP. Simply report that the creature already exists. If the creature is unique and successfully added, report the calculated index value. Your hash array should start as size4. You will need to implement a rehashing function to maintain a load factor of 0.75. Collision resolution should be handled via separate chaining with linked lists.
Other Requirements
•Read in a CSV file from the command line when running the program.
•Convert the raw CSV data into the creature struct and add it to a HashMap
•Make sure you properly release all of your allocated memory.
•Format your code consistently.
•Function declarations, structs, and preprocess directives should be placed in a corresponding header file.
•Save your code for this problem ascreature_hash.(c|h).
Creature struct
typedef struct {
char *name;
char *type;
int hp;
int ac;
int speed;
} Creature;
Example Run
1. Search

2. Add Creature

3. Exit

> 1

Enter name: Terrasque

Unable to find "Terrasque"

1. Search

2. Add Creature

3. Exit

> 2

Enter name: Storm Giant

Enter type: Huge giant

Enter HP: 230

Enter AC: 16

Enter speed: 50

Storm Giant added at index 3.

CSV file: Name, hp, ac, speed, type

Rakshasa,110,16,40,Fiend
Priest,27,13,25,Humanoid
Berserker,67,13,30,Humanoid
Fire Elemental,102,13,50,Elemental
Kraken,472,18,20,Monstrosity
Centaur,45,12,50,Monstrosity
Mage,40,12,30,Humanoid
Hell Hound,45,15,50,Fiend
Basilisk,52,15,20,Elemental
Androsphinx,199,17,40,Monstrosity
Efreeti,200,17,40,Elemental
Balor,262,19,40,Fiend
Chain Devil,142,19,40,Fiend
Adult Black Dragon,195,19,80,Dragon
Adult Blue Dragon,225,19,80,Dragon
Adult Red Dragon,256,19,80,Dragon
Please help in C
Computers and Technology
1 answer:
Mekhanik [1.2K]2 years ago
8 0

Answer:

Explanation:

class TableInput{

    Object key;

    Object value;

    TableInput(Object key, Object value){

       this.key = key;

       this.value = value;

   }

}

abstract class HashTable {

   protected TableInput[] tableInput;

   protected int size;

   HashTable (int size) {

       this.size = size;

       tableInput = new TableInput[size];

       for (int i = 0; i <= size - 1; i++){

           tableInput[i] = null;

       }

   }

   abstract int hash(Object key);

   public abstract void insert(Object key, Object value);

   public abstract Object retrieve(Object key);

}

class ChainedTableInput extends TableInput {

   ChainedTableInput(Object key, Object value){

       super(key, value);

       this.next = null;

   }

    ChainedTableInput next;

}

class ChainedHashTable extends HashTable {

   ChainedHashTable(int size) {

       super(size);

       // TODO Auto-generated constructor stub

   }

   public int hash(Object key){

       return key.hashCode() % size;

   }

   public Object retrieve(Object key){

       ChainedTableInput p;

       p = (ChainedTableInput) tableInput[hash(key)];

       while(p != null && !p.key.equals(key)){

           p = p.next;

       }

       if (p != null){

           return p.value;

       }

       else {

           return null;

       }

   }

   public void insert(Object key, Object value){

       ChainedTableInput entry = new ChainedTableInput(key, value);

       int k = hash(key);

       ChainedTableInput p = (ChainedTableInput) tableInput[k];

       if (p == null){

           tableInput[k] = entry;

           return;

       }

       while(!p.key.equals(key) && p.next != null){

           p = p.next;

       }

       if (!p.key.equals(key)){

           p.next = entry;

       }

   }

   public double distance(Object key1, Object key2){

       final int R = 6373;

       Double lat1 = Double.parseDouble(Object);

   }

   }

You might be interested in
The function keys are labeled from f1 to wat
Fed [463]
If we are talking about a simple North American Keyboard, The answer would be F1 to F12
Hope this Helps!!!
8 0
3 years ago
PLZ HELP WILL MARK BRANLIEST Jargon is:
77julia77 [94]

Answer:C language that include terms that only a select

Explanation:

It’s the right one

7 0
2 years ago
In Python write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs
Lilit [14]

Answer:

ansList =input().split() #get input and split it by space

ansList = [int(i) for i in ansList if int(i)>0] #turn string to integer,and get all positive integers

print(ansList)

Explanation: I think this would work for you. I leace comments in the answer.

3 0
1 year ago
In the tcp/ip protocol that allows communication across the internet, what does tcp do?
DedPeter [7]

TCP tells or state how applications can make channels of communication across a network.

<h3>What is the role of TCP?</h3>

TCP is known to often help in the management of how a message is put together into smaller packets before they are sent or transmitted over the internet and then put together again in the right way at the arriving or destination address.

Therefore, TCP tells or state how applications can make channels of communication across a network.

Learn more about TCP from

brainly.com/question/17387945

#SPJ11

7 0
2 years ago
Which aspect of design theory describes the relationship of one object to another in size? A.value B.form C.proportion D.tecture
pashok25 [27]

Answer:

<u>Proportion </u>is the aspect in design theory that describe the relationship of one object to another object in size.

Explanation:

Proportion is an important aspect in design theory in terms of size. It refers to the relationship between object of the design in terms of size. The relation between size of different object in design theory can describe as, if the size of one object increases or decreases, it may leads to change in size of other object. It is called proportion.

If the size of one object increase with the size of other object, the relation is called direct proportion. If the size of one object decrease with the increase in size of other object is called inverse proportion.

7 0
3 years ago
Other questions:
  • At regular intervals the AP in an infrastructure network or wireless device in an ad hoc network sends a ____ frame both to anno
    8·1 answer
  • _____ refer(s) to computer programs that provide instructions for a computer to execute a desired task. Answer .a.Software .b. I
    7·1 answer
  • Oiê gentee, bom dia O que você entende por cultura digital ??
    12·1 answer
  • Why are ethics important in PR?
    8·1 answer
  • Using hard disk to temporarily store data or instructions from ram is referred to as the
    12·1 answer
  • Your computer system is a participant in an asymmetric cryptography system. You've crafted a message to be sent to another user.
    13·1 answer
  • Essay about evolution of media shaped the values and norms of the society
    11·1 answer
  • If the list [8,1,4,2,10,0] is sorted with the selection sort algorithm, what is the list at the 4th step of the algorithm?
    13·1 answer
  • What is a motherboard​
    10·1 answer
  • Instructions
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!